-
Notifications
You must be signed in to change notification settings - Fork 1
266 lines (229 loc) · 7.63 KB
/
release.yml
File metadata and controls
266 lines (229 loc) · 7.63 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
name: devir-linux-amd64
- goos: linux
goarch: arm64
name: devir-linux-arm64
- goos: darwin
goarch: amd64
name: devir-darwin-amd64
- goos: darwin
goarch: arm64
name: devir-darwin-arm64
- goos: windows
goarch: amd64
name: devir-windows-amd64
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.24"
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${{ steps.version.outputs.VERSION }}
LDFLAGS="-s -w -X main.Version=${VERSION}"
if [ "$GOOS" = "windows" ]; then
go build -ldflags="${LDFLAGS}" -o devir.exe ./cmd/devir
else
go build -ldflags="${LDFLAGS}" -o devir ./cmd/devir
fi
- name: Create archive
run: |
if [ "${{ matrix.goos }}" = "windows" ]; then
zip ${{ matrix.name }}.zip devir.exe
else
tar -czvf ${{ matrix.name }}.tar.gz devir
fi
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.name }}
path: |
*.tar.gz
*.zip
extension:
name: Build Extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
run: cd extension && pnpm install
- name: Build extension
run: cd extension && pnpm build
- name: Create extension zip
run: |
cd extension/dist
zip -r ../../devir-extension.zip .
- name: Upload extension artifact
uses: actions/upload-artifact@v6
with:
name: devir-extension
path: devir-extension.zip
release:
name: Release
needs: [build, extension]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: dist
merge-multiple: true
- name: Create checksums
run: |
cd dist
sha256sum * > checksums.txt
cat checksums.txt
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release with Changelog
run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets
run: |
gh release upload ${{ steps.version.outputs.VERSION }} \
dist/*.tar.gz \
dist/*.zip \
dist/checksums.txt \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
name: Update Homebrew
needs: release
runs-on: ubuntu-latest
steps:
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Download checksums
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Waiting for release assets to be available..."
sleep 30
for i in {1..10}; do
if gh release download "v${{ steps.version.outputs.VERSION }}" \
--repo productdevbook/devir \
--pattern "checksums.txt" \
--clobber; then
echo "Downloaded checksums.txt"
cat checksums.txt
break
fi
echo "Attempt $i failed, retrying in 15s..."
sleep 15
done
- name: Extract SHA256
id: sha
run: |
if [ ! -f checksums.txt ]; then
echo "Error: checksums.txt not found"
exit 1
fi
DARWIN_ARM64=$(grep 'darwin-arm64' checksums.txt | awk '{print $1}')
DARWIN_AMD64=$(grep 'darwin-amd64' checksums.txt | awk '{print $1}')
LINUX_ARM64=$(grep 'linux-arm64' checksums.txt | awk '{print $1}')
LINUX_AMD64=$(grep 'linux-amd64' checksums.txt | awk '{print $1}')
echo "DARWIN_ARM64=$DARWIN_ARM64"
echo "DARWIN_AMD64=$DARWIN_AMD64"
echo "LINUX_ARM64=$LINUX_ARM64"
echo "LINUX_AMD64=$LINUX_AMD64"
if [ -z "$DARWIN_ARM64" ] || [ -z "$DARWIN_AMD64" ] || [ -z "$LINUX_ARM64" ] || [ -z "$LINUX_AMD64" ]; then
echo "Error: One or more SHA256 values are empty"
exit 1
fi
echo "DARWIN_ARM64=$DARWIN_ARM64" >> $GITHUB_OUTPUT
echo "DARWIN_AMD64=$DARWIN_AMD64" >> $GITHUB_OUTPUT
echo "LINUX_ARM64=$LINUX_ARM64" >> $GITHUB_OUTPUT
echo "LINUX_AMD64=$LINUX_AMD64" >> $GITHUB_OUTPUT
- name: Checkout homebrew-tap
uses: actions/checkout@v6
with:
repository: productdevbook/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
mkdir -p homebrew-tap/Formula
cat > homebrew-tap/Formula/devir.rb << EOF
class Devir < Formula
desc "Dev Runner CLI - Terminal UI for managing dev services"
homepage "https://github.com/productdevbook/devir"
version "${{ steps.version.outputs.VERSION }}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/productdevbook/devir/releases/download/v${{ steps.version.outputs.VERSION }}/devir-darwin-arm64.tar.gz"
sha256 "${{ steps.sha.outputs.DARWIN_ARM64 }}"
end
on_intel do
url "https://github.com/productdevbook/devir/releases/download/v${{ steps.version.outputs.VERSION }}/devir-darwin-amd64.tar.gz"
sha256 "${{ steps.sha.outputs.DARWIN_AMD64 }}"
end
end
on_linux do
on_arm do
url "https://github.com/productdevbook/devir/releases/download/v${{ steps.version.outputs.VERSION }}/devir-linux-arm64.tar.gz"
sha256 "${{ steps.sha.outputs.LINUX_ARM64 }}"
end
on_intel do
url "https://github.com/productdevbook/devir/releases/download/v${{ steps.version.outputs.VERSION }}/devir-linux-amd64.tar.gz"
sha256 "${{ steps.sha.outputs.LINUX_AMD64 }}"
end
end
def install
bin.install "devir"
end
test do
system "#{bin}/devir", "-h"
end
end
EOF
- name: Commit and push
run: |
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/devir.rb
git commit -m "Update devir to ${{ steps.version.outputs.VERSION }}"
git push