Skip to content

Commit 93cfa61

Browse files
MagicalTuxclaude
andcommitted
add github actions workflow for multi-platform builds
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e3af4e8 commit 93cfa61

1 file changed

Lines changed: 194 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
env:
10+
GO_VERSION: '1.23'
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
24+
25+
- name: Install Linux dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y \
29+
libgl1-mesa-dev \
30+
libxcursor-dev \
31+
libxrandr-dev \
32+
libxinerama-dev \
33+
libxi-dev \
34+
libxxf86vm-dev \
35+
libasound2-dev \
36+
pkg-config
37+
38+
- name: Add static library replacements
39+
run: |
40+
go mod edit -replace github.com/gordonklaus/portaudio=github.com/KarpelesLab/static-portaudio@v0.6.190600
41+
go mod edit -replace github.com/hraban/opus=github.com/KarpelesLab/static-opus@v0.5.131
42+
43+
- name: Run tests
44+
run: go test -v ./...
45+
46+
build-linux:
47+
name: Build Linux
48+
runs-on: ubuntu-latest
49+
needs: test
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- name: Set up Go
55+
uses: actions/setup-go@v5
56+
with:
57+
go-version: ${{ env.GO_VERSION }}
58+
59+
- name: Install Linux dependencies
60+
run: |
61+
sudo apt-get update
62+
sudo apt-get install -y \
63+
libgl1-mesa-dev \
64+
libxcursor-dev \
65+
libxrandr-dev \
66+
libxinerama-dev \
67+
libxi-dev \
68+
libxxf86vm-dev \
69+
libasound2-dev \
70+
pkg-config
71+
72+
- name: Add static library replacements
73+
run: |
74+
go mod edit -replace github.com/gordonklaus/portaudio=github.com/KarpelesLab/static-portaudio@v0.6.190600
75+
go mod edit -replace github.com/hraban/opus=github.com/KarpelesLab/static-opus@v0.5.131
76+
77+
- name: Build
78+
run: |
79+
CGO_ENABLED=1 go build -v -ldflags="-s -w" -o shells-go-linux-amd64 .
80+
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: shells-go-linux-amd64
85+
path: shells-go-linux-amd64
86+
87+
build-windows:
88+
name: Build Windows
89+
runs-on: windows-latest
90+
needs: test
91+
defaults:
92+
run:
93+
shell: msys2 {0}
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
98+
- name: Setup MSYS2
99+
uses: msys2/setup-msys2@v2
100+
with:
101+
msystem: MINGW64
102+
update: true
103+
install: >-
104+
mingw-w64-x86_64-gcc
105+
mingw-w64-x86_64-go
106+
mingw-w64-x86_64-pkg-config
107+
108+
- name: Add static library replacements
109+
run: |
110+
go mod edit -replace github.com/gordonklaus/portaudio=github.com/KarpelesLab/static-portaudio@v0.6.190600
111+
go mod edit -replace github.com/hraban/opus=github.com/KarpelesLab/static-opus@v0.5.131
112+
113+
- name: Build
114+
run: |
115+
export CGO_ENABLED=1
116+
go build -v -ldflags="-s -w" -o shells-go-windows-amd64.exe .
117+
118+
- name: Upload artifact
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: shells-go-windows-amd64
122+
path: shells-go-windows-amd64.exe
123+
124+
build-macos-intel:
125+
name: Build macOS Intel
126+
runs-on: macos-15-intel
127+
needs: test
128+
steps:
129+
- name: Checkout code
130+
uses: actions/checkout@v4
131+
132+
- name: Set up Go
133+
uses: actions/setup-go@v5
134+
with:
135+
go-version: ${{ env.GO_VERSION }}
136+
137+
- name: Add static library replacements
138+
run: |
139+
go mod edit -replace github.com/gordonklaus/portaudio=github.com/KarpelesLab/static-portaudio@v0.6.190600
140+
go mod edit -replace github.com/hraban/opus=github.com/KarpelesLab/static-opus@v0.5.131
141+
142+
- name: Build
143+
run: |
144+
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v -ldflags="-s -w" -o shells-go-darwin-amd64 .
145+
146+
- name: Upload artifact
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: shells-go-darwin-amd64
150+
path: shells-go-darwin-amd64
151+
152+
build-macos-arm:
153+
name: Build macOS ARM + Universal Binary
154+
runs-on: macos-latest
155+
needs: [test, build-macos-intel]
156+
steps:
157+
- name: Checkout code
158+
uses: actions/checkout@v4
159+
160+
- name: Set up Go
161+
uses: actions/setup-go@v5
162+
with:
163+
go-version: ${{ env.GO_VERSION }}
164+
165+
- name: Add static library replacements
166+
run: |
167+
go mod edit -replace github.com/gordonklaus/portaudio=github.com/KarpelesLab/static-portaudio@v0.6.190600
168+
go mod edit -replace github.com/hraban/opus=github.com/KarpelesLab/static-opus@v0.5.131
169+
170+
- name: Build ARM64
171+
run: |
172+
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -v -ldflags="-s -w" -o shells-go-darwin-arm64 .
173+
174+
- name: Download Intel binary
175+
uses: actions/download-artifact@v4
176+
with:
177+
name: shells-go-darwin-amd64
178+
179+
- name: Create Universal Binary
180+
run: |
181+
lipo -create -output shells-go-darwin-universal shells-go-darwin-amd64 shells-go-darwin-arm64
182+
file shells-go-darwin-universal
183+
184+
- name: Upload ARM64 artifact
185+
uses: actions/upload-artifact@v4
186+
with:
187+
name: shells-go-darwin-arm64
188+
path: shells-go-darwin-arm64
189+
190+
- name: Upload Universal Binary artifact
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: shells-go-darwin-universal
194+
path: shells-go-darwin-universal

0 commit comments

Comments
 (0)