diff --git a/.github/workflows/reusable-create-homebrew-pr.yml b/.github/workflows/reusable-create-homebrew-pr.yml index f9bdeb8e89b..c855480eb2c 100644 --- a/.github/workflows/reusable-create-homebrew-pr.yml +++ b/.github/workflows/reusable-create-homebrew-pr.yml @@ -22,29 +22,82 @@ permissions: contents: read jobs: + fetch-release-checksums: + runs-on: ubuntu-latest + env: + ARM_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-arm64.tar.gz + AMD_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-amd64.tar.gz + outputs: + arm-sha256: ${{ steps.fetch-arm-sha256.outputs.sha256 }} + amd-sha256: ${{ steps.fetch-amd-sha256.outputs.sha256 }} + arm-tarball-url: ${{ env.ARM_TARBALL_URL }} + amd-tarball-url: ${{ env.AMD_TARBALL_URL }} + steps: + - name: Fetch arm sha256 + id: fetch-arm-sha256 + if: inputs.release-condition != 'false' + run: | + echo "sha256=$(curl -sSL ${{ env.ARM_TARBALL_URL }} | shasum -a 256 | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT" + - name: Fetch amd sha256 + id: fetch-amd-sha256 + if: inputs.release-condition != 'false' + run: | + echo "sha256=$(curl -sSL ${{ env.AMD_TARBALL_URL }} | shasum -a 256 | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT" + homebrew-create-pr: runs-on: macos-latest - + needs: fetch-release-checksums steps: - name: Checks release pre-condition if: inputs.release-condition == 'false' run: | echo The release-condition evaluated to false. echo Skipping all the next steps. - - name: Create PR on Homebrew Formula repository + + - name: Checkout garden repo if: inputs.release-condition != 'false' - uses: stefreak/bump-homebrew-formula-action@82352c3cbbc2acdec5a064502447b555f18496fc + uses: actions/checkout@v4 with: - tag-name: ${{ inputs.release-version }} - formula-name: garden-cli - formula-path: Formula/garden-cli.rb - homebrew-tap: garden-io/homebrew-garden - base-branch: main - create-pullrequest: true - download-url: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-amd64.tar.gz + repository: garden-io/garden + ref: main + path: garden + token: ${{ secrets.COMMITTER_TOKEN }} + + - name: Checkout homebrew repo + if: inputs.release-condition != 'false' + uses: actions/checkout@v4 + with: + repository: garden-io/homebrew-garden + ref: main + path: homebrew-garden + token: ${{ secrets.COMMITTER_TOKEN }} + + - name: Template Homebrew Formula + if: inputs.release-condition != 'false' + uses: cuchi/jinja2-action@v1.2.0 + with: + template: garden/support/homebrew-formula.rb.j2 + output_file: homebrew-garden/Formula/garden-cli.rb + strict: true + variables: | + version=${{ inputs.release-version }}} + armTarballUrl=${{ needs.fetch-release-checksums.outputs.arm-tarball-url }} + amdTarballUrl=${{ needs.fetch-release-checksums.outputs.amd-tarball-url }} + armSha256=${{ needs.fetch-release-checksums.outputs.arm-sha256 }} + amdSha256=${{ needs.fetch-release-checksums.outputs.amd-sha256 }} + + - name: Create PR on Homebrew Repository + if: inputs.release-condition != 'false' + uses: peter-evans/create-pull-request@v5 + with: + path: homebrew-garden + token: ${{ secrets.COMMITTER_TOKEN }} commit-message: ${{ inputs.commit-message }} - env: - COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} + title: Bump garden-cli to ${{ inputs.release-version }} + body: ${{ inputs.commit-message}} + branch: garden-cli-${{ inputs.release-version }} + reviewers: ${{ github.triggering_actor }} + - name: Adding markdown summary if: inputs.release-condition != 'false' run: | diff --git a/support/homebrew-formula.rb b/support/homebrew-formula.rb.j2 similarity index 66% rename from support/homebrew-formula.rb rename to support/homebrew-formula.rb.j2 index 2bae3002ada..458a601ff36 100644 --- a/support/homebrew-formula.rb +++ b/support/homebrew-formula.rb.j2 @@ -1,9 +1,17 @@ class GardenCli < Formula desc "Development engine for Kubernetes" homepage "https://garden.io" - url "{{{tarballUrl}}}" + version "{{version}}" - sha256 "{{sha256}}" + + # Determine architecture + if Hardware::CPU.arm? + url "{{armTarballUrl}}" + sha256 "{{armSha256}}" + else + url "{{amdTarballUrl}}" + sha256 "{{amdSha256}}" + end def install libexec.install "garden", "fsevents.node", "static", "pty.node"