Skip to content

Commit 5c0b1ad

Browse files
authored
ci(release): integrate Windows ABE payload into goreleaser (#590)
1 parent 15680c1 commit 5c0b1ad

2 files changed

Lines changed: 90 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
mode:
7+
description: 'Run mode'
8+
type: choice
9+
options:
10+
- snapshot
11+
- release
12+
default: snapshot
13+
tag:
14+
description: 'Release tag (required for release mode, e.g., v0.5.0)'
15+
required: false
16+
type: string
17+
draft:
18+
description: 'Publish as draft (release mode only)'
19+
required: false
20+
type: boolean
21+
default: true
522

623
permissions:
724
contents: write
@@ -10,6 +27,12 @@ jobs:
1027
goreleaser:
1128
runs-on: ubuntu-latest
1229
steps:
30+
- name: Validate inputs
31+
if: inputs.mode == 'release' && inputs.tag == ''
32+
run: |
33+
echo "::error::tag is required when mode=release"
34+
exit 1
35+
1336
- name: Check out code
1437
uses: actions/checkout@v6
1538
with:
@@ -20,11 +43,54 @@ jobs:
2043
with:
2144
go-version-file: go.mod
2245

23-
- name: Run GoReleaser
46+
- name: Set up Zig
47+
uses: mlugg/setup-zig@v2
48+
with:
49+
version: 0.16.0
50+
51+
- name: Build ABE payload
52+
run: make payload
53+
54+
- name: Create and push tag
55+
if: inputs.mode == 'release'
56+
env:
57+
TAG: ${{ inputs.tag }}
58+
run: |
59+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null 2>&1; then
60+
echo "::error::Tag '$TAG' already exists locally"
61+
exit 1
62+
fi
63+
if git ls-remote --tags --exit-code origin "refs/tags/$TAG" >/dev/null 2>&1; then
64+
echo "::error::Tag '$TAG' already exists on origin"
65+
exit 1
66+
fi
67+
git tag -- "$TAG"
68+
git push origin -- "$TAG"
69+
70+
- name: Run GoReleaser (snapshot)
71+
if: inputs.mode == 'snapshot'
2472
uses: goreleaser/goreleaser-action@v7
2573
with:
2674
version: '~> v2'
27-
args: release --clean --draft
75+
args: release --snapshot --clean
2876
env:
2977
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3078
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
79+
80+
- name: Run GoReleaser (release)
81+
if: inputs.mode == 'release'
82+
uses: goreleaser/goreleaser-action@v7
83+
with:
84+
version: '~> v2'
85+
args: release --clean ${{ inputs.draft && '--draft' || '' }}
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
89+
90+
- name: Upload snapshot artifacts
91+
if: inputs.mode == 'snapshot'
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: snapshot-dist
95+
path: dist/
96+
retention-days: 7

.goreleaser.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ before:
55
- go mod tidy
66

77
builds:
8+
- id: "hack-browser-data-windows-amd64"
9+
main: ./cmd/hack-browser-data/
10+
binary: hack-browser-data
11+
env:
12+
- CGO_ENABLED=0
13+
goos: [windows]
14+
goarch: [amd64]
15+
tags:
16+
- abe_embed
17+
flags:
18+
- -trimpath
19+
ldflags:
20+
- -s -w
21+
- -X main.version={{.Version}}
22+
- -X main.commit={{.ShortCommit}}
23+
- -X main.buildDate={{.Date}}
24+
825
- id: "hack-browser-data"
926
main: ./cmd/hack-browser-data/
1027
binary: hack-browser-data
@@ -15,6 +32,8 @@ builds:
1532
ignore:
1633
- goos: darwin
1734
goarch: "386"
35+
- goos: windows
36+
goarch: amd64
1837
- goos: windows
1938
goarch: "386"
2039
- goos: windows
@@ -29,6 +48,9 @@ builds:
2948

3049
archives:
3150
- id: "archive"
51+
ids:
52+
- hack-browser-data-windows-amd64
53+
- hack-browser-data
3254
formats:
3355
- tar.gz
3456
format_overrides:

0 commit comments

Comments
 (0)