strawberry/.forgejo/workflows/release.yml
trvon f58a765033
All checks were successful
release / draft (push) Has been skipped
release / build (debian:trixie, trixie) (push) Successful in 31m13s
release / build (ubuntu:24.04, noble) (push) Successful in 26m59s
release / publish (push) Has been skipped
CI: Forgejo release workflow, test lane and runner probe
release.yml builds, tests and packs a Linux install tree per distro
(debian:trixie, ubuntu:24.04), one at a time with JOBS=2 and nice.
Branches (main, ci/**) and PRs run the test lane and print each sha256;
a v* tag uploads the tarballs and .sha256 files to a draft release and
publishes it only when every build passed.

runner-probe.yml checks that a runner with the docker label picks up
jobs, can clone this repo with the job token and reach the API.

packaging/ci/build-release.sh is the shared build step. It refuses to
run outside CI because it installs packages.

Forgejo now reads .forgejo/workflows and ignores .github/workflows,
whose ubuntu-24.04/macos-15 labels no runner here provides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 18:26:02 -07:00

101 lines
4 KiB
YAML

# Linux release builds for the Salt Security Hub rollout.
#
# Test lane: push to main or ci/**, pull requests, or manual run -> build + test + pack per
# distro; prints each tarball's sha256. Nothing is uploaded.
# Release lane: push a tag v* -> the same, then a draft release gets every tarball and its
# .sha256, and is published only if all builds passed.
#
# The sha256 values are copied into the hub pillar by hand; Salt installs only files that
# match them, so this workflow is not the trust anchor.
#
# Forgejo reads .forgejo/workflows and then ignores .github/workflows; GitHub keeps build.yml.
# Builds run one at a time (max-parallel: 1) with JOBS=2 and nice so the runner host stays usable.
name: release
on:
workflow_dispatch:
push:
branches: [main, "ci/**"]
tags: ["v*"]
pull_request:
jobs:
draft:
if: github.ref_type == 'tag'
runs-on: docker
container:
image: debian:trixie
outputs:
id: ${{ steps.create.outputs.id }}
steps:
- name: Create draft release
id: create
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }}
run: |
apt-get update -q && apt-get install -y -q --no-install-recommends curl ca-certificates python3 >/dev/null
body=$(python3 -c 'import json,os; t=os.environ["GITHUB_REF_NAME"]; print(json.dumps({"tag_name": t, "name": t, "draft": True, "body": "Linux install trees for the Security Hub canary. Verify the .sha256 files."}))')
curl -sf -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d "$body" "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" > release.json
id=$(python3 -c 'import json; print(json.load(open("release.json"))["id"])')
echo "draft release id=$id"; echo "id=$id" >> "$GITHUB_OUTPUT"
build:
needs: [draft]
# Run on branches (draft skipped) and on tags (draft succeeded).
if: ${{ !failure() && !cancelled() }}
runs-on: docker
strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- os: trixie
image: debian:trixie
- os: noble
image: ubuntu:24.04
container:
image: ${{ matrix.image }}
env:
CI: "true"
JOBS: "2"
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
apt-get update -q && apt-get install -y -q --no-install-recommends git ca-certificates >/dev/null
git init -q . && git -c http.extraHeader="Authorization: token $TOKEN" fetch -q --depth 50 --tags \
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" "$GITHUB_SHA"
git checkout -q FETCH_HEAD
git log -1 --format='building %H %s'
- name: Build, test, pack
run: bash packaging/ci/build-release.sh ${{ matrix.os }} dist
- name: Upload to draft release
if: github.ref_type == 'tag'
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }}
RELEASE_ID: ${{ needs.draft.outputs.id }}
run: |
for f in dist/*; do
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$(basename "$f")" >/dev/null
echo "uploaded $(basename "$f")"
done
publish:
needs: [draft, build]
if: github.ref_type == 'tag'
runs-on: docker
container:
image: debian:trixie
steps:
- name: Publish release
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }}
RELEASE_ID: ${{ needs.draft.outputs.id }}
run: |
apt-get update -q && apt-get install -y -q --no-install-recommends curl ca-certificates >/dev/null
curl -sf -X PATCH -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d '{"draft": false}' "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID" >/dev/null
echo "published release $RELEASE_ID"