Skip to content

Commit 58790b9

Browse files
committed
Static(ish) build in Windows and MacOs + darwin/amd64 build
1 parent 38039b8 commit 58790b9

2 files changed

Lines changed: 85 additions & 31 deletions

File tree

.github/workflows/main.yml

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
env:
99
GO_VERSION: "1.23.5"
10-
REGISTRY_IMAGE: "ghcr.io/proofrock/ws4sql"
10+
REGISTRY_IMAGE: "ghcr.io/proofrock/ws4sql_test"
1111

1212
jobs:
1313
test:
@@ -46,7 +46,7 @@ jobs:
4646
- name: Compile and Pack Artifact
4747
run: |
4848
apk add --no-cache musl-dev go g++ git make openssl openssl-dev openssl-libs-static zstd
49-
make build-static-linux-musl-amd64
49+
make build-static-ci-linux-musl-amd64
5050
tar czf bin/ws4sql-${{ github.ref_name }}-linux-amd64.tar.gz -C bin/ ws4sql
5151
shell: alpine.sh --root {0}
5252

@@ -80,7 +80,7 @@ jobs:
8080
- name: Compile and Pack Artifact
8181
run: |
8282
apk add --no-cache musl-dev go g++ git make openssl openssl-dev openssl-libs-static zstd
83-
make build-static-linux-musl-arm64
83+
make build-static-ci-linux-musl-arm64
8484
tar czf bin/ws4sql-${{ github.ref_name }}-linux-arm64.tar.gz -C bin/ ws4sql
8585
shell: alpine.sh --root {0}
8686

@@ -111,7 +111,7 @@ jobs:
111111

112112
- name: Compile and Pack Artifact
113113
run: |
114-
make build
114+
make build-static-macos
115115
tar czf bin/ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz -C bin/ ws4sql
116116
rm bin/ws4sql
117117
@@ -122,6 +122,37 @@ jobs:
122122
path: bin/ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz
123123
retention-days: 1
124124

125+
build_macos_amd64:
126+
runs-on: macos-13
127+
128+
steps:
129+
- name: Checkout
130+
uses: actions/checkout@v4
131+
132+
- uses: actions/setup-go@v5
133+
with:
134+
go-version: ${{ env.GO_VERSION }}
135+
136+
- name: Modify version number
137+
run: sed -i.bkp 's/v0\.0\.0/${{ github.ref_name }}/g' ws4sql.go
138+
working-directory: src/
139+
140+
- name: Build dir generation
141+
run: mkdir bin/
142+
143+
- name: Compile and Pack Artifact
144+
run: |
145+
make build-static-macos
146+
tar czf bin/ws4sql-${{ github.ref_name }}-macos-amd64.tar.gz -C bin/ ws4sql
147+
rm bin/ws4sql
148+
149+
- name: Upload artifacts
150+
uses: actions/upload-artifact@v4
151+
with:
152+
name: binary_macos_amd64
153+
path: bin/ws4sql-${{ github.ref_name }}-macos-amd64.tar.gz
154+
retention-days: 1
155+
125156
build_win_amd64:
126157
runs-on: windows-latest
127158

@@ -145,7 +176,7 @@ jobs:
145176

146177
- name: Compile and Pack Artifact
147178
run: |
148-
make build-windows
179+
make build-static-windows
149180
zip -j -9 bin/ws4sql-${{ github.ref_name }}-win-amd64.zip bin/ws4sql.exe
150181
rm bin/ws4sql.exe
151182
@@ -236,31 +267,38 @@ jobs:
236267
- build_linux_amd64
237268
- build_linux_arm64
238269
- build_macos_arm64
270+
- build_macos_amd64
239271
- build_win_amd64
240272
- build_docker
241273
- test
242274
runs-on: ubuntu-latest
243275

244276
steps:
245-
- name: Download artifacts [1/4]
277+
- name: Download artifacts [1/5]
246278
uses: actions/download-artifact@v4
247279
with:
248280
name: binary_linux_amd64
249281
path: bin/
250282

251-
- name: Download artifacts [2/4]
283+
- name: Download artifacts [2/5]
252284
uses: actions/download-artifact@v4
253285
with:
254286
name: binary_linux_arm64
255287
path: bin/
256288

257-
- name: Download artifacts [3/4]
289+
- name: Download artifacts [3/5]
258290
uses: actions/download-artifact@v4
259291
with:
260292
name: binary_macos_arm64
261293
path: bin/
262294

