ci: build release binaries once and stop recompiling archied #1852
No files matched your search
@@ -23,18 +23,20 @@ jobs:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
|
||||
- name: Build archied
|
||||
run: go build -tags no_ui -o "$RUNNER_TEMP/archied" ./cmd/archied
|
||||
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Fetch the published archied
|
||||
# The deploy workflow already built this binary. edge is the newest
|
||||
# main that passed the gate.
|
||||
run: |
|
||||
set -e
|
||||
image=git.catlow.cloud/sam/archied:edge
|
||||
docker pull -q "$image"
|
||||
container="$(docker create "$image")"
|
||||
docker cp "$container:/usr/local/bin/archied" "$RUNNER_TEMP/archied"
|
||||
docker rm "$container" >/dev/null
|
||||
|
||||
- name: Judge the canary
|
||||
env:
|
||||
ARCHIE_CANARY_TOKEN: ${{ secrets.CANARY_TOKEN }}
|
||||
|
||||
@@ -19,6 +19,8 @@ jobs:
|
||||
outputs:
|
||||
archied_version: ${{ steps.release_tag.outputs.archied_version }}
|
||||
run: ${{ steps.release_tag.outputs.run }}
|
||||
sha: ${{ steps.release_tag.outputs.sha }}
|
||||
component: ${{ steps.release_tag.outputs.component }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -35,6 +37,12 @@ jobs:
|
||||
else
|
||||
echo "no release tag at HEAD; distribution zip will be skipped"
|
||||
fi
|
||||
# An annotated tag makes GITHUB_SHA the tag object, so the commit is
|
||||
# resolved from the ref: image tags pin it.
|
||||
sha="$(git rev-parse "${GITHUB_REF}^{commit}")"
|
||||
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||
# A release reports its version; any other build of main names its commit.
|
||||
echo "component=${version:-dev+${sha:0:12}}" >> "$GITHUB_OUTPUT"
|
||||
run=true
|
||||
case "$GITHUB_REF" in
|
||||
refs/tags/*) ;;
|
||||
@@ -70,7 +78,7 @@ jobs:
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
node-version: "24"
|
||||
|
||||
- name: Install quality tools
|
||||
run: |
|
||||
@@ -94,13 +102,22 @@ jobs:
|
||||
run: docker pull alpine:3
|
||||
|
||||
- name: Quality gate
|
||||
env:
|
||||
RELEASE_VERSION: ${{ needs.plan.outputs.archied_version }}
|
||||
run: |
|
||||
task check TEST_FLAGS=-count=1
|
||||
# A release also builds the binaries it ships, in the same task run:
|
||||
# the dashboard is built once and the tree that passed is the tree
|
||||
# that is published.
|
||||
if [ -n "$RELEASE_VERSION" ]; then
|
||||
task check dist TEST_FLAGS=-count=1 VERSION="$RELEASE_VERSION"
|
||||
else
|
||||
task check TEST_FLAGS=-count=1
|
||||
fi
|
||||
git diff --exit-code
|
||||
|
||||
- name: Vulnerability scan
|
||||
run: |
|
||||
go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
go install golang.org/x/vuln/cmd/govulncheck@v1.9.0
|
||||
govulncheck ./...
|
||||
|
||||
- name: Release tags must match changelogs
|
||||
@@ -129,156 +146,116 @@ jobs:
|
||||
echo "This commit isn't a release, so the images are published as :edge and sha-<sha>; :latest keeps naming the newest promoted release."
|
||||
fi
|
||||
|
||||
- name: Package the release binaries
|
||||
if: needs.plan.outputs.archied_version != ''
|
||||
# tar keeps the executable bit, which an uploaded artifact drops.
|
||||
run: tar -cf release-binaries.tar dist
|
||||
|
||||
- name: Upload the release binaries
|
||||
if: needs.plan.outputs.archied_version != ''
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-binaries
|
||||
path: release-binaries.tar
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
archied-image:
|
||||
needs: gate
|
||||
needs: [plan, gate]
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve the commit this ref points at
|
||||
id: commit
|
||||
run: |
|
||||
sha="$(git rev-parse "${GITHUB_REF}^{commit}")"
|
||||
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||
echo "short=${sha:0:12}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
# One named builder that is never removed, so the Dockerfiles' cache
|
||||
# mounts are still there on the next run. Removing it at the end of
|
||||
# a job would take it from under another run that is building.
|
||||
name: archie-ci
|
||||
cleanup: false
|
||||
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Resolve component versions
|
||||
id: versions
|
||||
run: |
|
||||
RELEASE_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -1)"
|
||||
GATEWAY_VERSION="${RELEASE_TAG#v}"
|
||||
RUNTIME_VERSION="${RELEASE_TAG#v}"
|
||||
[ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION="dev+${GITHUB_SHA:0:12}"
|
||||
[ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION="dev+${GITHUB_SHA:0:12}"
|
||||
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "gateway=$GATEWAY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "archied_tags<<EOF"
|
||||
if [ -n "$RELEASE_TAG" ]; then
|
||||
echo "git.catlow.cloud/sam/archied:$RELEASE_TAG"
|
||||
fi
|
||||
echo "git.catlow.cloud/sam/archied:edge"
|
||||
echo "git.catlow.cloud/sam/archied:sha-${{ steps.commit.outputs.sha }}"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and push archied
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.archied
|
||||
push: true
|
||||
tags: ${{ steps.versions.outputs.archied_tags }}
|
||||
# The first line is empty for a build of main; empty lines are ignored.
|
||||
tags: |
|
||||
${{ needs.plan.outputs.archied_version != '' && format('git.catlow.cloud/sam/archied:v{0}', needs.plan.outputs.archied_version) || '' }}
|
||||
git.catlow.cloud/sam/archied:edge
|
||||
git.catlow.cloud/sam/archied:sha-${{ needs.plan.outputs.sha }}
|
||||
build-args: |
|
||||
GATEWAY_VERSION=${{ steps.versions.outputs.gateway }}
|
||||
RUNTIME_VERSION=${{ steps.versions.outputs.runtime }}
|
||||
GATEWAY_VERSION=${{ needs.plan.outputs.component }}
|
||||
RUNTIME_VERSION=${{ needs.plan.outputs.component }}
|
||||
cache-from: type=gha,scope=archied
|
||||
cache-to: type=gha,mode=max,scope=archied
|
||||
|
||||
agent-image:
|
||||
needs: [plan, gate]
|
||||
# The agent image is only published with a release.
|
||||
if: needs.plan.outputs.run == 'true' && needs.plan.outputs.archied_version != ''
|
||||
outputs:
|
||||
agent_digest: ${{ steps.agent.outputs.digest }}
|
||||
needs: gate
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve the commit this ref points at
|
||||
id: commit
|
||||
run: |
|
||||
sha="$(git rev-parse "${GITHUB_REF}^{commit}")"
|
||||
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||
echo "short=${sha:0:12}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
# One named builder that is never removed, so the Dockerfiles' cache
|
||||
# mounts are still there on the next run. Removing it at the end of
|
||||
# a job would take it from under another run that is building.
|
||||
name: archie-ci
|
||||
cleanup: false
|
||||
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Resolve runtime version
|
||||
id: versions
|
||||
run: |
|
||||
RELEASE_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -1)"
|
||||
RUNTIME_VERSION="${RELEASE_TAG#v}"
|
||||
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and push archie-agent
|
||||
id: agent
|
||||
if: steps.versions.outputs.release_tag != ''
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
git.catlow.cloud/sam/archie-agent:${{ steps.versions.outputs.release_tag }}
|
||||
git.catlow.cloud/sam/archie-agent:sha-${{ steps.commit.outputs.sha }}
|
||||
git.catlow.cloud/sam/archie-agent:v${{ needs.plan.outputs.archied_version }}
|
||||
git.catlow.cloud/sam/archie-agent:sha-${{ needs.plan.outputs.sha }}
|
||||
build-args: |
|
||||
RUNTIME_VERSION=${{ steps.versions.outputs.runtime }}
|
||||
RUNTIME_VERSION=${{ needs.plan.outputs.archied_version }}
|
||||
cache-from: type=gha,scope=archie-agent
|
||||
cache-to: type=gha,mode=max,scope=archie-agent
|
||||
|
||||
dist-zip:
|
||||
needs: [plan, gate, agent-image]
|
||||
if: needs.plan.outputs.archied_version != ''
|
||||
# archied-image is needed so a release never reaches the canary without it.
|
||||
needs: [plan, gate, archied-image, agent-image]
|
||||
if: needs.plan.outputs.run == 'true' && needs.plan.outputs.archied_version != ''
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
# The gate built these from the tree it checked; nothing is compiled here.
|
||||
- name: Download the release binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
name: release-binaries
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
package_json_file: ui/package.json
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Build the dashboard
|
||||
working-directory: ui
|
||||
run: |
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm run build
|
||||
- name: Unpack the release binaries
|
||||
run: tar -xf release-binaries.tar
|
||||
|
||||
- name: Resolve archied version
|
||||
id: version
|
||||
run: echo "version=${{ needs.plan.outputs.archied_version }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build linux/amd64 binaries
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: "0"
|
||||
run: |
|
||||
set -e
|
||||
ldflags="-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary -X github.com/samcharles93/archie-core/internal/buildinfo.Version=${{ steps.version.outputs.version }} -X github.com/samcharles93/archie-core/internal/buildinfo.Runtime=${{ steps.version.outputs.version }} -X github.com/samcharles93/archie-core/internal/app/agentworker.version=${{ steps.version.outputs.version }}"
|
||||
mkdir -p dist
|
||||
for cmd in $(jq -r '.required_topology.units[], .required_topology.binaries[]?' release.json); do
|
||||
go build -ldflags "$ldflags" -o "dist/$cmd" "./cmd/$cmd"
|
||||
done
|
||||
|
||||
- name: Assemble distribution zip
|
||||
id: zip
|
||||
run: |
|
||||
@@ -327,6 +304,8 @@ jobs:
|
||||
set -e
|
||||
tag="v${{ steps.version.outputs.version }}"
|
||||
version="${{ steps.version.outputs.version }}"
|
||||
prerelease=false
|
||||
case "$version" in *-*) prerelease=true ;; esac
|
||||
notes="$(mktemp)"
|
||||
awk -v hdr="## [$version]" '
|
||||
index($0, hdr) == 1 { printing = 1 }
|
||||
@@ -343,7 +322,8 @@ jobs:
|
||||
curl -sf -X DELETE -H "$auth" "$api/repos/$repo/releases/tags/$tag" >/dev/null || true
|
||||
curl -sf -X POST -H "$auth" -H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg tag "$tag" --arg name "Archie v$version" --arg body "$(cat "$notes")" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')" \
|
||||
--argjson prerelease "$prerelease" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: $prerelease}')" \
|
||||
"$api/repos/$repo/releases" >/dev/null
|
||||
echo "published release notes for $tag"
|
||||
|
||||
|
||||
@@ -21,23 +21,20 @@ jobs:
|
||||
if: vars.CANARY_URL != ''
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
|
||||
- name: Build archied
|
||||
run: go build -tags no_ui -o "$RUNNER_TEMP/archied" ./cmd/archied
|
||||
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Fetch the published archied
|
||||
# The deploy workflow already built this binary. edge is the newest
|
||||
# main that passed the gate.
|
||||
run: |
|
||||
set -e
|
||||
image=git.catlow.cloud/sam/archied:edge
|
||||
docker pull -q "$image"
|
||||
container="$(docker create "$image")"
|
||||
docker cp "$container:/usr/local/bin/archied" "$RUNNER_TEMP/archied"
|
||||
docker rm "$container" >/dev/null
|
||||
|
||||
- name: Promote the canary's release
|
||||
env:
|
||||
ARCHIE_CANARY_TOKEN: ${{ secrets.CANARY_TOKEN }}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/archied
|
||||
/archie-agent
|
||||
/bin/
|
||||
/dist/
|
||||
.task/
|
||||
*.db
|
||||
.references/
|
||||
|
||||
+23
-7
@@ -17,10 +17,22 @@ when:
|
||||
# overlapping runs would judge the same release twice.
|
||||
concurrency: 1
|
||||
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git:2.8.0
|
||||
settings:
|
||||
# A rollback compares the migrations between two release tags, so the
|
||||
# checkout needs the tags and the trees behind them.
|
||||
tags: true
|
||||
partial: false
|
||||
|
||||
steps:
|
||||
- name: judge
|
||||
image: golang:1.27.3-bookworm
|
||||
image: docker:29-cli
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
CANARY_URL:
|
||||
from_secret: canary_url
|
||||
CANARY_WINDOW:
|
||||
@@ -33,14 +45,18 @@ steps:
|
||||
- '[ -n "$$CANARY_URL" ] || { echo "repo secret canary_url is not set, so there is no canary to judge"; exit 1; }'
|
||||
- '[ -n "$$ARCHIE_CANARY_TOKEN" ] || { echo "repo secret canary_token is not set, so the canary cannot be reached"; exit 1; }'
|
||||
- '[ -n "$$DEPLOY_TOKEN" ] || { echo "repo secret deploy_token is not set, so the registry cannot be tagged"; exit 1; }'
|
||||
- go build -tags no_ui -o /tmp/archied ./cmd/archied
|
||||
# archied reads the registry credentials a docker login would have
|
||||
# written; this step has no docker CLI, so the file is written directly.
|
||||
- apk add --no-cache git
|
||||
# archied reads the registry credentials this login writes.
|
||||
- printf '%s' "$$DEPLOY_TOKEN" | docker login git.catlow.cloud -u "$$CI_REPO_OWNER" --password-stdin
|
||||
# The deploy pipeline already built this binary. edge is the newest main
|
||||
# that passed the gate.
|
||||
- |
|
||||
set -eu
|
||||
mkdir -p "$$HOME/.docker"
|
||||
auth=$(printf '%s:%s' "$$CI_REPO_OWNER" "$$DEPLOY_TOKEN" | base64 -w0)
|
||||
printf '{"auths":{"git.catlow.cloud":{"auth":"%s"}}}\n' "$$auth" > "$$HOME/.docker/config.json"
|
||||
image=git.catlow.cloud/sam/archied:edge
|
||||
docker pull -q "$$image"
|
||||
container=$(docker create "$$image")
|
||||
docker cp "$$container:/usr/local/bin/archied" /tmp/archied
|
||||
docker rm "$$container" >/dev/null
|
||||
- |
|
||||
set -eu
|
||||
set --
|
||||
|
||||
+28
-24
@@ -24,13 +24,14 @@ when:
|
||||
concurrency: 1
|
||||
|
||||
variables:
|
||||
# The gate and the distribution step both build the dashboard. Anchored here
|
||||
# rather than written twice, so the digest and the pnpm version can only
|
||||
# change in one place.
|
||||
# Only the gate builds the dashboard and the release binaries; later steps
|
||||
# reuse what it left in the workspace. The Node digest and the pnpm version
|
||||
# are pinned here.
|
||||
- &node-setup |
|
||||
set -eu
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends xz-utils
|
||||
# jq reads release.json for `task dist`.
|
||||
apt-get install -y -qq --no-install-recommends xz-utils jq
|
||||
curl -fsSL -o /tmp/node.tar.xz https://nodejs.org/dist/v24.22.2/node-v24.22.2-linux-x64.tar.xz
|
||||
echo "48cc0e21e048790e54c0cf5749c2725005313d652651c40b7a21feb9697aaf75 /tmp/node.tar.xz" | sha256sum -c -
|
||||
tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1
|
||||
@@ -81,9 +82,15 @@ steps:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /var/tmp/woodpecker-archie-gate:/var/tmp/woodpecker-archie-gate
|
||||
# Module, build and lint caches outlive the step's container; without
|
||||
# them every pipeline downloads and compiles everything from nothing.
|
||||
- /var/cache/woodpecker-archie:/cache
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
TMPDIR: /var/tmp/woodpecker-archie-gate
|
||||
GOCACHE: /cache/go-build
|
||||
GOMODCACHE: /cache/go-mod
|
||||
GOLANGCI_LINT_CACHE: /cache/golangci-lint
|
||||
commands:
|
||||
- '. "$$CI_WORKSPACE/.git/ci-plan.env"'
|
||||
- '[ "$$RUN" = true ] || { echo "a release tag owns this commit; the tag pipeline publishes it"; exit 0; }'
|
||||
@@ -104,9 +111,18 @@ steps:
|
||||
git branch main HEAD
|
||||
fi
|
||||
fi
|
||||
- task check TEST_FLAGS=-count=1
|
||||
# A release also builds the binaries it ships, in the same task run: the
|
||||
# dashboard is built once and the tree that passed is the tree that is
|
||||
# published. dist/ stays in the workspace for the steps below.
|
||||
- |
|
||||
set -eu
|
||||
if [ -n "$$RELEASE_VERSION" ]; then
|
||||
task check dist TEST_FLAGS=-count=1 VERSION="$$RELEASE_VERSION"
|
||||
else
|
||||
task check TEST_FLAGS=-count=1
|
||||
fi
|
||||
- git diff --exit-code
|
||||
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
- go install golang.org/x/vuln/cmd/govulncheck@v1.9.0
|
||||
- govulncheck ./...
|
||||
- |
|
||||
set -eu
|
||||
@@ -210,25 +226,10 @@ steps:
|
||||
- '[ -n "$$RELEASE_VERSION" ] || { echo "not a release; no distribution to build"; exit 0; }'
|
||||
- apt-get update -qq
|
||||
- apt-get install -y -qq --no-install-recommends jq zip
|
||||
- *node-setup
|
||||
# A subshell: a bare `cd ui` here would leave every later command in this
|
||||
# step building from the dashboard directory.
|
||||
# The gate built dist/ from the tree it checked; this only packages it.
|
||||
- |
|
||||
set -eu
|
||||
(
|
||||
cd ui
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm run build
|
||||
)
|
||||
- |
|
||||
set -eu
|
||||
base=github.com/samcharles93/archie-core
|
||||
ldflags="-X $${base}/internal/installtype.buildType=binary -X $${base}/internal/buildinfo.Version=$$RELEASE_VERSION -X $${base}/internal/buildinfo.Runtime=$$RELEASE_VERSION -X $${base}/internal/app/agentworker.version=$$RELEASE_VERSION"
|
||||
cmds=$(jq -r '.required_topology.units[], .required_topology.binaries[]?' release.json)
|
||||
mkdir -p dist
|
||||
for cmd in $$cmds; do
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$$ldflags" -o "dist/$$cmd" "./cmd/$$cmd"
|
||||
done
|
||||
name="archie-core-archied-v$$RELEASE_VERSION-linux-amd64"
|
||||
mkdir -p "$$name"
|
||||
for cmd in $$cmds; do
|
||||
@@ -277,7 +278,7 @@ steps:
|
||||
|
||||
- name: notes
|
||||
image: golang:1.27.3-bookworm
|
||||
depends_on: [dist]
|
||||
depends_on: [publish]
|
||||
environment:
|
||||
DEPLOY_TOKEN:
|
||||
from_secret: deploy_token
|
||||
@@ -291,6 +292,8 @@ steps:
|
||||
- |
|
||||
set -eu
|
||||
tag="v$$RELEASE_VERSION"
|
||||
prerelease=false
|
||||
case "$$RELEASE_VERSION" in *-*) prerelease=true ;; esac
|
||||
notes=$(mktemp)
|
||||
awk -v hdr="## [$$RELEASE_VERSION]" '
|
||||
index($$0, hdr) == 1 { printing = 1 }
|
||||
@@ -307,7 +310,8 @@ steps:
|
||||
curl -sf -X DELETE -H "$$auth" "$$api/repos/$$repo/releases/tags/$$tag" >/dev/null || true
|
||||
curl -sf -X POST -H "$$auth" -H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg tag "$$tag" --arg name "Archie v$$RELEASE_VERSION" --arg body "$(cat "$$notes")" \
|
||||
'{tag_name: $$tag, name: $$name, body: $$body, draft: false, prerelease: false}')" \
|
||||
--argjson prerelease "$$prerelease" \
|
||||
'{tag_name: $$tag, name: $$name, body: $$body, draft: false, prerelease: $$prerelease}')" \
|
||||
"$$api/repos/$$repo/releases" >/dev/null
|
||||
echo "published release notes for $$tag"
|
||||
# The packages exist under this repository's namespace but are not
|
||||
|
||||
@@ -12,10 +12,16 @@ when:
|
||||
|
||||
concurrency: 1
|
||||
|
||||
# Promotion reads the canary and the registry, never the repository.
|
||||
skip_clone: true
|
||||
|
||||
steps:
|
||||
- name: promote
|
||||
image: golang:1.27.3-bookworm
|
||||
image: docker:29-cli
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
CANARY_URL:
|
||||
from_secret: canary_url
|
||||
ARCHIE_CANARY_TOKEN:
|
||||
@@ -27,14 +33,17 @@ steps:
|
||||
- '[ -n "$$CANARY_URL" ] || { echo "repo secret canary_url is not set, so there is no canary to read"; exit 1; }'
|
||||
- '[ -n "$$ARCHIE_CANARY_TOKEN" ] || { echo "repo secret canary_token is not set, so the canary cannot be reached"; exit 1; }'
|
||||
- '[ -n "$$DEPLOY_TOKEN" ] || { echo "repo secret deploy_token is not set, so the registry cannot be tagged"; exit 1; }'
|
||||
- go build -tags no_ui -o /tmp/archied ./cmd/archied
|
||||
# archied reads the registry credentials a docker login would have
|
||||
# written; this step has no docker CLI, so the file is written directly.
|
||||
# archied reads the registry credentials this login writes.
|
||||
- printf '%s' "$$DEPLOY_TOKEN" | docker login git.catlow.cloud -u "$$CI_REPO_OWNER" --password-stdin
|
||||
# The deploy pipeline already built this binary. edge is the newest main
|
||||
# that passed the gate.
|
||||
- |
|
||||
set -eu
|
||||
mkdir -p "$$HOME/.docker"
|
||||
auth=$(printf '%s:%s' "$$CI_REPO_OWNER" "$$DEPLOY_TOKEN" | base64 -w0)
|
||||
printf '{"auths":{"git.catlow.cloud":{"auth":"%s"}}}\n' "$$auth" > "$$HOME/.docker/config.json"
|
||||
image=git.catlow.cloud/sam/archied:edge
|
||||
docker pull -q "$$image"
|
||||
container=$(docker create "$$image")
|
||||
docker cp "$$container:/usr/local/bin/archied" /tmp/archied
|
||||
docker rm "$$container" >/dev/null
|
||||
- >-
|
||||
/tmp/archied release canary promote -dashboard "$$CANARY_URL"
|
||||
-version "$$VERSION"
|
||||
|
||||
@@ -21,6 +21,15 @@ clone:
|
||||
steps:
|
||||
- name: check
|
||||
image: golang:1.27.3-bookworm
|
||||
# Module, build and lint caches outlive the step's container. Pull requests
|
||||
# get their own directory so they cannot write into the cache a release
|
||||
# build reads.
|
||||
volumes:
|
||||
- /var/cache/woodpecker-archie-pr:/cache
|
||||
environment:
|
||||
GOCACHE: /cache/go-build
|
||||
GOMODCACHE: /cache/go-mod
|
||||
GOLANGCI_LINT_CACHE: /cache/golangci-lint
|
||||
commands:
|
||||
- go install github.com/go-task/task/v3/cmd/task@v3.48.0
|
||||
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(cat .golangci-version)
|
||||
|
||||
@@ -36,6 +36,9 @@ steps:
|
||||
- go install github.com/go-task/task/v3/cmd/task@v3.48.0
|
||||
- git config user.name "Sam Catlow"
|
||||
- git config user.email "sam@catlow.tech"
|
||||
# `task release` only cuts from a branch named main, and the clone can
|
||||
# leave HEAD detached at main's tip.
|
||||
- git checkout -q -B main
|
||||
- task release RELEASE="$$RELEASE"
|
||||
- |
|
||||
set -eu
|
||||
|
||||
+6
-2
@@ -10,9 +10,13 @@ FROM golang:1.27-trixie AS builder
|
||||
ARG RUNTIME_VERSION=dev
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
# Cache mounts keep modules and compiled packages on the build daemon; without
|
||||
# them COPY . . makes every commit a cold compile.
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build \
|
||||
-ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=container" \
|
||||
-o /usr/local/bin/archie-agent ./cmd/archie-agent/
|
||||
|
||||
|
||||
+6
-2
@@ -12,12 +12,16 @@ RUN pnpm run build
|
||||
FROM golang:1.27-trixie AS builder
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
# Cache mounts keep modules and compiled packages on the build daemon; without
|
||||
# them COPY . . makes every commit a cold compile.
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY . .
|
||||
COPY --from=dashboard /src/ui/dist ./ui/dist
|
||||
ARG GATEWAY_VERSION=dev
|
||||
ARG RUNTIME_VERSION=dev
|
||||
RUN CGO_ENABLED=0 go build \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build \
|
||||
-ldflags "-X github.com/samcharles93/archie-core/internal/buildinfo.Version=${GATEWAY_VERSION} -X github.com/samcharles93/archie-core/internal/buildinfo.Runtime=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=container" \
|
||||
-o /usr/local/bin/archied ./cmd/archied/
|
||||
|
||||
|
||||
+5
-2
@@ -71,7 +71,9 @@ The tag push runs `deploy.yml`:
|
||||
|
||||
- **Gate.** `task check TEST_FLAGS=-count=1` (uncached, including the
|
||||
Docker-backed tests `-short` skips) and `govulncheck`, then a check that the
|
||||
tag has a `[version]` section in `CHANGELOG.md`.
|
||||
tag has a `[version]` section in `CHANGELOG.md`. On a release the same task
|
||||
run also builds the binaries the zip ships (`task dist`), so nothing is
|
||||
compiled again after the gate.
|
||||
- **Images.** `archied:v<version>` and `archie-agent:v<version>` on a release
|
||||
tag; `archied:edge` and `archied:sha-<commit>` on any other push to `main`.
|
||||
`:latest` moves only on promotion, so it names the newest promoted release.
|
||||
@@ -92,7 +94,8 @@ release rather than committing the fix on top of a tagged one.
|
||||
## The canary
|
||||
|
||||
The canary is the production host, following `next`. Every quarter hour
|
||||
`canary.yml` runs `archied release canary check`, which reads the canary
|
||||
`canary.yml` takes `archied` from the published `archied:edge` image and runs
|
||||
`release canary check`, which reads the canary
|
||||
through its dashboard API and judges **the release the canary actually runs**,
|
||||
not the moving `next` tag:
|
||||
|
||||
|
||||
@@ -101,6 +101,9 @@ tasks:
|
||||
|
||||
ui:
|
||||
desc: Build the dashboard into ui/dist, which the Go build embeds
|
||||
# check builds the dashboard and then build depends on it again; a second
|
||||
# build empties ui/dist under the Go steps that embed it.
|
||||
run: once
|
||||
dir: ui
|
||||
deps: [ui:deps]
|
||||
cmds:
|
||||
@@ -231,6 +234,10 @@ tasks:
|
||||
build:
|
||||
desc: Build archie services and agent binaries
|
||||
deps: [ui]
|
||||
# Static, like the binaries a release ships, so `dist` reuses these
|
||||
# compiled packages and only links again.
|
||||
env:
|
||||
CGO_ENABLED: "0"
|
||||
vars:
|
||||
GATEWAY_VERSION: '{{.GATEWAY_VERSION | default .VERSION}}'
|
||||
RUNTIME_VERSION: '{{.RUNTIME_VERSION | default .VERSION}}'
|
||||
@@ -264,6 +271,30 @@ tasks:
|
||||
cmd: go build -trimpath -ldflags "{{.SERVICE_LDFLAGS}}" -o {{.BIN_DIR}}/{{.ITEM}} ./cmd/{{.ITEM}}
|
||||
- go build -trimpath -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
|
||||
|
||||
dist:
|
||||
desc: Build the linux/amd64 binaries a release ships into dist/ (VERSION=1.2.3; needs jq)
|
||||
deps: [ui]
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: "0"
|
||||
vars:
|
||||
DIST_LDFLAGS: >-
|
||||
-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary
|
||||
-X github.com/samcharles93/archie-core/internal/buildinfo.Version={{.VERSION}}
|
||||
-X github.com/samcharles93/archie-core/internal/buildinfo.Runtime={{.VERSION}}
|
||||
-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.VERSION}}
|
||||
cmds:
|
||||
# release.json names what a release ships, so the zip and this build
|
||||
# cannot disagree. The compiler flags match `build`, so after the gate
|
||||
# has built bin/ this only links.
|
||||
- |
|
||||
set -eu
|
||||
mkdir -p dist
|
||||
for cmd in $(jq -r '.required_topology.units[], .required_topology.binaries[]?' release.json); do
|
||||
go build -trimpath -ldflags "{{.DIST_LDFLAGS}}" -o "dist/$cmd" "./cmd/$cmd"
|
||||
done
|
||||
|
||||
test:
|
||||
desc: Run Go tests; the release gate passes TEST_FLAGS=-count=1
|
||||
cmds:
|
||||
|
||||
Reference in new issue
Block a user