diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 54aebea..5c2f56c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,8 +75,7 @@ You can read our [full policy](https://www.eff.org/about/opportunities/volunteer This one is for maintainers of Rayhunter. 1. Make a PR changing the versions in `Cargo.toml` and other files. - This could be automated better but right now it's manual. You can do this easily with sed: - `sed -i "" -E 's/x.x.x/y.y.y/g' */Cargo.toml installer-gui/src-tauri/Cargo.toml` + This can be done by running `scripts/set-versions.sh VERSION_NUM`. 2. Merge the PR, make a tag, and push the tag to GitHub. Pushing the tag should trigger the [release workflow](https://github.com/EFForg/rayhunter/actions/workflows/release.yml). diff --git a/scripts/set-versions.sh b/scripts/set-versions.sh new file mode 100755 index 0000000..a4a5ae0 --- /dev/null +++ b/scripts/set-versions.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Sets Rayhunter package versions in preparation for a release. +# +# Usage: ./scripts/set-versions.sh VERSION_NUM +# Example: ./scripts/set-versions.sh 0.12.3 + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" + +cd "$PROJECT_DIR" + +if [ -z "$1" ]; then + echo "Error: Missing required version number argument." + exit 1 +fi + +SED_COMMAND="s/^version = \".*\"/version = \"$1\"/" +TOML_FILES=(*/Cargo.toml installer-gui/src-tauri/Cargo.toml) + +echo "Updating Cargo.toml files" +if sed --version > /dev/null 2>&1; then + # we have GNU sed + sed -i -E "$SED_COMMAND" "${TOML_FILES[@]}" +else + # we have macOS/BSD sed + sed -i "" -E "$SED_COMMAND" "${TOML_FILES[@]}" +fi + +echo "Updating Cargo.lock" +cargo update --workspace