Files
zampler/.gitea/workflows/build.yml
T
aneurin 7f57e25dcf
Build / build-and-push (push) Successful in 6m7s
Build a multi-arch (amd64 + arm64) image (!4)
Co-authored-by: Aneurin Barker Snook <aneurin@aneur.in>
2026-09-07 00:42:58 +00:00

78 lines
2.2 KiB
YAML

name: Build
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
container:
image: golang:1.26-alpine
env:
CGO_ENABLED: "0"
IMAGE: code.aneur.in/${{ gitea.repository }}
steps:
- name: Install toolchain deps
run: apk add --no-cache nodejs npm docker-cli docker-cli-buildx git tar
- uses: actions/checkout@v4
- name: Cache npm downloads
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: npm-
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-${{ hashFiles('go.sum') }}-${{ hashFiles('**/*.go') }}
restore-keys: |
go-${{ hashFiles('go.sum') }}-
go-
- name: Build frontend
working-directory: frontend
run: |
npm ci
npx vite build --outDir ../internal/server/static --emptyOutDir
- name: Cross-compile binaries
run: |
for arch in amd64 arm64; do
GOOS=linux GOARCH="$arch" \
go build -ldflags="-s -w" -o "dist/zampler-linux-$arch" .
done
- name: Set up Docker buildx
run: |
docker buildx rm multi 2>/dev/null || true
docker buildx create --name multi --driver docker-container --use
- name: Log in to the container registry
env:
BUILD_API_TOKEN: ${{ secrets.BUILD_API_TOKEN }}
run: echo "$BUILD_API_TOKEN" | docker login code.aneur.in -u "${{ gitea.actor }}" --password-stdin
- name: Promote current "latest" to "previous"
run: |
if docker buildx imagetools inspect "$IMAGE:latest" >/dev/null 2>&1; then
docker buildx imagetools create -t "$IMAGE:previous" "$IMAGE:latest"
else
echo "No existing :latest to promote; skipping."
fi
- name: Build and push multi-arch "latest"
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag "$IMAGE:latest" \
--push \
.