Skip to content

Commit 83a0a2e

Browse files
committed
ci: Try different runners even harder
1 parent 5e58bf2 commit 83a0a2e

File tree

2 files changed

+77
-19
lines changed

2 files changed

+77
-19
lines changed

.github/workflows/release.yaml

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,72 @@ on:
55
tags:
66
- "*"
77
workflow_dispatch: # Allow triggering manually.
8+
# ${{ secrets.GH_PAT }}
89

910
jobs:
10-
goreleaser:
11+
build:
12+
name: Build (${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
1114
strategy:
1215
matrix:
1316
os: [ubuntu-latest, macos-latest, windows-latest]
1417

15-
runs-on: ${{ matrix.os }}
16-
1718
steps:
1819
- name: Checkout
1920
uses: actions/checkout@v5
2021

21-
- name: Set up Go
22+
- name: Setup Go
2223
uses: actions/setup-go@v5
2324
with:
24-
go-version: 1.24
25+
go-version: "1.24"
2526

26-
- name: Install dependencies (Linux)
27-
if: runner.os == 'Linux'
28-
run: sudo apt-get install -y build-essential
27+
# --- Install CGO deps per OS ---
28+
- name: Setup Linux build environment
29+
if: startsWith(matrix.os, 'ubuntu')
30+
run: sudo apt-get update && sudo apt-get install -y build-essential
2931

30-
- name: Install dependencies (macOS)
31-
if: runner.os == 'macOS'
32+
- name: Setup macOS build environment
33+
if: startsWith(matrix.os, 'macos')
3234
run: brew install gcc
3335

34-
- name: Install dependencies (Windows)
35-
if: runner.os == 'Windows'
36-
run: choco install mingw
36+
- name: Setup Windows build environment
37+
if: startsWith(matrix.os, 'windows')
38+
run: |
39+
choco install mingw
40+
echo "Path=C:/tools/mingw64/bin;$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Append
3741
38-
- name: Run GoReleaser
42+
- name: Set build ID
43+
id: buildid
44+
run: |
45+
case "${{ runner.os }}" in
46+
macOS)
47+
echo "id=darwin-build" >> $GITHUB_OUTPUT
48+
;;
49+
Windows)
50+
echo "id=windows-build" >> $GITHUB_OUTPUT
51+
;;
52+
Linux)
53+
echo "id=linux-build" >> $GITHUB_OUTPUT
54+
;;
55+
*)
56+
echo "id=unknown-runner-os-${{ runner.os }}" >> $GITHUB_OUTPUT
57+
;;
58+
esac
59+
shell: bash
60+
61+
- name: Build with GoReleaser
3962
uses: goreleaser/goreleaser-action@v6
4063
with:
64+
distribution: goreleaser
4165
version: latest
42-
args: release --clean
66+
args: release --clean --id ${{ steps.buildid.outputs.id }} --skip-publish
4367
env:
44-
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
45-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Upload artifacts
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: artifacts-${{ matrix.os }}
74+
path: |
75+
dist/*
76+
if-no-files-found: error

.goreleaser.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,45 @@ before:
55
- go mod download
66

77
builds:
8-
- env:
8+
# Linux
9+
- id: linux-build
10+
main: ./cmd/myapp
11+
env:
912
- CGO_ENABLED=1
1013
goos:
1114
- linux
15+
goarch:
16+
- amd64
17+
- arm64
18+
19+
# macOS
20+
- id: darwin-build
21+
main: ./cmd/myapp
22+
env:
23+
- CGO_ENABLED=1
24+
goos:
1225
- darwin
26+
goarch:
27+
- amd64
28+
- arm64
29+
30+
# Windows
31+
- id: windows-build
32+
main: ./cmd/myapp
33+
env:
34+
- CGO_ENABLED=1
35+
goos:
1336
- windows
1437
goarch:
1538
- amd64
1639
- arm64
1740

1841
archives:
19-
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
42+
- builds:
43+
- linux-build
44+
- darwin-build
45+
- windows-build
46+
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
2047
format_overrides:
2148
- goos: windows
2249
formats:

0 commit comments

Comments
 (0)