Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Release

on:
push:
tags:
- "v*"
pull_request:
workflow_dispatch:

permissions:
contents: read
actions: write

concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build-amd64:
name: Build (linux/amd64)
runs-on: blacksmith-2vcpu-ubuntu-2404

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0

- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract version
id: meta
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
fi

- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
platforms: linux/amd64
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-amd64
cache-from: type=gha,scope=buildkit-linux-amd64
cache-to: type=gha,mode=max,scope=buildkit-linux-amd64

build-arm64:
name: Build (linux/arm64)
runs-on: blacksmith-2vcpu-ubuntu-2404-arm

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0

- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract version
id: meta
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
fi

- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
platforms: linux/arm64
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-arm64
cache-from: type=gha,scope=buildkit-linux-arm64
cache-to: type=gha,mode=max,scope=buildkit-linux-arm64

push-dockerhub:
name: Push to Docker Hub
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
needs: [build-amd64, build-arm64]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0

- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create multi-arch manifest
run: |
VERSION=${GITHUB_REF_NAME#v}
docker buildx imagetools create \
-t docker.io/zeabur/stratus:${VERSION} \
-t docker.io/zeabur/stratus:${VERSION%.*} \
-t docker.io/zeabur/stratus:${VERSION%%.*} \
-t docker.io/zeabur/stratus:latest \
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
docker.io/zeabur/stratus:${VERSION}-linux-arm64

push-swr:
name: Push to Huawei SWR
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
needs: [build-amd64, build-arm64]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0

- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Huawei SWR
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: swr.cn-east-3.myhuaweicloud.com
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
password: ${{ secrets.HUAWEI_SWR_TOKEN }}

Comment thread
pan93412 marked this conversation as resolved.
- name: Retag to SWR
run: |
VERSION=${GITHUB_REF_NAME#v}
REGISTRY=swr.cn-east-3.myhuaweicloud.com
docker buildx imagetools create \
-t ${REGISTRY}/zeabur/stratus:${VERSION} \
-t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
-t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
-t ${REGISTRY}/zeabur/stratus:latest \
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
docker.io/zeabur/stratus:${VERSION}-linux-arm64
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
id-token: write
contents: read

concurrency:
group: tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint and format
runs-on: blacksmith-2vcpu-ubuntu-2404-arm

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0

- name: Set up FlakeHub cache
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0

- name: Verify formatting
run: nix develop --command golangci-lint fmt --diff

- name: Run golangci-lint
run: nix develop --command golangci-lint run ./...

unit:
name: Unit tests
runs-on: blacksmith-2vcpu-ubuntu-2404-arm

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0

- name: Set up FlakeHub cache
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0

- name: Run unit tests
run: nix develop --command go test ./...
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "2"

run:
timeout: 5m

linters:
default: standard
enable:
- modernize

formatters:
enable:
- gofumpt
4 changes: 2 additions & 2 deletions examples/push-image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/layout"

stratusconfig "github.com/zeabur/stratus/v2/pkg/config"
stratuspush "github.com/zeabur/stratus/v2/pkg/push"
stratusconfig "github.com/zeabur/stratus/v2/pkg/config"
stratuspush "github.com/zeabur/stratus/v2/pkg/push"
stratusstorage "github.com/zeabur/stratus/v2/pkg/storage"
)

Expand Down
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 8 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,41 @@ module github.com/zeabur/stratus/v2
go 1.26.1

require (
github.com/gofiber/fiber/v3 v3.1.0
github.com/google/go-containerregistry v0.21.5
github.com/minio/minio-go/v7 v7.0.100
github.com/samber/slog-fiber v1.22.1
github.com/gofiber/fiber/v3 v3.2.0
Comment thread
pan93412 marked this conversation as resolved.
github.com/minio/minio-go/v7 v7.1.0
github.com/samber/slog-fiber v1.22.2
golang.org/x/sync v0.20.0
)

require (
github.com/andybalholm/brotli v1.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
github.com/docker/cli v29.4.0+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/gofiber/schema v1.7.1 // indirect
github.com/gofiber/utils/v2 v2.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/klauspost/crc32 v1.3.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.21 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/minio/crc64nvme v1.1.1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.70.0 // indirect
github.com/vbatts/tar-split v0.12.2 // indirect
github.com/valyala/fasthttp v1.71.0 // indirect
github.com/zeebo/xxh3 v1.1.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/text v0.36.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gotest.tools/v3 v3.5.2 // indirect
)
Loading
Loading