Skip to content

Commit 61fd142

Browse files
committed
Merged fork/feature/ci branch
1 parent 5b9f89a commit 61fd142

9 files changed

Lines changed: 328 additions & 38 deletions

File tree

.github/workflows/main.yml

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
name: "Build & Release CI Pipeline"
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
GO_VERSION: "1.23.4"
10+
REGISTRY_IMAGE: "ghcr.io/proofrock/ws4sql"
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
23+
24+
- name: Test
25+
run: make test
26+
27+
build_linux_amd64:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- uses: actions/setup-go@v5
35+
with:
36+
go-version: ${{ env.GO_VERSION }}
37+
38+
- name: Modify version number
39+
run: sed -i 's/v0\.0\.0/${{ github.ref_name }}/g' ws4sql.go
40+
working-directory: src/
41+
42+
- name: Build dir generation
43+
run: mkdir bin/
44+
45+
- name: Compile and Pack Artifact
46+
run: |
47+
make build-static
48+
tar czf bin/ws4sql-${{ github.ref_name }}-linux-amd64.tar.gz -C bin/ ws4sql
49+
rm bin/ws4sql
50+
51+
- name: Upload artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: binary_linux_amd64
55+
path: bin/ws4sql-${{ github.ref_name }}-linux-amd64.tar.gz
56+
retention-days: 1
57+
58+
# TODO build_linux_arm64
59+
60+
build_macos_arm64:
61+
runs-on: macos-latest
62+
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
67+
- uses: actions/setup-go@v5
68+
with:
69+
go-version: ${{ env.GO_VERSION }}
70+
71+
- name: Modify version number
72+
run: sed -i.bkp 's/v0\.0\.0/${{ github.ref_name }}/g' ws4sql.go
73+
working-directory: src/
74+
75+
- name: Build dir generation
76+
run: mkdir bin/
77+
78+
- name: Compile and Pack Artifact
79+
run: |
80+
make build
81+
tar czf bin/ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz -C bin/ ws4sql
82+
rm bin/ws4sql
83+
84+
- name: Upload artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: binary_macos_arm64
88+
path: bin/ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz
89+
retention-days: 1
90+
91+
build_win_amd64:
92+
runs-on: windows-latest
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v4
97+
98+
- uses: actions/setup-go@v5
99+
with:
100+
go-version: ${{ env.GO_VERSION }}
101+
102+
- name: Modify version number
103+
run: sed -i 's/v0\.0\.0/${{ github.ref_name }}/g' ws4sql.go
104+
working-directory: src/
105+
106+
- name: Build dir generation
107+
run: mkdir bin/
108+
109+
- name: Install zip
110+
run: choco install zip -y
111+
112+
- name: Compile and Pack Artifact
113+
run: |
114+
make build-windows
115+
zip -j -9 bin/ws4sql-${{ github.ref_name }}-win-amd64.zip bin/ws4sql.exe
116+
rm bin/ws4sql.exe
117+
118+
- name: Upload artifacts
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: binary_win_amd64
122+
path: bin/ws4sql-${{ github.ref_name }}-win-amd64.zip
123+
retention-days: 1
124+
125+
release:
126+
needs:
127+
- build_linux_amd64
128+
- build_macos_arm64
129+
- build_win_amd64
130+
- test
131+
runs-on: ubuntu-latest
132+
133+
steps:
134+
- name: Download artifacts [1/3]
135+
uses: actions/download-artifact@v4
136+
with:
137+
name: binary_linux_amd64
138+
path: bin/
139+
140+
- name: Download artifacts [2/3]
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: binary_macos_arm64
144+
path: bin/
145+
146+
- name: Download artifacts [3/3]
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: binary_win_amd64
150+
path: bin/
151+
152+
- name: Verify Artifact Creation
153+
run: ls -lh bin/
154+
155+
- name: Create Draft Release
156+
id: create_release
157+
uses: actions/create-release@v1
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
160+
with:
161+
body: _replace_me_
162+
tag_name: ${{ github.ref_name }}
163+
release_name: Version ${{ github.ref_name }}
164+
draft: true
165+
prerelease: false
166+
167+
- name: Release Artifact [linux/amd64]
168+
uses: actions/upload-release-asset@v1
169+
env:
170+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
171+
with:
172+
upload_url: ${{ steps.create_release.outputs.upload_url }}
173+
asset_path: bin/ws4sql-${{ github.ref_name }}-linux-amd64.tar.gz
174+
asset_name: ws4sql-${{ github.ref_name }}-linux-amd64.tar.gz
175+
asset_content_type: application/gzip
176+
177+
- name: Release Artifact [darwin/arm64]
178+
uses: actions/upload-release-asset@v1
179+
env:
180+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
181+
with:
182+
upload_url: ${{ steps.create_release.outputs.upload_url }}
183+
asset_path: bin/ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz
184+
asset_name: ws4sql-${{ github.ref_name }}-macos-arm64.tar.gz
185+
asset_content_type: application/zip
186+
187+
- name: Release Artifact [windows/amd64]
188+
uses: actions/upload-release-asset@v1
189+
env:
190+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
191+
with:
192+
upload_url: ${{ steps.create_release.outputs.upload_url }}
193+
asset_path: bin/ws4sql-${{ github.ref_name }}-win-amd64.zip
194+
asset_name: ws4sql-${{ github.ref_name }}-win-amd64.zip
195+
asset_content_type: application/zip
196+
197+
build-docker:
198+
runs-on: ubuntu-latest
199+
strategy:
200+
fail-fast: false
201+
matrix:
202+
platform:
203+
- linux/amd64
204+
- linux/arm64
205+
steps:
206+
- name: Prepare
207+
run: |
208+
platform=${{ matrix.platform }}
209+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
210+
211+
- name: Checkout
212+
uses: actions/checkout@v4
213+
214+
- name: Modify version number
215+
run: sed -i 's/v0\.0\.0/${{ github.ref_name }}/g' ws4sql.go
216+
working-directory: src/
217+
218+
- name: Docker meta
219+
id: meta
220+
uses: docker/metadata-action@v5
221+
with:
222+
images: ${{ env.REGISTRY_IMAGE }}
223+
224+
# - name: Set up QEMU
225+
# uses: docker/setup-qemu-action@v3
226+
227+
- name: Set up Docker Buildx
228+
uses: docker/setup-buildx-action@v3
229+
230+
- name: Login to Github Container Registry
231+
uses: docker/login-action@v3
232+
with:
233+
registry: ghcr.io
234+
username: ${{ github.actor }}
235+
password: ${{ secrets.TOKEN }}
236+
237+
- name: Build and push by digest
238+
id: build
239+
uses: docker/build-push-action@v5
240+
with:
241+
context: .
242+
platforms: ${{ matrix.platform }}
243+
labels: ${{ steps.meta.outputs.labels }}
244+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
245+
246+
- name: Export digest
247+
run: |
248+
mkdir -p /tmp/digests
249+
digest="${{ steps.build.outputs.digest }}"
250+
touch "/tmp/digests/${digest#sha256:}"
251+
252+
- name: Upload digest
253+
uses: actions/upload-artifact@v4
254+
with:
255+
name: digests-${{ env.PLATFORM_PAIR }}
256+
path: /tmp/digests/*
257+
if-no-files-found: error
258+
retention-days: 1
259+
260+
merge-docker:
261+
runs-on: ubuntu-latest
262+
needs:
263+
- build-docker
264+
- release
265+
- test
266+
steps:
267+
- name: Download digests
268+
uses: actions/download-artifact@v4
269+
with:
270+
path: /tmp/digests
271+
pattern: digests-*
272+
merge-multiple: true
273+
274+
- name: Set up Docker Buildx
275+
uses: docker/setup-buildx-action@v3
276+
277+
- name: Docker meta
278+
id: meta
279+
uses: docker/metadata-action@v5
280+
with:
281+
images: ${{ env.REGISTRY_IMAGE }}
282+
283+
- name: Login to Github Container Registry
284+
uses: docker/login-action@v3
285+
with:
286+
registry: ghcr.io
287+
username: ${{ github.actor }}
288+
password: ${{ secrets.TOKEN }}
289+
290+
- name: Create manifest list and push
291+
working-directory: /tmp/digests
292+
run: |
293+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
294+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
295+
296+
- name: Inspect image
297+
run: |
298+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See BUILDING.md
2+
3+
FROM golang:latest as build
4+
5+
WORKDIR /go/src/app
6+
COPY . .
7+
8+
RUN make build
9+
10+
# Now copy it into our base image.
11+
FROM gcr.io/distroless/static-debian12
12+
COPY --from=build /go/src/app/bin/ws4sql /
13+
14+
EXPOSE 12321
15+
VOLUME /data
16+
17+
ENTRYPOINT ["/ws4sql"]

Dockerfile.arm64

Lines changed: 0 additions & 8 deletions
This file was deleted.

Dockerfile.binaries

Lines changed: 0 additions & 17 deletions
This file was deleted.

Dockerfile.x86_64

Lines changed: 0 additions & 8 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ build:
1818
cd src; go build -trimpath
1919
mv src/ws4sql bin/
2020

21+
build-windows:
22+
make build-prepare
23+
cd src; go build -trimpath
24+
mv src/ws4sql.exe bin/
25+
2126
build-static:
2227
make build-prepare
2328
cd src; go build -trimpath -a -tags="netgo osusergo sqlite_omit_load_extension" -ldflags='-w -extldflags "-static"'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Obtaining an answer of
7777
- [**Embedded web server**](https://germ.gitbook.io/ws4sql/documentation/web-server) to directly serve web pages that can access ws4sql without CORS;
7878
- Compact codebase;
7979
- Comprehensive test suite (`make test`);
80-
- 6 os's/arch's directly supported;
80+
- 4 os's/arch's directly supported (`linux`, `amd64` and `arm64`; `macos`, `arm64`; `windows`, `amd64`);
8181
- [**Docker images**](https://germ.gitbook.io/ws4sql/documentation/installation/docker), for amd64, arm and arm64.
8282

8383
# Security Features

ROAD_TO_WS4SQL.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
The next version of `ws4sqlite` will be called `ws4sql`, because it will support more RDBMs than sqlite.
22

3-
The version in this branch is a work in progress to slowly add features and (unfortunately) breaking changes; here is a review of what changed compared to `ws4sqlite` "stable" + a migration path.
3+
The version in this branch is a work in progress to add features and (unfortunately) breaking changes; here is a review of what changed compared to `ws4sqlite` "stable" + a migration path.
44

55
# Changes
66

77
- SQLite is embedded via [mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) and CGO. Should be way faster.
88
- Support for DuckDB (see below).
9-
- Target platforms (because of CGO) are now 6 (`win/amd64`, `macos/amd64`, `macos/arm64`, `linux/amd64`, `linux/arm64`, `linux/arm6`).
9+
- Target platforms (because of CGO) are now 4 (`win/amd64`, `macos/arm64`, `linux/amd64`, `linux/arm64`).
10+
- For Docker, `linux/amd64` and `linux/arm64`.
1011
- [**BREAKING CHANGE**] When running the app, the config files must be specified on the command line, the file paths cannot be used anymore (there). This is described in the "Migration" section below. The file path is in the config file.
1112
- The only exception is a "simple case" to serve a file path without any config. This can be done with the new `--quick-db` parameter.
12-
- Fail fast if the request is empty, don't even attempt to authenticate
13+
- Fail fast if the request is empty, don't even attempt to authenticate.
14+
- Docker images are now based on `distroless/static-debian12`.
15+
- Docker images are now hosted on Github's Container Registry.
1316

1417
# Migration
1518

0 commit comments

Comments
 (0)