Skip to content

Commit fffeda4

Browse files
Refactor GitHub Actions workflow to build and upload CLI binaries for Linux, Windows, and macOS, enhancing cross-platform compatibility and simplifying binary selection during tests.
1 parent b63a710 commit fffeda4

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

.github/workflows/go.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ jobs:
1111
uses: actions/checkout@v4
1212
- name: Set up Go
1313
uses: actions/setup-go@v4
14-
- name: Build CLI
14+
- name: Build CLI for Linux
1515
run: |
16-
go build ./cli-v2.go
17-
- name: Upload CLI binary
16+
GOOS=linux GOARCH=amd64 go build -o cli-v2-linux ./cli-v2.go
17+
- name: Build CLI for Windows
18+
run: |
19+
GOOS=windows GOARCH=amd64 go build -o cli-v2.exe ./cli-v2.go
20+
- name: Build CLI for macOS
21+
run: |
22+
GOOS=darwin GOARCH=amd64 go build -o cli-v2-macos ./cli-v2.go
23+
- name: Upload CLI binaries
1824
uses: actions/upload-artifact@v4
1925
with:
20-
name: cli-binary
21-
path: cli-v2
26+
name: cli-binaries
27+
path: |
28+
cli-v2-linux
29+
cli-v2.exe
30+
cli-v2-macos
2231
2332
test:
2433
needs: build
@@ -31,11 +40,20 @@ jobs:
3140
uses: actions/checkout@v4
3241
- name: Set up Go
3342
uses: actions/setup-go@v4
34-
- name: Download CLI binary
43+
- name: Download CLI binaries
3544
uses: actions/download-artifact@v4
3645
with:
37-
name: cli-binary
46+
name: cli-binaries
3847
path: .
48+
- name: Select correct binary
49+
run: |
50+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
51+
mv cli-v2.exe cli-v2
52+
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
53+
mv cli-v2-macos cli-v2
54+
else
55+
mv cli-v2-linux cli-v2
56+
fi
3957
- name: Make binary executable
4058
if: matrix.os != 'windows-latest'
4159
run: chmod +x cli-v2

0 commit comments

Comments
 (0)