2026-06-23 23:25:10 +03:00
|
|
|
# Forgejo build + release for anwesen ([ANW-30]).
|
|
|
|
|
#
|
|
|
|
|
# The operator's Forgejo forge is the primary home (the GitHub mirror's
|
|
|
|
|
# release.yml under .github/ is the secondary). This workflow is the
|
|
|
|
|
# Forgejo-side counterpart: it builds the release binaries for both targets
|
|
|
|
|
# and publishes them to a Forgejo release.
|
|
|
|
|
#
|
|
|
|
|
# Unlike the GitHub workflow it is NOT driven by a release-published event.
|
|
|
|
|
# It runs on demand -- from the Forgejo UI ("Run workflow") or via the API:
|
|
|
|
|
#
|
|
|
|
|
# POST /api/v1/repos/{owner}/{repo}/actions/workflows/build.yml/dispatches
|
|
|
|
|
#
|
|
|
|
|
# so a build can be triggered for a test without first cutting a release.
|
|
|
|
|
# The `tag` input names the release the assets attach to; `prerelease`
|
|
|
|
|
# defaults true so test runs land as a replaceable prerelease rather than a
|
|
|
|
|
# stable release. forgejo-release creates the release (from the checked-out
|
|
|
|
|
# sha) if it does not exist, and `override: true` lets a re-run replace the
|
|
|
|
|
# assets.
|
2026-06-24 00:07:27 +03:00
|
|
|
#
|
|
|
|
|
# Runner topology. There is one self-hosted runner registered `linux-amd64`
|
|
|
|
|
# with `:host` execution -- jobs run directly on the host, not in a
|
|
|
|
|
# container. The host already provides node, git, rustup/cargo, hurl, and the
|
|
|
|
|
# aarch64 cross linker, so the workflow uses them in place rather than
|
|
|
|
|
# installing anything (the host user has no passwordless sudo). Both targets
|
|
|
|
|
# build on this one amd64 host: x86_64 natively, aarch64 by cross-compilation.
|
2026-06-23 23:25:10 +03:00
|
|
|
name: build
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
inputs:
|
|
|
|
|
tag:
|
|
|
|
|
description: Release tag the binaries attach to (created if absent).
|
|
|
|
|
required: true
|
|
|
|
|
default: nightly
|
|
|
|
|
prerelease:
|
|
|
|
|
description: Mark the release as a prerelease.
|
|
|
|
|
type: boolean
|
|
|
|
|
default: true
|
|
|
|
|
|
|
|
|
|
# forgejo-release uploads assets to a release in this repository.
|
|
|
|
|
permissions:
|
|
|
|
|
contents: write
|
|
|
|
|
|
|
|
|
|
jobs:
|
2026-06-24 00:07:27 +03:00
|
|
|
# Single test gate for both targets. The suite and the HTTP contract
|
|
|
|
|
# harness are architecture-independent, so they run once, natively on the
|
|
|
|
|
# amd64 host. Both build jobs depend on this, so a release never ships a
|
|
|
|
|
# red build.
|
|
|
|
|
test:
|
|
|
|
|
name: test
|
|
|
|
|
runs-on: linux-amd64
|
|
|
|
|
steps:
|
|
|
|
|
- name: Check out the workflow ref
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
# The :host runner runs each step in a non-login shell that does not
|
|
|
|
|
# source ~/.cargo/env, so rustup/cargo are not on PATH. Source it in
|
|
|
|
|
# each step that needs the toolchain -- self-contained, no reliance on
|
|
|
|
|
# GITHUB_PATH propagating across steps.
|
|
|
|
|
- name: Run the Rust test suite
|
|
|
|
|
run: |
|
|
|
|
|
source "$HOME/.cargo/env"
|
|
|
|
|
cargo test --locked
|
|
|
|
|
|
|
|
|
|
# The HTTP contract harness (tests/run-hurl.sh, per ADR-008) boots
|
|
|
|
|
# `anwesen serve` and runs hurl against it -- headless, so it runs in CI.
|
|
|
|
|
# hurl is on the host PATH; the harness builds anwesen, so cargo too.
|
|
|
|
|
- name: Run the HTTP contract tests
|
|
|
|
|
run: |
|
|
|
|
|
source "$HOME/.cargo/env"
|
|
|
|
|
tests/run-hurl.sh
|
|
|
|
|
|
2026-06-23 23:25:10 +03:00
|
|
|
build:
|
|
|
|
|
name: ${{ matrix.label }}
|
2026-06-24 00:07:27 +03:00
|
|
|
needs: test
|
|
|
|
|
runs-on: linux-amd64
|
2026-06-23 23:25:10 +03:00
|
|
|
strategy:
|
|
|
|
|
# One target's failure should not cancel the other's build.
|
|
|
|
|
fail-fast: false
|
|
|
|
|
matrix:
|
|
|
|
|
include:
|
2026-06-24 00:07:27 +03:00
|
|
|
# amd64 Linux -- the deploy target. Built natively for the host.
|
|
|
|
|
- target: x86_64-unknown-linux-gnu
|
2026-06-23 23:25:10 +03:00
|
|
|
label: x86_64-linux
|
2026-06-24 00:07:27 +03:00
|
|
|
# arm64 Linux -- cross-compiled on the same amd64 host. cross-rs
|
|
|
|
|
# would need a container engine the host runner does not provide
|
|
|
|
|
# (and cannot target apple-darwin from Linux anyway), so this uses
|
|
|
|
|
# the rustup target plus the host's aarch64-linux-gnu-gcc linker.
|
|
|
|
|
- target: aarch64-unknown-linux-gnu
|
|
|
|
|
label: aarch64-linux
|
|
|
|
|
env:
|
|
|
|
|
# cargo picks the linker for the aarch64 target from this; the host
|
|
|
|
|
# already provides aarch64-linux-gnu-gcc. Harmless for the amd64 target.
|
|
|
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
2026-06-23 23:25:10 +03:00
|
|
|
steps:
|
|
|
|
|
- name: Check out the workflow ref
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
2026-06-24 00:07:27 +03:00
|
|
|
# See the test job: source the host toolchain in each step rather than
|
|
|
|
|
# rely on GITHUB_PATH. The host toolchain is rustup-managed; ensure the
|
|
|
|
|
# cross target's std is present (idempotent for the native target).
|
|
|
|
|
- name: Add the Rust target
|
2026-06-23 23:25:10 +03:00
|
|
|
run: |
|
2026-06-24 00:07:27 +03:00
|
|
|
source "$HOME/.cargo/env"
|
|
|
|
|
rustup target add ${{ matrix.target }}
|
2026-06-23 23:25:10 +03:00
|
|
|
|
|
|
|
|
- name: Build the release binary
|
2026-06-24 00:07:27 +03:00
|
|
|
run: |
|
|
|
|
|
source "$HOME/.cargo/env"
|
|
|
|
|
cargo build --release --locked --target ${{ matrix.target }}
|
2026-06-23 23:25:10 +03:00
|
|
|
|
2026-06-24 00:07:27 +03:00
|
|
|
# forgejo-release uploads everything under the release dir, so the
|
|
|
|
|
# staged name is the asset name -- make the target explicit. The tag
|
|
|
|
|
# goes through env, not direct interpolation into the run body.
|
2026-06-23 23:25:10 +03:00
|
|
|
- name: Stage the asset for its target
|
2026-06-24 00:07:27 +03:00
|
|
|
env:
|
|
|
|
|
TAG: ${{ inputs.tag }}
|
2026-06-23 23:25:10 +03:00
|
|
|
run: |
|
|
|
|
|
mkdir -p dist/release
|
2026-06-24 00:07:27 +03:00
|
|
|
install -m 0755 "target/${{ matrix.target }}/release/anwesen" \
|
|
|
|
|
"dist/release/anwesen-${TAG}-${{ matrix.label }}"
|
2026-06-23 23:25:10 +03:00
|
|
|
|
|
|
|
|
- name: Publish the binary to the Forgejo release
|
|
|
|
|
uses: https://code.forgejo.org/actions/forgejo-release@v2
|
|
|
|
|
with:
|
|
|
|
|
direction: upload
|
|
|
|
|
url: ${{ env.GITHUB_SERVER_URL }}
|
|
|
|
|
repo: ${{ github.repository }}
|
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
tag: ${{ inputs.tag }}
|
|
|
|
|
sha: ${{ github.sha }}
|
|
|
|
|
release-dir: dist/release
|
|
|
|
|
prerelease: ${{ inputs.prerelease }}
|
|
|
|
|
# A re-run for the same tag replaces the assets rather than failing.
|
|
|
|
|
override: true
|