Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience release scripts #232

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading