-
Notifications
You must be signed in to change notification settings - Fork 3
282 lines (235 loc) · 8.89 KB
/
release.yml
File metadata and controls
282 lines (235 loc) · 8.89 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
build:
name: Build Binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
output: wt-linux-amd64
bottle: x86_64_linux
- goos: linux
goarch: arm64
output: wt-linux-arm64
bottle: aarch64_linux
- goos: darwin
goarch: amd64
output: wt-darwin-amd64
bottle: ventura
- goos: darwin
goarch: arm64
output: wt-darwin-arm64
bottle: arm64_sonoma
steps:
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/wt .
- name: Create Homebrew bottle
run: |
# Create bottle directory structure: wt/VERSION/bin/wt
mkdir -p wt/${{ steps.version.outputs.VERSION }}/bin
cp dist/wt wt/${{ steps.version.outputs.VERSION }}/bin/
# Create tarball with proper naming: wt-VERSION.PLATFORM.bottle.tar.gz
tar czf wt-${{ steps.version.outputs.VERSION }}.${{ matrix.bottle }}.bottle.tar.gz wt
# Also keep the raw binary for non-Homebrew users
mv dist/wt dist/${{ matrix.output }}
- name: Upload bottle artifact
uses: actions/upload-artifact@v4
with:
name: bottle-${{ matrix.bottle }}
path: wt-${{ steps.version.outputs.VERSION }}.${{ matrix.bottle }}.bottle.tar.gz
if-no-files-found: error
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.output }}
path: dist/${{ matrix.output }}
if-no-files-found: error
build-windows:
name: Build Windows Binary
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build Windows binary
env:
GOOS: windows
GOARCH: amd64
run: |
mkdir -p dist
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/wt-windows-amd64.exe .
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: binary-wt-windows-amd64.exe
path: dist/wt-windows-amd64.exe
if-no-files-found: error
release:
name: Create Release
needs: [build, build-windows]
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Organize release files
run: |
mkdir -p release
# Move bottles to release directory
find artifacts/bottle-* -name "*.bottle.tar.gz" -exec mv {} release/ \;
# Move binaries to release directory
find artifacts/binary-* -type f -exec mv {} release/ \;
ls -la release/
- name: Generate checksums
run: |
cd release
shasum -a 256 * > checksums.txt
cat checksums.txt
- name: Upload checksums artifact
uses: actions/upload-artifact@v4
with:
name: checksums
path: release/checksums.txt
if-no-files-found: error
- name: Create GitHub Release
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--generate-notes \
release/*
update-formula:
name: Update Homebrew Formula
needs: release
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
repositories: |
wt
homebrew-tap
- name: Download checksums artifact
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Extract version and checksums
id: version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Find checksums.txt in artifacts
CHECKSUMS_FILE=$(find artifacts -name "checksums.txt" -type f | head -1)
# Extract bottle SHA256s from checksums
AARCH64_LINUX=$(grep "wt-${VERSION}.aarch64_linux.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
ARM64_SONOMA=$(grep "wt-${VERSION}.arm64_sonoma.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
VENTURA=$(grep "wt-${VERSION}.ventura.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
X86_64_LINUX=$(grep "wt-${VERSION}.x86_64_linux.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
echo "AARCH64_LINUX=$AARCH64_LINUX" >> $GITHUB_OUTPUT
echo "ARM64_SONOMA=$ARM64_SONOMA" >> $GITHUB_OUTPUT
echo "VENTURA=$VENTURA" >> $GITHUB_OUTPUT
echo "X86_64_LINUX=$X86_64_LINUX" >> $GITHUB_OUTPUT
- name: Download source tarball and calculate SHA256
id: source
run: |
VERSION=${{ steps.version.outputs.VERSION }}
wget "https://github.com/timvw/wt/archive/refs/tags/v${VERSION}.tar.gz" -O source.tar.gz
SOURCE_SHA256=$(shasum -a 256 source.tar.gz | awk '{print $1}')
echo "SHA256=$SOURCE_SHA256" >> $GITHUB_OUTPUT
- name: Clone homebrew-tap repository
run: |
git clone https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/timvw/homebrew-tap.git
- name: Update formula
run: |
cd homebrew-tap
VERSION=${{ steps.version.outputs.VERSION }}
# Update the formula file
cat > Formula/wt.rb << 'EOF'
class Wt < Formula
desc "Git worktree helper"
homepage "https://github.com/timvw/wt"
url "https://github.com/timvw/wt/archive/refs/tags/v${{ steps.version.outputs.VERSION }}.tar.gz"
sha256 "${{ steps.source.outputs.SHA256 }}"
license "MIT"
head "https://github.com/timvw/wt.git", branch: "main"
bottle do
root_url "https://github.com/timvw/wt/releases/download/v${{ steps.version.outputs.VERSION }}"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "${{ steps.version.outputs.ARM64_SONOMA }}"
sha256 cellar: :any_skip_relocation, ventura: "${{ steps.version.outputs.VENTURA }}"
sha256 cellar: :any_skip_relocation, x86_64_linux: "${{ steps.version.outputs.X86_64_LINUX }}"
sha256 cellar: :any_skip_relocation, aarch64_linux: "${{ steps.version.outputs.AARCH64_LINUX }}"
end
def install
bin.install "wt"
end
test do
assert_match "wt version", shell_output("#{bin}/wt version")
end
end
EOF
- name: Commit and push changes
run: |
cd homebrew-tap
git config user.name "timvw-ci-bot[bot]"
git config user.email "timvw-ci-bot[bot]@users.noreply.github.com"
git add Formula/wt.rb
git commit -m "chore: update wt formula to v${{ steps.version.outputs.VERSION }}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
git push