Skip to content

Commit

Permalink
Add script to easily update Spin formula for new releases
Browse files Browse the repository at this point in the history
Signed-off-by: Kate Goldenring <[email protected]>
  • Loading branch information
kate-goldenring committed Mar 28, 2024
1 parent 70793b3 commit 2d8a3b4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
37 changes: 37 additions & 0 deletions scripts/bump-spin-formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

VERSION=$1
FORMULA=${2:-Formula/Spin.rb}

usage() {
echo "Usage: $0 <VERSION> [<FORMULA_PATH>]"
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."

0 comments on commit 2d8a3b4

Please sign in to comment.