-
Notifications
You must be signed in to change notification settings - Fork 12
276 lines (237 loc) · 9.1 KB
/
release.yml
File metadata and controls
276 lines (237 loc) · 9.1 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v0.2.0)'
required: true
permissions:
contents: write
jobs:
detect-release-type:
runs-on: ubuntu-latest
outputs:
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
version: ${{ steps.check.outputs.version }}
version_clean: ${{ steps.check.outputs.version_clean }}
steps:
- name: Determine release type
id: check
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
VERSION_CLEAN="${VERSION#v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_clean=${VERSION_CLEAN}" >> $GITHUB_OUTPUT
if [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "ERROR: version '${VERSION}' does not match expected format vX.Y.Z[-(rc|beta|alpha).N]"
exit 1
fi
if [[ "${VERSION_CLEAN}" =~ (rc|beta|alpha) ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "Detected pre-release: ${VERSION}"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "Detected stable release: ${VERSION}"
fi
gate-tests:
needs: detect-release-type
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Vet
run: go vet ./...
- name: Unit tests
run: make test-unit
- name: Integration tests
run: make test-integration
- name: Destructive tests
run: make test-destructive
build:
needs: [detect-release-type, gate-tests]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: darwin
arch: amd64
- os: darwin
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: '0'
run: |
go build -ldflags="-s -w -X github.com/openbootdotdev/openboot/internal/cli.version=${{ needs.detect-release-type.outputs.version_clean }}" -trimpath -o openboot-${{ matrix.os }}-${{ matrix.arch }} ./cmd/openboot
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: openboot-${{ matrix.os }}-${{ matrix.arch }}
path: openboot-${{ matrix.os }}-${{ matrix.arch }}
smoke-test:
needs: [detect-release-type, build]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Download arm64 artifact
uses: actions/download-artifact@v4
with:
name: openboot-darwin-arm64
path: artifacts
- name: Prepare release binary for testing
run: |
chmod +x artifacts/openboot-darwin-arm64
cp artifacts/openboot-darwin-arm64 ./openboot
- name: Verify binary version string
run: |
VERSION_OUTPUT=$(./openboot version 2>&1 || true)
echo "Binary version output: ${VERSION_OUTPUT}"
EXPECTED="${{ needs.detect-release-type.outputs.version_clean }}"
if [[ "${VERSION_OUTPUT}" != *"${EXPECTED}"* ]]; then
echo "ERROR: Binary version '${VERSION_OUTPUT}' does not contain expected '${EXPECTED}'"
exit 1
fi
- name: Run smoke tests against release binary
run: make test-smoke-prebuilt
- name: Upload snapshot artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: smoke-test-results
path: |
/tmp/openboot-smoke-*.json
retention-days: 7
if-no-files-found: ignore
release:
needs: [detect-release-type, build, smoke-test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate source tarball
run: |
VERSION="${{ needs.detect-release-type.outputs.version }}"
VERSION_CLEAN="${{ needs.detect-release-type.outputs.version_clean }}"
git archive --format=tar.gz --prefix="openboot-${VERSION_CLEAN}/" -o "openboot-${VERSION_CLEAN}.tar.gz" "${VERSION}"
- name: Generate checksums
run: |
cd artifacts
find . -type f -name 'openboot-*' -exec sha256sum {} \; | sed 's|./[^/]*/||' > checksums.txt
mv checksums.txt ..
cd ..
VERSION_CLEAN="${{ needs.detect-release-type.outputs.version_clean }}"
sha256sum "openboot-${VERSION_CLEAN}.tar.gz" >> checksums.txt
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.detect-release-type.outputs.version }}
name: OpenBoot ${{ needs.detect-release-type.outputs.version }}
draft: false
prerelease: ${{ needs.detect-release-type.outputs.is_prerelease == 'true' }}
files: |
artifacts/openboot-darwin-amd64/openboot-darwin-amd64
artifacts/openboot-darwin-arm64/openboot-darwin-arm64
openboot-*.tar.gz
checksums.txt
body: |
## Installation
```bash
brew install openbootdotdev/tap/openboot
```
## Binaries
| Platform | Architecture | Download |
|----------|--------------|----------|
| macOS | Apple Silicon (M1/M2/M3) | `openboot-darwin-arm64` |
| macOS | Intel | `openboot-darwin-amd64` |
update-homebrew-tap:
needs: [detect-release-type, release]
if: needs.detect-release-type.outputs.is_prerelease == 'false'
runs-on: ubuntu-latest
steps:
- name: Download release binaries and calculate SHA256
id: sha
run: |
VERSION="${{ needs.detect-release-type.outputs.version }}"
curl -sL -o openboot-darwin-arm64 "https://github.com/openbootdotdev/openboot/releases/download/${VERSION}/openboot-darwin-arm64"
curl -sL -o openboot-darwin-amd64 "https://github.com/openbootdotdev/openboot/releases/download/${VERSION}/openboot-darwin-amd64"
echo "arm64=$(sha256sum openboot-darwin-arm64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "amd64=$(sha256sum openboot-darwin-amd64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: openbootdotdev/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
cat > homebrew-tap/Formula/openboot.rb << 'FORMULA'
class Openboot < Formula
desc "Set up your macOS dev environment in one command"
homepage "https://openboot.dev"
version "VERSION_PLACEHOLDER"
license "MIT"
depends_on :macos
if Hardware::CPU.arm?
url "https://github.com/openbootdotdev/openboot/releases/download/vVERSION_PLACEHOLDER/openboot-darwin-arm64"
sha256 "ARM64_SHA_PLACEHOLDER"
else
url "https://github.com/openbootdotdev/openboot/releases/download/vVERSION_PLACEHOLDER/openboot-darwin-amd64"
sha256 "AMD64_SHA_PLACEHOLDER"
end
def install
if Hardware::CPU.arm?
bin.install "openboot-darwin-arm64" => "openboot"
else
bin.install "openboot-darwin-amd64" => "openboot"
end
end
test do
assert_match version.to_s, shell_output("#{bin}/openboot version")
end
end
FORMULA
sed -i 's/VERSION_PLACEHOLDER/${{ needs.detect-release-type.outputs.version_clean }}/g' homebrew-tap/Formula/openboot.rb
sed -i 's/ARM64_SHA_PLACEHOLDER/${{ steps.sha.outputs.arm64 }}/g' homebrew-tap/Formula/openboot.rb
sed -i 's/AMD64_SHA_PLACEHOLDER/${{ steps.sha.outputs.amd64 }}/g' homebrew-tap/Formula/openboot.rb
sed -i 's/^ //' homebrew-tap/Formula/openboot.rb
- 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/openboot.rb
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "chore: bump openboot to ${{ needs.detect-release-type.outputs.version_clean }}"
git push