Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/bump-homebrew.yml
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]
Comment on lines +9 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Run the formula bump from the release workflow

When releases are created by the repository's existing .github/workflows/release.yml, the ncipollo/release-action is explicitly authenticated with secrets.GITHUB_TOKEN (release.yml:88-100). GitHub does not start new workflow runs for events generated by that token, so its published release event 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 👍 / 👎.

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
Loading