From 642b1fff01d1bccdc7729cad828470daee0bf113 Mon Sep 17 00:00:00 2001 From: Hayden Baker Date: Wed, 10 Apr 2024 13:00:23 -0700 Subject: [PATCH] add post-release action to run after releases (#2238) --- .github/workflows/post-release.yml | 29 +++++++ .github/workflows/update-brew.yml | 118 ----------------------------- 2 files changed, 29 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/post-release.yml delete mode 100644 .github/workflows/update-brew.yml diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml new file mode 100644 index 00000000000..3d3d7333d70 --- /dev/null +++ b/.github/workflows/post-release.yml @@ -0,0 +1,29 @@ +# Runs certain jobs after a release is published or on an as-needed basis (manually), +# e.g. triggering an update to the homebrew-tap when a new version of the CLI is available + +name: post-release +on: + release: + types: [released] + workflow_dispatch: # on button click + inputs: + version: + description: 'The version that was released (e.g. 1.47.0)' + required: true + type: string + +env: + version: ${{ github.event.inputs.version || github.ref_name }} + +jobs: + homebrew-tap: + runs-on: ubuntu-latest + steps: + - name: Trigger homebrew-tap update + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: autoupdate + repo: smithy-lang/homebrew-tap + inputs: '{ "version": "${{ env.version }}" }' + # Required when using the `repo` option + token: "${{ secrets.PR_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/update-brew.yml b/.github/workflows/update-brew.yml deleted file mode 100644 index 9a86b65de5f..00000000000 --- a/.github/workflows/update-brew.yml +++ /dev/null @@ -1,118 +0,0 @@ -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 'github-smithy-automation@amazon.com' - 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 }}