Skip to content

Commit 596f4e4

Browse files
authored
Merge pull request #2 from zeabur/improve-release
ci: add CI workflows, golangci-lint config, and release pipeline
2 parents ee8e463 + 6870e4b commit 596f4e4

7 files changed

Lines changed: 251 additions & 58 deletions

File tree

.github/workflows/release.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
actions: write
13+
14+
concurrency:
15+
group: release-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17+
18+
jobs:
19+
build-amd64:
20+
name: Build (linux/amd64)
21+
runs-on: blacksmith-2vcpu-ubuntu-2404
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
29+
30+
- name: Login to Docker Hub
31+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
32+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_TOKEN }}
36+
37+
- name: Extract version
38+
id: meta
39+
run: |
40+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
41+
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
44+
fi
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
48+
with:
49+
platforms: linux/amd64
50+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
51+
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-amd64
52+
cache-from: type=gha,scope=buildkit-linux-amd64
53+
cache-to: type=gha,mode=max,scope=buildkit-linux-amd64
54+
55+
build-arm64:
56+
name: Build (linux/arm64)
57+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
65+
66+
- name: Login to Docker Hub
67+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
68+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
69+
with:
70+
username: ${{ secrets.DOCKERHUB_USERNAME }}
71+
password: ${{ secrets.DOCKERHUB_TOKEN }}
72+
73+
- name: Extract version
74+
id: meta
75+
run: |
76+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
77+
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
78+
else
79+
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
80+
fi
81+
82+
- name: Build and push
83+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
84+
with:
85+
platforms: linux/arm64
86+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
87+
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-arm64
88+
cache-from: type=gha,scope=buildkit-linux-arm64
89+
cache-to: type=gha,mode=max,scope=buildkit-linux-arm64
90+
91+
push-dockerhub:
92+
name: Push to Docker Hub
93+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
94+
needs: [build-amd64, build-arm64]
95+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
96+
97+
steps:
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
100+
101+
- name: Login to Docker Hub
102+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
103+
with:
104+
username: ${{ secrets.DOCKERHUB_USERNAME }}
105+
password: ${{ secrets.DOCKERHUB_TOKEN }}
106+
107+
- name: Create multi-arch manifest
108+
run: |
109+
VERSION=${GITHUB_REF_NAME#v}
110+
docker buildx imagetools create \
111+
-t docker.io/zeabur/stratus:${VERSION} \
112+
-t docker.io/zeabur/stratus:${VERSION%.*} \
113+
-t docker.io/zeabur/stratus:${VERSION%%.*} \
114+
-t docker.io/zeabur/stratus:latest \
115+
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
116+
docker.io/zeabur/stratus:${VERSION}-linux-arm64
117+
118+
push-swr:
119+
name: Push to Huawei SWR
120+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
121+
needs: [build-amd64, build-arm64]
122+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
123+
124+
steps:
125+
- name: Set up Docker Buildx
126+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
127+
128+
- name: Login to Docker Hub
129+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
130+
with:
131+
username: ${{ secrets.DOCKERHUB_USERNAME }}
132+
password: ${{ secrets.DOCKERHUB_TOKEN }}
133+
134+
- name: Login to Huawei SWR
135+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
136+
with:
137+
registry: swr.cn-east-3.myhuaweicloud.com
138+
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
139+
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
140+
141+
- name: Retag to SWR
142+
run: |
143+
VERSION=${GITHUB_REF_NAME#v}
144+
REGISTRY=swr.cn-east-3.myhuaweicloud.com
145+
docker buildx imagetools create \
146+
-t ${REGISTRY}/zeabur/stratus:${VERSION} \
147+
-t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
148+
-t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
149+
-t ${REGISTRY}/zeabur/stratus:latest \
150+
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
151+
docker.io/zeabur/stratus:${VERSION}-linux-arm64

.github/workflows/tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
id-token: write
12+
contents: read
13+
14+
concurrency:
15+
group: tests-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
lint:
20+
name: Lint and format
21+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
27+
- name: Install Nix
28+
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0
29+
30+
- name: Set up FlakeHub cache
31+
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0
32+
33+
- name: Verify formatting
34+
run: nix develop --command golangci-lint fmt --diff
35+
36+
- name: Run golangci-lint
37+
run: nix develop --command golangci-lint run ./...
38+
39+
unit:
40+
name: Unit tests
41+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46+
47+
- name: Install Nix
48+
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0
49+
50+
- name: Set up FlakeHub cache
51+
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0
52+
53+
- name: Run unit tests
54+
run: nix develop --command go test ./...

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
6+
linters:
7+
default: standard
8+
enable:
9+
- modernize
10+
11+
formatters:
12+
enable:
13+
- gofumpt

examples/push-image/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"github.com/google/go-containerregistry/pkg/v1/empty"
2323
"github.com/google/go-containerregistry/pkg/v1/layout"
2424

25-
stratusconfig "github.com/zeabur/stratus/v2/pkg/config"
26-
stratuspush "github.com/zeabur/stratus/v2/pkg/push"
25+
stratusconfig "github.com/zeabur/stratus/v2/pkg/config"
26+
stratuspush "github.com/zeabur/stratus/v2/pkg/push"
2727
stratusstorage "github.com/zeabur/stratus/v2/pkg/storage"
2828
)
2929

flake.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,41 @@ module github.com/zeabur/stratus/v2
33
go 1.26.1
44

55
require (
6-
github.com/gofiber/fiber/v3 v3.1.0
7-
github.com/google/go-containerregistry v0.21.5
8-
github.com/minio/minio-go/v7 v7.0.100
9-
github.com/samber/slog-fiber v1.22.1
6+
github.com/gofiber/fiber/v3 v3.2.0
7+
github.com/minio/minio-go/v7 v7.1.0
8+
github.com/samber/slog-fiber v1.22.2
109
golang.org/x/sync v0.20.0
1110
)
1211

1312
require (
1413
github.com/andybalholm/brotli v1.2.1 // indirect
1514
github.com/cespare/xxhash/v2 v2.3.0 // indirect
16-
github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
17-
github.com/docker/cli v29.4.0+incompatible // indirect
18-
github.com/docker/docker-credential-helpers v0.9.3 // indirect
1915
github.com/dustin/go-humanize v1.0.1 // indirect
2016
github.com/go-ini/ini v1.67.0 // indirect
2117
github.com/gofiber/schema v1.7.1 // indirect
2218
github.com/gofiber/utils/v2 v2.0.4 // indirect
2319
github.com/google/uuid v1.6.0 // indirect
24-
github.com/klauspost/compress v1.18.5 // indirect
20+
github.com/klauspost/compress v1.18.6 // indirect
2521
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
2622
github.com/klauspost/crc32 v1.3.0 // indirect
2723
github.com/kr/pretty v0.3.1 // indirect
2824
github.com/mattn/go-colorable v0.1.14 // indirect
29-
github.com/mattn/go-isatty v0.0.21 // indirect
25+
github.com/mattn/go-isatty v0.0.22 // indirect
3026
github.com/minio/crc64nvme v1.1.1 // indirect
3127
github.com/minio/md5-simd v1.1.2 // indirect
32-
github.com/mitchellh/go-homedir v1.1.0 // indirect
33-
github.com/opencontainers/go-digest v1.0.0 // indirect
34-
github.com/opencontainers/image-spec v1.1.1 // indirect
3528
github.com/philhofer/fwd v1.2.0 // indirect
3629
github.com/rogpeppe/go-internal v1.14.1 // indirect
3730
github.com/rs/xid v1.6.0 // indirect
38-
github.com/sirupsen/logrus v1.9.4 // indirect
3931
github.com/tinylib/msgp v1.6.4 // indirect
4032
github.com/valyala/bytebufferpool v1.0.0 // indirect
41-
github.com/valyala/fasthttp v1.70.0 // indirect
42-
github.com/vbatts/tar-split v0.12.2 // indirect
33+
github.com/valyala/fasthttp v1.71.0 // indirect
34+
github.com/zeebo/xxh3 v1.1.0 // indirect
4335
go.opentelemetry.io/otel v1.43.0 // indirect
4436
go.opentelemetry.io/otel/trace v1.43.0 // indirect
4537
go.yaml.in/yaml/v3 v3.0.4 // indirect
4638
golang.org/x/crypto v0.50.0 // indirect
4739
golang.org/x/net v0.53.0 // indirect
48-
golang.org/x/sys v0.43.0 // indirect
40+
golang.org/x/sys v0.44.0 // indirect
4941
golang.org/x/text v0.36.0 // indirect
5042
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
51-
gotest.tools/v3 v3.5.2 // indirect
5243
)

0 commit comments

Comments
 (0)