Skip to content

update-brew

update-brew #8

Workflow file for this run

name: update-brew
on:
release:
types: [released]
workflow_dispatch: # on button click
env:
release_prefix: https://github.com/smithy-lang/smithy/releases/download
jobs:
download-and-save:
runs-on: ubuntu-latest
steps:
- name: mac
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-darwin-x86_64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: mac-arm
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-darwin-aarch64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: linux
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-linux-x86_64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: linux-arm
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-linux-aarch64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: brew-artifacts
path: '*.sha256'
retention-days: 7
create-pr:
runs-on: ubuntu-latest
needs: download-and-save
permissions:
pull-requests: write
steps:
- name: Get artifacts
id: download
uses: actions/download-artifact@v4
with:
name: brew-artifacts
- name: Checkout bottle repo
uses: actions/checkout@v4
with:
repository: 'smithy-lang/homebrew-tap'
path: 'homebrew-tap'
ref: 'main'
token: ${{ secrets.PR_TOKEN }}
- name: Update version
run: |
version="${GITHUB_REF##*/}"
tmp=$(mktemp)
jq --arg version "${version}" '.version = $version' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update root_url
run: |
version="${GITHUB_REF##*/}"
tmp=$(mktemp)
jq --arg release_url "${{ env.release_prefix }}" --arg version "${version}" '.bottle.root_url = "\($release_url)/\($version)/smithy-cli"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update mac
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-darwin-x86_64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.sierra = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update mac-arm
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-darwin-aarch64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.arm64_big_sur = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update linux
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-linux-x86_64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update linux-arm
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-linux-aarch64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux_arm = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Set up new git branch for version bump
working-directory: homebrew-tap
run: |
git config user.name 'smithy-automation'
git config user.email '[email protected]'
git checkout -b "automation/bump-smithy-cli-version/${GITHUB_REF##*/}"
- name: Create PR
working-directory: homebrew-tap
run: |
git add bottle-configs/smithy-cli.json
git commit -m "chore: upgrade smithy-cli to ${GITHUB_REF##*/}"
git push --set-upstream origin "automation/bump-smithy-cli-version/${GITHUB_REF##*/}"
gh pr create \
--title "[Automation] chore: upgrade smithy-cli to ${GITHUB_REF##*/}" \
--body "Created by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
--base main
env:
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}