Skip to content

Commit

Permalink
ci(*): add workflow to create Spin bump PR on release event; a few sc…
Browse files Browse the repository at this point in the history
…ript updates

Signed-off-by: Vaughn Dice <[email protected]>
  • Loading branch information
vdice committed Apr 4, 2024
1 parent 803a640 commit 8ddf41c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/bump-spin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bump Spin

on:
repository_dispatch:
types:
- spin-release

jobs:
create-pr:
name: Create PR with Spin Formula bumped
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Bump Spin Formula
shell: bash
run: ./scripts/bump-spin-formula.sh ${{ github.event.client_payload.version }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: "chore(spin.rb): bump Spin to ${{ github.event.client_payload.version }}"
title: "chore(spin.rb): bump Spin to ${{ github.event.client_payload.version }}"
body: Update the Spin formula with ${{ github.event.client_payload.version }}
branch: bump-spin-${{ github.event.client_payload.version }}
base: main
delete-branch: true
committer: fermybot <[email protected]>
author: fermybot <[email protected]>
signoff: true
17 changes: 11 additions & 6 deletions scripts/bump-spin-formula.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/bash
set -eoux pipefail

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

# -i syntax differs between GNU and Mac sed; this usage is supported by both
SED_INPLACE='sed -i.bak'

# cleanup
trap 'rm checksums.txt **/*.bak' EXIT

usage() {
echo "Usage: $0 <VERSION> [<FORMULA_PATH>]"
Expand Down Expand Up @@ -30,17 +37,15 @@ fi

# Remove the 'v' prefix from the version
ERSION="${VERSION:1}"
sed -i '' -e "s/version \"[^\"]*\"/version \"$ERSION\"/" $FORMULA
$SED_INPLACE -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}"
os_arch=$(echo ${filename} | sed "s/spin-v${ERSION}-//g")
if grep -q "$os_arch" $FORMULA; then
sed -i '' -E "/url \".*$os_arch\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"$sha256\"/; }" $FORMULA
$SED_INPLACE -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 8ddf41c

Please sign in to comment.