Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Publish kargo to brew #3011

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
52 changes: 52 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -333,3 +333,55 @@ jobs:
base64-subjects: "${{ needs.combine_hashes.outputs.hashes }}"
upload-assets: true # Optional: Upload to a new release
provenance-name: kargo-cli.intoto.jsonl

update-homebrew-formula:
krancour marked this conversation as resolved.
Show resolved Hide resolved
if: github.event_name == 'release' && github.event.action == 'released' # Runs only for stable releases
runs-on: ubuntu-latest
needs: [ publish-image, publish-cli ]
steps:
- name: Checkout tap repository
uses: actions/checkout@v4
with:
repository: akuity/homebrew-tap
token: ${{ secrets.TAP_PAT }}

- name: Export LATEST_TAG and VERSION_SUFFIX
run: |
LATEST_TAG=$(curl -qsSL \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
'${{ github.api_url }}/repos/${{ github.repository }}/releases/latest' \
| jq -r .tag_name)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV

VERSION_SUFFIX=$(echo "${{ github.ref_name }}" | grep -oP "^v\d+\.\d+" | sed 's/^v/@/')
echo "VERSION_SUFFIX=$VERSION_SUFFIX" >> $GITHUB_ENV

- name: Setup Git User
uses: fregante/setup-git-user@v2

- name: Update formula and push changes
run: |
git checkout -b update-kargo-${{ github.ref_name }}

if [[ ${{ github.ref_name }} == ${{ env.LATEST_TAG }} ]]; then
./update.sh kargo ${{ github.ref_name }}
git add kargo.rb
fi

./update.sh kargo ${{ github.ref_name }} ${{ env.VERSION_SUFFIX }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns about this script. It seems a bit brittle and also isn't producing formulae that pass the default CI tests included in a new tap (which I added into that repo not long ago since they were absent).

There's been previous mention of using goreleaser to publish the CLI to our homebrew tap. I've played with it a bit and it works extremely well. I am highly in favor of pursuing that further.

The one catch is that the free/open source version of goreleaser cannot publish versioned formulae, but a pro subscription isn't very expensive and I will sort out how we can get one.

git add kargo${{ env.VERSION_SUFFIX }}.rb
git commit -m "chore: update Kargo cli to version ${{ github.ref_name }}"
git push origin update-kargo-${{ github.ref_name }}

- name: Open PR
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.TAP_PAT }}
commit-message: "Update Kargo formula to version ${{ github.ref_name }}"
branch: update-kargo-${{ github.ref_name }}
base: main
title: "chore: update Kargo formula to version ${{ github.ref_name }}"
body: "This PR updates the Homebrew formula for Kargo to version ${{ github.ref_name }}."
delete-branch: 'true'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ build-cli:
./cmd/cli

################################################################################
# Used for Nighty/Unstable builds #
# Used for Nightly/Unstable builds #
################################################################################

.PHONY: build-nightly-cli