Skip to content

Commit 254cf44

Browse files
mjcheethamdscho
authored andcommitted
homebrew: add GitHub workflow to release Cask
Add a GitHub workflow that is triggered on the `release` event to automatically update the `microsoft-git` Homebrew Cask on the `microsoft/git` Tap. A secret `HOMEBREW_TOKEN` with push permissions to the `microsoft/homebrew-git` repository must exist. A pull request will be created at the moment to allow for last minute manual verification. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 32ab787 commit 254cf44

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Diff for: .github/workflows/release-homebrew.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Update Homebrew Tap
2+
on:
3+
release:
4+
types: [released]
5+
6+
permissions:
7+
id-token: write # required for Azure login via OIDC
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
environment: release
13+
steps:
14+
- id: version
15+
name: Compute version number
16+
run: |
17+
echo "result=$(echo $GITHUB_REF | sed -e "s/^refs\/tags\/v//")" >>$GITHUB_OUTPUT
18+
- id: hash
19+
name: Compute release asset hash
20+
uses: mjcheetham/asset-hash@v1.1
21+
with:
22+
asset: /git-(.*)\.pkg/
23+
hash: sha256
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Log into Azure
26+
uses: azure/login@v2
27+
with:
28+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
29+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
30+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
31+
- name: Retrieve token
32+
id: token
33+
run: |
34+
az keyvault secret show \
35+
--name ${{ secrets.HOMEBREW_TOKEN_SECRET_NAME }} \
36+
--vault-name ${{ secrets.AZURE_VAULT }} \
37+
--query "value" -o tsv >token &&
38+
# avoid outputting the token under `set -x` by using `sed` instead of `echo`
39+
sed s/^/::add-mask::/ <token &&
40+
sed s/^/result=/ <token >>$GITHUB_OUTPUT &&
41+
rm token
42+
- name: Update scalar Cask
43+
uses: mjcheetham/update-homebrew@v1.4
44+
with:
45+
token: ${{ steps.token.outputs.result }}
46+
tap: microsoft/git
47+
name: microsoft-git
48+
type: cask
49+
version: ${{ steps.version.outputs.result }}
50+
sha256: ${{ steps.hash.outputs.result }}
51+
alwaysUsePullRequest: false

0 commit comments

Comments
 (0)