Skip to content

Commit b3d9b0a

Browse files
committed
chore: build release automatically
1 parent 699437c commit b3d9b0a

2 files changed

Lines changed: 74 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,41 @@ jobs:
109109
name: pgrollback-windows-amd64
110110
path: bin/pgrollback.exe
111111

112+
build-windows-cross:
113+
name: Build pgrollback (Windows cross-compile on Linux)
114+
runs-on: ubuntu-latest
115+
needs: test
116+
if: startsWith(github.ref, 'refs/tags/')
117+
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- name: Install mingw-w64 (Windows cross-compiler)
122+
run: sudo apt-get update -y && sudo apt-get install -y gcc-mingw-w64
123+
124+
- uses: actions/setup-go@v5
125+
with:
126+
go-version: '1.23'
127+
cache: true
128+
129+
- name: Install systray dependency (Linux)
130+
run: sudo apt-get update -y && sudo apt-get install -y libayatana-appindicator3-dev
131+
132+
- name: Build pgrollback.exe (cross, CGO)
133+
env:
134+
CGO_ENABLED: 1
135+
GOOS: windows
136+
GOARCH: amd64
137+
CC: x86_64-w64-mingw32-gcc
138+
run: |
139+
mkdir -p bin
140+
go build -o bin/pgrollback.exe ./cmd/pgrollback
141+
142+
- name: Upload binary artifact (cross)
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: pgrollback-windows-amd64-cross
146+
path: bin/pgrollback.exe
112147

113148
build:
114149
name: Build pgrollback binary
@@ -164,8 +199,13 @@ jobs:
164199
run: |
165200
TAG="${GITHUB_REF#refs/tags/}"
166201
mkdir -p release
167-
mv pgrollback-linux-amd64/bin/pgrollback "release/pgrollback-${TAG}-linux-amd64"
168-
mv pgrollback-windows-amd64/bin/pgrollback.exe "release/pgrollback-${TAG}-windows-amd64.exe"
202+
# Artifact may be at root or under bin/ depending on upload-artifact behavior
203+
LINUX_BIN=pgrollback-linux-amd64/pgrollback
204+
[ -f pgrollback-linux-amd64/bin/pgrollback ] && LINUX_BIN=pgrollback-linux-amd64/bin/pgrollback
205+
WIN_BIN=pgrollback-windows-amd64/pgrollback.exe
206+
[ -f pgrollback-windows-amd64/bin/pgrollback.exe ] && WIN_BIN=pgrollback-windows-amd64/bin/pgrollback.exe
207+
mv "$LINUX_BIN" "release/pgrollback-${TAG}-linux-amd64"
208+
mv "$WIN_BIN" "release/pgrollback-${TAG}-windows-amd64.exe"
169209
ls -la release/
170210
171211
- name: Create Release and upload assets

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Build
21+
run: |
22+
mkdir -p dist
23+
GOOS=linux GOARCH=amd64 go build -o dist/pgrollback-linux-amd64 ./...
24+
GOOS=windows GOARCH=amd64 go build -o dist/pgrollback-windows-amd64.exe ./...
25+
(cd dist && zip -r pgrollback-linux-amd64.zip pgrollback-linux-amd64)
26+
(cd dist && zip -r pgrollback-windows-amd64.zip pgrollback-windows-amd64.exe)
27+
28+
- name: Release
29+
uses: softprops/action-gh-release@v2
30+
with:
31+
files: |
32+
dist/*.zip

0 commit comments

Comments
 (0)