Skip to content

Commit

Permalink
Merge pull request #232 from getditto/dhm/convenience-release-scripts
Browse files Browse the repository at this point in the history
Add convenience release scripts
  • Loading branch information
danielhenrymantilla authored Jul 30, 2024
2 parents 2485abe + af3e083 commit e5dfba8
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ path = "src/_lib.rs"

[package]
name = "safer-ffi"
version = "0.1.10-rc3" # Keep in sync
version = "0.1.10-rc4" # Keep in sync
authors = [
"Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>",
]
Expand Down Expand Up @@ -179,7 +179,7 @@ version = "0.0.3"

[dependencies.safer_ffi-proc_macros]
path = "src/proc_macro"
version = "=0.1.10-rc3" # Keep in sync
version = "=0.1.10-rc4" # Keep in sync

[workspace]
members = [
Expand Down
4 changes: 2 additions & 2 deletions ffi_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions scripts/cargo_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# Script to cargo publish a new version of safer-ffi

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"

(set -x
git status >&2
)
if [ -n "$(git status --porcelain)" ]; then
echo >&2 "❌ Uncommitted changes detected."
false
fi

current_version="$(sed -nE 's/^version = "(.*)"\s*# Keep in sync.*/\1/p' src/proc_macro/Cargo.toml)"
(set -x
current_version="${current_version}"
)

echo -n "Version desired? [${current_version}] "
read -r desired_version

set -x
desired_version="${desired_version:-$current_version}"
{ set +x; } 2>/dev/null

(set -x
./scripts/change_version.sh "${desired_version}"
)

if [ -n "$(git status --porcelain)" ]; then
git add -u
(set -x
git commit -m "Version \`${desired_version}\` release"
)
fi
(set -x
git push
)

PACKAGES=(
src/proc_macro/
./
)
for package in "${PACKAGES[@]}"; do
(set -x
cd "${package}"
cargo publish
)
done
40 changes: 40 additions & 0 deletions scripts/change_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# Script to bump the `safer-ffi` version of the repo (both in `.toml` and `.lock` files).

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"

usage() {
cat >&2 <<-EOF
Usage:
${0} <new version number>
Current version:
${0} $(sed -nE 's/^version = "(.*)"\s*# Keep in sync.*/\1/p' src/proc_macro/Cargo.toml)
EOF
false
}

new_version="${1:?$(usage)}"

PACKAGES=(
Cargo.toml
src/proc_macro/Cargo.toml
)

for package in "${PACKAGES[@]}"; do
(
set -x
sed -i.bak -E 's/^version = "(=?)(.*)"(\s*# Keep in sync)/version = "\1'"${new_version}"'"\3/' "${package}"
)
rm "${package}".bak
done

find . -type f -name 'Cargo.lock' -print0 \
| while IFS= read -r -d '' lockfile; do
dir="$(dirname ${lockfile})"
(
set -x
cd "${dir}" && cargo update -vw
)
done
2 changes: 1 addition & 1 deletion src/proc_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ proc-macro = true

[package]
name = "safer_ffi-proc_macros"
version = "0.1.10-rc3" # Keep in sync
version = "0.1.10-rc4" # Keep in sync
authors = ["Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>"]
edition = "2021"

Expand Down

0 comments on commit e5dfba8

Please sign in to comment.