-
Notifications
You must be signed in to change notification settings - Fork 1
371 lines (319 loc) · 13.3 KB
/
Copy pathci.yml
File metadata and controls
371 lines (319 loc) · 13.3 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read
jobs:
quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version-file: 'go.mod'
cache-dependency-path: go.sum
- name: Install gofumpt
run: go install mvdan.cc/gofumpt@v0.7.0
- name: Check formatting (gofumpt)
run: |
UNFORMATTED=$(gofumpt -l .)
if [ -n "$UNFORMATTED" ]; then
echo "::error::Files need formatting with gofumpt:"
echo "$UNFORMATTED"
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run golangci-lint
uses: step-security/golangci-lint-action@ce3368d2f0a15c79206a120861e3f847c8beb466 # v9.2.1
with:
version: v2.10.1
- name: Run tests with race detector
run: go test ./... -v -count=1 -race -coverprofile=coverage.out -covermode=atomic
- name: Display coverage summary
run: go tool cover -func=coverage.out
- name: Validate build
run: go build -o /dev/null ./cmd/sideshow
build-binaries:
name: Build Binaries
needs: quality-gate
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version-file: 'go.mod'
cache-dependency-path: go.sum
- name: Generate version
id: version
run: |
VERSION="0.1.0-alpha.$(date -u +%Y%m%d).$(date -u +%H%M%S).${GITHUB_SHA::7}"
TAG="alpha-$(date -u +%Y%m%d)-$(date -u +%H%M%S)-${GITHUB_SHA::7}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Build alpha binaries
run: |
LDFLAGS="-X main.version=${{ steps.version.outputs.version }} -X main.channel=alpha"
GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o sideshow-darwin-arm64 ./cmd/sideshow
GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o sideshow-darwin-amd64 ./cmd/sideshow
GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o sideshow-linux-amd64 ./cmd/sideshow
- name: Upload binaries
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: binaries
path: sideshow-*
retention-days: 14
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
sign-and-notarize:
name: Sign & Notarize
needs: build-binaries
if: github.event_name == 'push' && vars.SIGNING_ENABLED == 'true'
environment: release
runs-on: macos-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: binaries
- name: Import certificates
env:
APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
security create-keychain -p "" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "" build.keychain
echo "$APPLE_CERTIFICATE_P12" | base64 --decode > cert.p12
security import cert.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
rm cert.p12
curl -sfo /tmp/DeveloperIDG2CA.cer https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
security add-certificates -k build.keychain /tmp/DeveloperIDG2CA.cer
rm /tmp/DeveloperIDG2CA.cer
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
- name: Sign darwin binaries
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
run: |
codesign --force --options runtime --sign "$APPLE_SIGNING_IDENTITY" --identifier "com.arcavenae.sideshow" --timestamp sideshow-darwin-arm64
codesign --force --options runtime --sign "$APPLE_SIGNING_IDENTITY" --identifier "com.arcavenae.sideshow" --timestamp sideshow-darwin-amd64
- name: Verify signatures
run: |
codesign --verify --deep --strict sideshow-darwin-arm64
codesign --verify --deep --strict sideshow-darwin-amd64
- name: Upload signed binaries
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: signed-binaries
path: |
sideshow-darwin-arm64
sideshow-darwin-amd64
retention-days: 14
- name: Cleanup keychain
if: always()
run: security delete-keychain build.keychain || true
release:
name: Create Release
needs: [build-binaries, sign-and-notarize]
if: github.event_name == 'push' && !cancelled() && needs.build-binaries.result == 'success'
permissions:
contents: write
environment: release
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
persist-credentials: false
- name: Download signed binaries
if: needs.sign-and-notarize.result == 'success'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: signed-binaries
- name: Download unsigned binaries (fallback)
if: needs.sign-and-notarize.result != 'success'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: binaries
- name: Download all binaries (for linux)
if: needs.sign-and-notarize.result == 'success'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: binaries
path: unsigned-binaries
- name: Copy linux binary from unsigned artifacts
if: needs.sign-and-notarize.result == 'success'
run: |
cp unsigned-binaries/sideshow-linux-amd64 .
rm -rf unsigned-binaries
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.build-binaries.outputs.tag }}
VERSION: ${{ needs.build-binaries.outputs.version }}
COMMIT: ${{ github.sha }}
SIGNED: ${{ needs.sign-and-notarize.result == 'success' && 'Yes (Apple Developer ID)' || 'No (unsigned)' }}
run: |
BODY="Automated alpha release from push to main.
**Version:** ${VERSION}
**Commit:** ${COMMIT}
**Signed:** ${SIGNED}
**Binaries:**
- \`sideshow-darwin-arm64\` — macOS Apple Silicon
- \`sideshow-darwin-amd64\` — macOS Intel
- \`sideshow-linux-amd64\` — Linux x86_64
**Homebrew (alpha):** \`brew install arcavenae/tap/sideshow\`"
ASSETS=()
for f in sideshow-*; do
[ -f "$f" ] && ASSETS+=("$f")
done
gh release create "$TAG" \
--title "Alpha ${TAG}" \
--notes "$BODY" \
--prerelease \
"${ASSETS[@]}"
- name: Update Homebrew formula
if: vars.ALPHA_TAP_ENABLED == 'true'
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION="${{ needs.build-binaries.outputs.version }}"
TAG="${{ needs.build-binaries.outputs.tag }}"
BASE_URL="https://github.com/arcavenae/sideshow/releases/download/${TAG}"
SHA_ARM64=$(sha256sum sideshow-darwin-arm64 | cut -d' ' -f1)
SHA_AMD64=$(sha256sum sideshow-darwin-amd64 | cut -d' ' -f1)
SHA_LINUX=$(sha256sum sideshow-linux-amd64 | cut -d' ' -f1)
cat > sideshow.rb <<FORMULA
class Sideshow < Formula
desc "Content pack manager for AI CLI tools"
homepage "https://github.com/arcavenae/sideshow"
version "${VERSION}"
license "MIT"
if OS.mac? && Hardware::CPU.arm?
url "${BASE_URL}/sideshow-darwin-arm64"
sha256 "${SHA_ARM64}"
elsif OS.mac?
url "${BASE_URL}/sideshow-darwin-amd64"
sha256 "${SHA_AMD64}"
elsif OS.linux?
url "${BASE_URL}/sideshow-linux-amd64"
sha256 "${SHA_LINUX}"
end
def install
if OS.mac? && Hardware::CPU.arm?
bin.install "sideshow-darwin-arm64" => "sideshow"
elsif OS.mac?
bin.install "sideshow-darwin-amd64" => "sideshow"
elsif OS.linux?
bin.install "sideshow-linux-amd64" => "sideshow"
end
end
test do
assert_match "sideshow", shell_output("#{bin}/sideshow version 2>&1")
end
end
FORMULA
sed -i 's/^ //' sideshow.rb
ruby -c sideshow.rb
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/arcavenae/homebrew-tap.git" tap-repo
mkdir -p tap-repo/Formula
cp sideshow.rb tap-repo/Formula/sideshow.rb
cd tap-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/sideshow.rb
if git diff --cached --quiet; then
echo "Formula unchanged, skipping push"
else
git commit -m "chore(formula): update sideshow to ${TAG}"
git push origin main
fi
- name: Clean up old alpha releases
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release list --limit 200 \
| grep 'alpha-' \
| tail -n +31 \
| awk '{print $1}' \
| xargs -I{} gh release delete {} --yes --cleanup-tag
attest:
name: Attest Release Provenance
needs: [build-binaries, sign-and-notarize, release]
# Run after release (which is the final asset-landing job) so
# attestations cover the FINAL bytes that ship — the signed binaries
# copied into the release, or unsigned fallbacks when SIGNING_ENABLED
# is not set. Tolerates skipped sign-and-notarize.
if: |
github.event_name == 'push' &&
!cancelled() &&
needs.release.result == 'success' &&
(needs.sign-and-notarize.result == 'success' || needs.sign-and-notarize.result == 'skipped')
permissions:
contents: write
id-token: write
attestations: write
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Download final release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.build-binaries.outputs.tag }}
run: |
mkdir -p release-assets
# Pull everything currently attached to the release; the release
# job has already uploaded final signed (or unsigned fallback)
# binaries by the time this job runs.
gh release download "$TAG" \
--repo "${{ github.repository }}" \
--dir release-assets
echo "Assets to be attested:"
ls -la release-assets/
- name: Attest release artifacts
id: attest
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: 'release-assets/*'
- name: Upload attestation bundle to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Publish the Sigstore bundle as a release asset so external
# scanners (e.g. OSSF Scorecard Signed-Releases) can see it; the
# GitHub attestation store is not visible to them.
cp "${{ steps.attest.outputs.bundle-path }}" attestations.sigstore.json
gh release upload "${{ needs.build-binaries.outputs.tag }}" attestations.sigstore.json \
--repo "${{ github.repository }}" --clobber