-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (65 loc) · 2.7 KB
/
brew.yml
File metadata and controls
74 lines (65 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Homebrew Tap
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish to the Homebrew tap (for example: v0.1.1)"
required: true
type: string
permissions:
contents: read
jobs:
brew:
runs-on: ubuntu-latest
env:
HOMEBREW_TAP_REPOSITORY: ${{ vars.HOMEBREW_TAP_REPOSITORY }}
steps:
- uses: actions/checkout@v4
- name: Validate tap token
env:
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
run: |
if [ -z "${HOMEBREW_TAP_GITHUB_TOKEN}" ]; then
echo "HOMEBREW_TAP_GITHUB_TOKEN is not configured for this repository." >&2
echo "Add a token with write access to your Homebrew tap repository in Settings > Secrets and variables > Actions." >&2
exit 1
fi
- name: Validate tap repository
run: |
TAP_REPOSITORY="${HOMEBREW_TAP_REPOSITORY:-libi/homebrew-tap}"
if ! git ls-remote "https://github.com/${TAP_REPOSITORY}.git" >/dev/null 2>&1; then
echo "Homebrew tap repository not found: ${TAP_REPOSITORY}" >&2
echo "Create the repository first, then set Actions variable HOMEBREW_TAP_REPOSITORY if you are not using libi/homebrew-tap." >&2
exit 1
fi
- name: Update Homebrew tap formula
env:
TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
run: |
TAP_REPOSITORY="${HOMEBREW_TAP_REPOSITORY:-libi/homebrew-tap}"
if [ -z "${TAG}" ]; then
echo "Release tag is required." >&2
exit 1
fi
case "${TAG}" in
v*) ;;
*)
echo "Release tag must start with 'v', got: ${TAG}" >&2
exit 1
;;
esac
curl -fsSL -o /tmp/ko-browser-src.tar.gz "https://github.com/libi/ko-browser/archive/refs/tags/${TAG}.tar.gz"
SHA256=$(shasum -a 256 /tmp/ko-browser-src.tar.gz | awk '{print $1}')
git clone "https://x-access-token:${HOMEBREW_TAP_GITHUB_TOKEN}@github.com/${TAP_REPOSITORY}.git" /tmp/homebrew-tap
mkdir -p /tmp/homebrew-tap/Formula
bash ./scripts/render-homebrew-formula.sh "${TAG}" "${SHA256}" > /tmp/homebrew-tap/Formula/ko-browser.rb
cd /tmp/homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/ko-browser.rb
git commit -m "brew: update ko-browser to ${TAG}" || exit 0
git push