diff --git a/README.md b/README.md index 69de52b..267e535 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,15 @@ a pull request. ```sh brew test-bot --only-tap-syntax ``` + +### Updating the Spin Formula for a New Release + +Run the [`bump-spin-formula.sh`](scripts/bump-spin-formula.sh) to update the +formula to use the assets of a specific release (say `v2.4.0`): + +```sh +./scripts/bump-spin-formula.sh v2.4.0 +``` + +The script will update the version in the formula, get the checksums file from +the specified release, and update the checksum for each architecture and OS. \ No newline at end of file diff --git a/scripts/bump-spin-formula.sh b/scripts/bump-spin-formula.sh new file mode 100755 index 0000000..a14c963 --- /dev/null +++ b/scripts/bump-spin-formula.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +VERSION=$1 +FORMULA=${2:-Formula/Spin.rb} + +usage() { + echo "Usage: $0 []" + echo "Updates the Spin Formula for the specified release version" + echo "Example: $0 3.0.0" +} + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + +# Get the checksum file for the release +wget -qO checksums.txt "https://github.com/fermyon/spin/releases/download/$VERSION/checksums-$VERSION.txt" + +# Update the formula version +ERSION="${VERSION:1}" +sed -i '' -e "s/version \"[^\"]*\"/version \"$ERSION\"/" $FORMULA + +# Update the sha256 checksums for each OS/Arch +while read -r line; do + filename=$(echo "$line" | awk '{print $2}') + sha256=$(echo "$line" | awk '{print $1}') + os_arch="${filename:12}" + if grep -q "$os_arch" $FORMULA; then + sed -i '' -E "/url \".*$os_arch\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"$sha256\"/; }" $FORMULA + fi + +done < checksums.txt + +rm checksums.txt + +echo "Formula updated to version $VERSION with new checksums."