Skip to content

Commit 7fcf8ac

Browse files
committed
feat: create homebrew cask updates via pull requests from a fork
1 parent 456c189 commit 7fcf8ac

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎.github/workflows/release.yaml‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,57 @@ jobs:
7272
AUTHKEY_BASE64: ${{ secrets.APPLE_API_KEY }}
7373
- name: Install Snapcraft
7474
uses: samuelmeuli/action-snapcraft@v3
75-
75+
76+
- name: Ensure tap fork exists
77+
run: |
78+
gh repo fork stackitcloud/homebrew-tap \
79+
--fork-name homebrew-tap-fork \
80+
--clone=false || true
81+
env:
82+
GH_TOKEN: ${{ secrets.CLI_RELEASE }}
83+
7684
- name: Run GoReleaser
7785
uses: goreleaser/[email protected]
7886
with:
7987
args: release --clean
8088
env:
8189
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
HOMEBREW_RELEASE_TOKEN: ${{ secrets.CLI_RELEASE }}
8291
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
8392
GPG_KEY_PATH: ${{ env.GPG_KEY_PATH }}
8493
# nfpm-rpm signing needs this env to be set.
8594
NFPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
8695

96+
- name: Create issue tracking upstream Homebrew PR
97+
run: |
98+
# Wait a moment for GitHub's search index to catch up
99+
sleep 5
100+
101+
# Find the open PR authored by your account in the upstream repository
102+
PR_URL=$(gh pr list \
103+
--repo stackitcloud/homebrew-tap \
104+
--author "@me" \
105+
--state open \
106+
--search "${{ github.ref_name }}" \
107+
--limit 1 \
108+
--json url \
109+
--jq '.[0].url')
110+
111+
if [ -n "$PR_URL" ] && [ "$PR_URL" != "null" ]; then
112+
gh issue create \
113+
--repo "${{ github.repository }}" \
114+
--title "Homebrew Cask PR opened for ${{ github.ref_name }}" \
115+
--body "A pull request has been automatically created for release **${{ github.ref_name }}**:
116+
117+
- **PR:** $PR_URL
118+
- **Upstream:** \`stackitcloud/homebrew-tap:main\`
119+
- **Branch:** \`${{ github.ref_name }}\`"
120+
else
121+
echo "Warning: Could not find an open PR in stackitcloud/homebrew-tap matching release ${{ github.ref_name }}."
122+
fi
123+
env:
124+
GH_TOKEN: ${{ secrets.CLI_RELEASE }}
125+
87126
- name: Clean up GPG key file
88127
if: always()
89128
run: |

‎.goreleaser.yaml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ homebrew_casks:
133133
- name: stackit
134134
directory: Casks
135135
repository:
136-
owner: stackitcloud
137-
name: homebrew-tap
136+
owner: stackit-pipeline
137+
name: homebrew-tap-fork
138+
token: "{{ .Env.HOMEBREW_RELEASE_TOKEN }}"
139+
branch: "{{.ProjectName}}-{{.Version}}"
140+
pull_request:
141+
enabled: true
142+
base:
143+
owner: stackitcloud
144+
name: homebrew-tap
145+
branch: main
138146
commit_author:
139147
name: CLI Release Bot
140148

0 commit comments

Comments
 (0)