New dist-zip job, independent of build-and-push (no change to the archied/archie-agent Docker image jobs). Triggers on any archied/vX.Y.Z tag, so a gateway-only release (RUNTIME=skip) still produces it, keyed to the archied version alone -- these binaries aren't in tools/release.sh's two-component split and don't need to be for this. archie-agent is deliberately excluded: it only ever runs inside the Docker image build-and-push already publishes, never as a host binary. Zip contains the four linux/amd64 binaries, the new deployments/INSTRUCTIONS.md (quickstart + deployment-profile/systemd pointers), and CHANGELOG.md/CHANGELOG.archied.md/CHANGELOG.archie.md. README.md is included only if present -- it doesn't exist in this repo yet, so omitted for now rather than fabricated here. Verified locally: all four binaries build clean under GOOS=linux GOARCH=amd64 CGO_ENABLED=0 (modernc.org/sqlite is pure Go, no cgo sqlite driver to worry about), and the assembled zip's contents match what the workflow step produces.
241 lines
9.0 KiB
YAML
241 lines
9.0 KiB
YAML
# Builds and pushes the archied and archie-agent images to GHCR on every
|
|
# merge to main. Mirrors .gitea/workflows/deploy.yml, which remains the
|
|
# production build path against git.catlow.cloud until that's cut over.
|
|
name: deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["archied/v*", "archie/v*"]
|
|
|
|
# Rapid successive pushes to main (a release commit right after its
|
|
# preceding fix, say) previously queued a full gate+build for each one,
|
|
# several minutes apiece, with no caching -- so a burst of pushes left
|
|
# three deploys racing in parallel for the same runner capacity. Only the
|
|
# last one's images matter (both jobs push :latest), so cancel a
|
|
# superseded run rather than let it fight for resources it can't use.
|
|
#
|
|
# Keyed on the commit, not github.ref: `git push --follow-tags` pushes
|
|
# main plus both archied/v* and archie/v* tags in one go, and all three
|
|
# refs point at the same commit -- on.push matches branches and tags
|
|
# both, so a single release push otherwise fires three redundant builds
|
|
# of identical content that a ref-keyed group can't see as the same work.
|
|
concurrency:
|
|
group: deploy-${{ github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
gate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
|
|
- name: Install gofumpt
|
|
run: go install mvdan.cc/gofumpt@latest
|
|
|
|
- name: Install protobuf tools
|
|
run: bash tools/proto.sh install
|
|
|
|
- name: Ensure contract baseline ref
|
|
run: |
|
|
if ! git show-ref --verify --quiet refs/heads/main; then
|
|
git branch main origin/main
|
|
fi
|
|
|
|
- name: Install ripgrep
|
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ripgrep
|
|
|
|
- name: Quality gate
|
|
run: |
|
|
gofumpt -w .
|
|
go fix ./...
|
|
bash tools/proto.sh lint
|
|
bash tools/proto.sh check
|
|
go vet ./...
|
|
go build ./...
|
|
go test ./... -count=1
|
|
|
|
- name: Vulnerability scan
|
|
run: |
|
|
go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
govulncheck ./...
|
|
|
|
# The dashboard suite runs in CI too, or it only ever runs when
|
|
# someone remembers to; the Go steps above never touch it.
|
|
- name: Dashboard tests
|
|
run: |
|
|
npm ci --prefix ui || npm install --prefix ui
|
|
npm test --prefix ui
|
|
|
|
- name: Release tags must match changelogs
|
|
run: |
|
|
set -e
|
|
fail=0
|
|
for tag in $(git tag --points-at HEAD); do
|
|
case "$tag" in
|
|
archied/v*)
|
|
# Strip the "v" too: tags are archied/vX.Y.Z, changelog
|
|
# sections are "## [X.Y.Z]" (see tools/release.sh).
|
|
ver="${tag#archied/v}"
|
|
echo " archied tag $tag -> looking for [$ver] in CHANGELOG.archied.md"
|
|
grep -q "^## \\[$ver\\]" CHANGELOG.archied.md || {
|
|
echo " FAIL: CHANGELOG.archied.md has no [$ver] section"
|
|
fail=1
|
|
}
|
|
;;
|
|
archie/v*)
|
|
ver="${tag#archie/v}"
|
|
echo " archie tag $tag -> looking for [$ver] in CHANGELOG.archie.md"
|
|
grep -q "^## \\[$ver\\]" CHANGELOG.archie.md || {
|
|
echo " FAIL: CHANGELOG.archie.md has no [$ver] section"
|
|
fail=1
|
|
}
|
|
;;
|
|
esac
|
|
done
|
|
if [ $fail -ne 0 ]; then
|
|
echo
|
|
echo "A release tag points at this commit but its changelog does not"
|
|
echo "describe that version. Run: task release:prepare VERSION=<ver>"
|
|
echo "edit the generated notes, then: task release VERSION=<ver>"
|
|
exit 1
|
|
fi
|
|
if ! git tag --points-at HEAD | grep -qE 'archie' ; then
|
|
echo "::warning ::No release tags at HEAD -- images will be stamped 'dev'"
|
|
fi
|
|
|
|
build-and-push:
|
|
needs: gate
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
|
|
|
- name: Resolve component versions
|
|
id: versions
|
|
run: |
|
|
GATEWAY_TAG="$(git tag --points-at HEAD --list 'archied/v*' | sort -V | tail -1)"
|
|
RUNTIME_TAG="$(git tag --points-at HEAD --list 'archie/v*' | sort -V | tail -1)"
|
|
GATEWAY_VERSION="${GATEWAY_TAG#archied/}"
|
|
RUNTIME_VERSION="${RUNTIME_TAG#archie/}"
|
|
[ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION=dev
|
|
[ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION=dev
|
|
# Keep the raw tag presence separate from the version fallback:
|
|
# gateway-only releases must not rebuild the runtime image as dev.
|
|
echo "gateway_tag=$GATEWAY_TAG" >> "$GITHUB_OUTPUT"
|
|
echo "runtime_tag=$RUNTIME_TAG" >> "$GITHUB_OUTPUT"
|
|
echo "gateway=$GATEWAY_VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push archied
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile.archied
|
|
push: true
|
|
tags: ghcr.io/samcharles93/archied:latest
|
|
build-args: |
|
|
GATEWAY_VERSION=${{ steps.versions.outputs.gateway }}
|
|
RUNTIME_VERSION=${{ steps.versions.outputs.runtime }}
|
|
cache-from: type=gha,scope=archied
|
|
cache-to: type=gha,mode=max,scope=archied
|
|
|
|
- name: Build and push archie-agent
|
|
if: steps.versions.outputs.runtime_tag != ''
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
push: true
|
|
tags: ghcr.io/samcharles93/archie-agent:latest
|
|
build-args: |
|
|
RUNTIME_VERSION=${{ steps.versions.outputs.runtime }}
|
|
cache-from: type=gha,scope=archie-agent
|
|
cache-to: type=gha,mode=max,scope=archie-agent
|
|
|
|
# Packages the host-run binaries (archied, archie-gateway,
|
|
# archie-state-store, archie-playbooks) as a linux/amd64 zip for a
|
|
# non-Docker install. Independent of build-and-push: it never touches the
|
|
# archied/archie-agent image jobs, and a gateway-only release (no
|
|
# archie/v* tag) still produces this zip -- it's keyed to the archied tag
|
|
# alone. archie-agent is deliberately excluded: it only ever runs inside
|
|
# the Docker image build-and-push already publishes, never as a host
|
|
# binary (archie-core-8cda.4.7.1).
|
|
dist-zip:
|
|
needs: gate
|
|
if: startsWith(github.ref, 'refs/tags/archied/v')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Resolve archied version
|
|
id: version
|
|
run: echo "version=${GITHUB_REF#refs/tags/archied/v}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build linux/amd64 binaries
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: amd64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
set -e
|
|
ldflags_archied="-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=${{ steps.version.outputs.version }} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary"
|
|
ldflags_gateway="-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=${{ steps.version.outputs.version }} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary"
|
|
mkdir -p dist
|
|
go build -ldflags "$ldflags_archied" -o dist/archied ./cmd/archied
|
|
go build -ldflags "$ldflags_gateway" -o dist/archie-gateway ./cmd/archie-gateway
|
|
go build -o dist/archie-state-store ./cmd/archie-state-store
|
|
go build -o dist/archie-playbooks ./cmd/archie-playbooks
|
|
|
|
- name: Assemble distribution zip
|
|
id: zip
|
|
run: |
|
|
set -e
|
|
name="archie-core-archied-v${{ steps.version.outputs.version }}-linux-amd64"
|
|
mkdir -p "$name"
|
|
cp dist/archied dist/archie-gateway dist/archie-state-store dist/archie-playbooks "$name/"
|
|
cp deployments/INSTRUCTIONS.md CHANGELOG.md CHANGELOG.archied.md CHANGELOG.archie.md "$name/"
|
|
# README.md doesn't exist yet in this repo; include it once it does
|
|
# rather than fail the release on its absence.
|
|
[ -f README.md ] && cp README.md "$name/"
|
|
zip -r "$name.zip" "$name"
|
|
echo "name=$name" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload distribution zip
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.zip.outputs.name }}
|
|
path: ${{ steps.zip.outputs.name }}.zip
|
|
retention-days: 90
|