-
-
Notifications
You must be signed in to change notification settings - Fork 231
ci: auto-bump Homebrew formula on release #546
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
Merged
+60
−0
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Bump Homebrew formula | ||
|
|
||
| # When a versioned release is published, update the Homebrew tap formula | ||
| # (Sapd/homebrew-headsetcontrol) to the new tarball URL + sha256. | ||
| # | ||
| # Pushes to the tap over SSH using a dedicated write deploy key stored in the | ||
| # repository secret HOMEBREW_TAP_DEPLOY_KEY (scoped to the tap repo only). | ||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Release tag to bump the formula to (e.g. 4.1.0)" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| bump: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Resolve tag, url and sha256 | ||
| id: src | ||
| env: | ||
| TAG: ${{ github.event.release.tag_name || inputs.tag }} | ||
| run: | | ||
| url="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/${TAG}.tar.gz" | ||
| sha="$(curl -fsSL "$url" | sha256sum | cut -d' ' -f1)" | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | ||
| echo "url=$url" >> "$GITHUB_OUTPUT" | ||
| echo "sha=$sha" >> "$GITHUB_OUTPUT" | ||
| echo "Bumping to $TAG ($sha)" | ||
|
|
||
| - name: Checkout tap | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| repository: Sapd/homebrew-headsetcontrol | ||
| ssh-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} | ||
|
|
||
| - name: Update and push formula | ||
| env: | ||
| TAG: ${{ steps.src.outputs.tag }} | ||
| URL: ${{ steps.src.outputs.url }} | ||
| SHA: ${{ steps.src.outputs.sha }} | ||
| run: | | ||
| f="Formula/headsetcontrol.rb" | ||
| # Only the stable `url` line (leave `head` untouched) | ||
| sed -i -E "s|^( url ).*|\1\"${URL}\"|" "$f" | ||
| sed -i -E "s|^( sha256 ).*|\1\"${SHA}\"|" "$f" | ||
| grep -E "^ (url|sha256) " "$f" | ||
| if git diff --quiet; then | ||
| echo "Formula already up to date."; exit 0 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git commit -am "headsetcontrol ${TAG}" | ||
| git push | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When releases are created by the repository's existing
.github/workflows/release.yml, thencipollo/release-actionis explicitly authenticated withsecrets.GITHUB_TOKEN(release.yml:88-100). GitHub does not start new workflow runs for events generated by that token, so its publishedreleaseevent will not invoke this workflow; normal tagged releases therefore leave the Homebrew formula unchanged unless someone manually dispatches this workflow. Add the bump as a job in the release pipeline or create the release with a token that can trigger downstream workflows.Useful? React with 👍 / 👎.