Skip to content

Commit 2d8a3b4

Browse files
Add script to easily update Spin formula for new releases
Signed-off-by: Kate Goldenring <[email protected]>
1 parent 70793b3 commit 2d8a3b4

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ a pull request.
2222
```sh
2323
brew test-bot --only-tap-syntax
2424
```
25+
26+
### Updating the Spin Formula for a New Release
27+
28+
Run the [`bump-spin-formula.sh`](scripts/bump-spin-formula.sh) to update the
29+
formula to use the assets of a specific release (say `v2.4.0`):
30+
31+
```sh
32+
./scripts/bump-spin-formula.sh v2.4.0
33+
```
34+
35+
The script will update the version in the formula, get the checksums file from
36+
the specified release, and update the checksum for each architecture and OS.

scripts/bump-spin-formula.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
VERSION=$1
4+
FORMULA=${2:-Formula/Spin.rb}
5+
6+
usage() {
7+
echo "Usage: $0 <VERSION> [<FORMULA_PATH>]"
8+
echo "Updates the Spin Formula for the specified release version"
9+
echo "Example: $0 3.0.0"
10+
}
11+
12+
if [ $# -ne 1 ]; then
13+
usage
14+
exit 1
15+
fi
16+
17+
# Get the checksum file for the release
18+
wget -qO checksums.txt "https://github.com/fermyon/spin/releases/download/$VERSION/checksums-$VERSION.txt"
19+
20+
# Update the formula version
21+
ERSION="${VERSION:1}"
22+
sed -i '' -e "s/version \"[^\"]*\"/version \"$ERSION\"/" $FORMULA
23+
24+
# Update the sha256 checksums for each OS/Arch
25+
while read -r line; do
26+
filename=$(echo "$line" | awk '{print $2}')
27+
sha256=$(echo "$line" | awk '{print $1}')
28+
os_arch="${filename:12}"
29+
if grep -q "$os_arch" $FORMULA; then
30+
sed -i '' -E "/url \".*$os_arch\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"$sha256\"/; }" $FORMULA
31+
fi
32+
33+
done < checksums.txt
34+
35+
rm checksums.txt
36+
37+
echo "Formula updated to version $VERSION with new checksums."

0 commit comments

Comments
 (0)