Skip to content

Commit 154a209

Browse files
committed
feat: add Windows build support to release workflow
1 parent a55e221 commit 154a209

1 file changed

Lines changed: 50 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,43 @@ jobs:
7575
name: statping-linux-amd64
7676
path: statping-linux-amd64
7777

78+
build-windows:
79+
name: Build Windows
80+
runs-on: windows-latest
81+
strategy:
82+
matrix:
83+
include:
84+
- goarch: amd64
85+
suffix: windows-amd64
86+
- goarch: arm64
87+
suffix: windows-arm64
88+
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
93+
- name: Set up Go
94+
uses: actions/setup-go@v5
95+
with:
96+
go-version: '1.21'
97+
98+
- name: Build
99+
env:
100+
GOOS: windows
101+
GOARCH: ${{ matrix.goarch }}
102+
CGO_ENABLED: 1
103+
run: |
104+
go build -ldflags="-s -w -H windowsgui" -o statping-${{ matrix.suffix }}.exe ./cmd/statping
105+
106+
- name: Upload artifact
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: statping-${{ matrix.suffix }}
110+
path: statping-${{ matrix.suffix }}.exe
111+
78112
release:
79113
name: Create Release
80-
needs: [build-macos, build-linux]
114+
needs: [build-macos, build-linux, build-windows]
81115
runs-on: ubuntu-latest
82116
steps:
83117
- name: Checkout code
@@ -95,15 +129,26 @@ jobs:
95129
cp "$dir"* ./release/ 2>/dev/null || true
96130
done
97131
cd release
98-
for f in statping-*; do
99-
chmod +x "$f"
100-
tar -czvf "${f}.tar.gz" "$f"
132+
# Compress Unix binaries
133+
for f in statping-darwin-* statping-linux-*; do
134+
if [ -f "$f" ]; then
135+
chmod +x "$f"
136+
tar -czvf "${f}.tar.gz" "$f"
137+
fi
138+
done
139+
# Compress Windows binaries
140+
for f in statping-windows-*.exe; do
141+
if [ -f "$f" ]; then
142+
zip "${f%.exe}.zip" "$f"
143+
fi
101144
done
102145
103146
- name: Create Release
104147
uses: softprops/action-gh-release@v1
105148
with:
106-
files: release/*.tar.gz
149+
files: |
150+
release/*.tar.gz
151+
release/*.zip
107152
generate_release_notes: true
108153
draft: false
109154
prerelease: false

0 commit comments

Comments
 (0)