263-
- name: Download artifacts [4/4]
295+
- name: Download artifacts [4/5]
296+
uses: actions/download-artifact@v4
297+
with:
298+
name: binary_macos_amd64
299+
path: bin/
300+
301+
- name: Download artifacts [5/5]
264302
uses: actions/download-artifact@v4
265303
with:
266304
name: binary_win_amd64
@@ -311,6 +349,16 @@ jobs:
311349
asset_name: ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz
312350
asset_content_type: application/zip
313351

352+
- name: Release Artifact [darwin/amd64]
353+
uses: actions/upload-release-asset@v1
354+
env:
355+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
356+
with:
357+
upload_url: ${{ steps.create_release.outputs.upload_url }}
358+
asset_path: bin/ws4sql-${{ github.ref_name }}-macos-amd64.tar.gz
359+
asset_name: ws4sql-${{ github.ref_name }}-macos-amd64.tar.gz
360+
asset_content_type: application/zip
361+
314362
- name: Release Artifact [windows/amd64]
315363
uses: actions/upload-release-asset@v1
316364
env:

Makefile

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
.PHONY: test
22

3-
build-prepare:
4-
make cleanup
5-
mkdir bin
6-
73
cleanup:
84
- rm -r bin
95
- rm src/ws4sql
@@ -12,39 +8,49 @@ cleanup:
128
upd-libraries:
139
cd src; go get -u
1410
cd src; go mod tidy
11+
12+
test:
13+
cd src; go test -v -timeout 6m
1514

16-
build:
15+
build-prepare:
16+
make cleanup
17+
mkdir bin
18+
19+
build-nostatic:
1720
make build-prepare
1821
cd src; go build -trimpath
1922
mv src/ws4sql bin/
2023

21-
build-windows:
24+
build-static-linux:
2225
make build-prepare
23-
cd src; go build -trimpath
24-
mv src/ws4sql.exe bin/
26+
cd src; go build -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension" -ldflags='-w -extldflags "-static"'
27+
mv src/ws4sql bin/
2528

26-
build-static:
29+
build-static-windows:
2730
make build-prepare
2831
cd src; go build -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension" -ldflags='-w -extldflags "-static"'
29-
mv src/ws4sql bin/
32+
mv src/ws4sql.exe bin/
3033

31-
build-static-linux-musl-amd64:
32-
# In an Alpine Linux context with the following packages
33-
# musl-dev go g++ make openssl openssl-dev openssl-libs-static zstd
34+
build-static-macos:
3435
make build-prepare
35-
cp precompiled/libduckdb_bundle/linux-musl-amd64/libduckdb_bundle.a.zst src/
36-
cd src && zstd -d libduckdb_bundle.a.zst
37-
cd src && CGO_CFLAGS="-O2 -fPIC" CGO_CXXFLAGS="-O2 -fPIC" CGO_LDFLAGS="-lduckdb_bundle -lssl -lcrypto -L./" go build -buildvcs=false -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension duckdb_use_static_lib" -ldflags='-w -extldflags "-static"'
36+
cd src; go build -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension" -ldflags='-w'
3837
mv src/ws4sql bin/
3938

40-
build-static-linux-musl-arm64:
41-
# In an Alpine Linux context with the following packages
42-
# musl-dev go g++ make openssl openssl-dev openssl-libs-static zstd
39+
# The following three targets are used in Github Actions
40+
# Can be also run in an Alpine Linux context with the following packages
41+
# musl-dev go g++ make openssl openssl-dev openssl-libs-static zstd
42+
43+
build-static-ci-common:
4344
make build-prepare
44-
cp precompiled/libduckdb_bundle/linux-musl-arm64/libduckdb_bundle.a.zst src/
4545
cd src && zstd -d libduckdb_bundle.a.zst
4646
cd src && CGO_CFLAGS="-O2 -fPIC" CGO_CXXFLAGS="-O2 -fPIC" CGO_LDFLAGS="-lduckdb_bundle -lssl -lcrypto -L./" go build -buildvcs=false -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension duckdb_use_static_lib" -ldflags='-w -extldflags "-static"'
4747
mv src/ws4sql bin/
48+
rm src/libduckdb_bundle.a
4849

49-
test:
50-
cd src; go test -v -timeout 6m
50+
build-static-ci-linux-musl-amd64:
51+
cp precompiled/libduckdb_bundle/linux-musl-amd64/libduckdb_bundle.a.zst src/
52+
make build-static-ci-common
53+
54+
build-static-ci-linux-musl-arm64:
55+
cp precompiled/libduckdb_bundle/linux-musl-arm64/libduckdb_bundle.a.zst src/
56+
make build-static-ci-common

0 commit comments

Comments
 (0)