bump-relay-stable #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump stable formula | |
on: | |
repository_dispatch: | |
types: | |
- bump-relay-stable | |
jobs: | |
bump-relay-stable: | |
name: Bump stable formula | |
runs-on: macos-11.0 | |
if: github.event.action == 'bump-relay-stable' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install GNU sed | |
run: brew install gnu-sed | |
- name: Fetch public release | |
uses: octokit/request-action@v2.x | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
route: GET /repos/cachewerk/relay/releases/tags/{tag_name} | |
tag_name: ${{ github.event.client_payload.tag }} | |
- name: Download release assets | |
env: | |
TAG_NAME: ${{ github.event.client_payload.tag }} | |
run: | | |
artifacts=$( | |
curl -sS --fail "https://builds.r2.relay.so/$TAG_NAME/artifacts.json" \ | |
| jq -r '.[] | select(.os == "darwin") | .url' | |
) | |
for artifact in $artifacts; do | |
echo "Downloading $artifact" | |
curl -sS --fail -o $(basename $artifact) --location $artifact | |
done | |
- name: Update formula | |
env: | |
TAG_NAME: ${{ github.event.client_payload.tag }} | |
run: | | |
echo "Updating stable tag to $TAG_NAME" | |
gsed -i "s/, tag: \"v.*\"/, tag: \"$TAG_NAME\"/" Formula/*.rb | |
for f in *.tar.gz; do | |
HASH=$(shasum --algorithm 256 $f | head -c 64) | |
MARKER=$(echo $f | cut -d - -f 3- | gsed 's/.tar.gz//') | |
URL="https://builds.r2.relay.so/$TAG_NAME/$f" | |
echo "Setting URL for stable $MARKER marker to $URL" | |
gsed -i "/.*# stable: $MARKER/!b;n;c\ \ \ \ \ \ \ \ url \"$URL\"" Formula/*.rb | |
echo "Setting checksum for stable $MARKER marker to $HASH" | |
gsed -i "/.*# stable: $MARKER/!b;n;n;c\ \ \ \ \ \ \ \ sha256 \"$HASH\"" Formula/*.rb | |
done | |
- name: Check formula style | |
run: | | |
brew style \ | |
--fix \ | |
--display-cop-names \ | |
--except-cops=FormulaAudit/Caveats,Layout/LineLength,FormulaAuditStrict/TestPresent \ | |
Formula/*.rb | |
- name: Commit changes | |
env: | |
TAG_NAME: ${{ github.event.client_payload.tag }} | |
run: | | |
BRANCH=pr/stable-$TAG_NAME | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
echo "Pushing changes to $BRANCH branch" | |
git checkout -b $BRANCH | |
git add Formula/*.rb | |
git commit -m "Bump stable to $TAG_NAME" | |
git push -u origin $BRANCH | |
- name: Open pull request | |
uses: octokit/request-action@v2.x | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
route: POST /repos/cachewerk/homebrew-tap/pulls | |
base: main | |
head: pr/stable-${{ github.event.client_payload.tag }} | |
title: Relay ${{ github.event.client_payload.tag }} | |
body: See https://github.com/cachewerk/relay/releases/tag/${{ github.event.client_payload.tag }} |