Files
zampler/.gitea/workflows/build.yml
T
aneurinandClaude Sonnet 5 ad4fc7dd7d
Build / build-binary (push) Failing after 59s
Build / build-image (push) Skipped
name the build artifact with its architecture
Rename the CI binary and its artifact to zampler-amd64, and make the
Dockerfile arch-agnostic via ARG TARGETARCH / COPY zampler-$TARGETARCH.
Keeps the pipeline single-arch for now but makes adding an arm64 leg a
smaller change later.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 17:07:20 +01:00

93 lines
2.4 KiB
YAML

name: Build
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-binary:
runs-on: ubuntu-latest
container:
image: golang:1.26-alpine
env:
CGO_ENABLED: "0"
steps:
- name: Install toolchain deps
run: apk add --no-cache nodejs npm 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: Build binary
run: go build -ldflags="-s -w" -o zampler-amd64 .
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: zampler-amd64
path: zampler-amd64
if-no-files-found: error
retention-days: 1
build-image:
runs-on: ubuntu-latest
needs: build-binary
container:
image: docker:cli
steps:
- name: Install action deps
run: apk add --no-cache nodejs
- uses: actions/checkout@v4
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: zampler-amd64
- name: Restore executable bit
run: chmod +x zampler-amd64
- 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: |
IMAGE="code.aneur.in/${{ gitea.repository }}"
if docker pull "$IMAGE:latest"; then
docker tag "$IMAGE:latest" "$IMAGE:previous"
docker push "$IMAGE:previous"
fi
- name: Build and push "latest"
run: |
IMAGE="code.aneur.in/${{ gitea.repository }}:latest"
docker build --build-arg TARGETARCH=amd64 -t "$IMAGE" .
docker push "$IMAGE"