Files
Echoion/.gitea/workflows/release.yml
T
faumaray 697db046d3
Modular container CI / release-build (push) Has been cancelled
Release: harden multiline secret handling
2026-07-30 03:58:21 +03:00

225 lines
8.1 KiB
YAML

name: Signed modular release
on:
push:
tags:
- v*
permissions:
contents: read
concurrency:
group: echoion-release-feed
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-24.04
steps:
- name: Verify the Docker-capable Gitea runner
shell: bash
run: |
set -euo pipefail
test "$(uname -s)" = Linux
command -v docker
docker version
docker info
- name: Check out the public signed root tag
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ gitea.ref }}
fetch-depth: 0
persist-credentials: false
- name: Reject embedded component sources and gitlinks
shell: bash
run: |
set -euo pipefail
test ! -e .gitmodules
if git ls-files -s | awk '$1 == "160000" { found=1 } END { exit !found }'
then
echo "root release contains a gitlink" >&2
exit 1
fi
python3 - <<'PY'
import json
import pathlib
components = json.loads(pathlib.Path("components.json").read_text())
embedded = [
name for name in components["components"]
if pathlib.Path(name).exists()
]
if embedded:
raise SystemExit(f"embedded component sources: {embedded}")
PY
- name: Check out every locked component and dependency over SSH
shell: bash
env:
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
run: >-
scripts/ci-checkout-components.sh
"$PWD/components"
"$PWD/dependencies"
- name: Verify protected annotated SSH tag and release lock
shell: bash
env:
TAG: ${{ gitea.ref_name }}
EXPECTED_EVENT_SHA: ${{ gitea.sha }}
EXPECTED_REF: ${{ gitea.ref }}
EXPECTED_REF_TYPE: ${{ gitea.ref_type }}
TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
test "$EXPECTED_REF_TYPE" = tag
test "$EXPECTED_REF" = "refs/tags/$TAG"
allowed_signers="$RUNNER_TEMP/echoion-release-allowed-signers"
tag_credentials="$RUNNER_TEMP/echoion-release-tag-ssh"
trap 'rm -rf -- "$tag_credentials"; rm -f -- "$allowed_signers"' EXIT
umask 077
printf '%s\n' "$TAG_ALLOWED_SIGNERS" >"$allowed_signers"
test -s "$allowed_signers"
. scripts/lib/component-ssh.sh
echoion_configure_component_ssh \
"$tag_credentials" "$ECHOION_COMPONENT_SSH_KEY"
scripts/restore-gitea-release-tag.sh \
--repository "ssh://gitea@git.faumaray.ru/$REPOSITORY.git" \
--tag "$TAG"
target_commit=$(
scripts/verify-gitea-release-tag.sh \
--tag "$TAG" \
--event-sha "$EXPECTED_EVENT_SHA" \
--allowed-signers "$allowed_signers" \
--notes-output "$RUNNER_TEMP/release-notes.md"
)
printf 'RELEASE_TARGET=%s\n' "$target_commit" >>"$GITHUB_ENV"
scripts/prepare-release.sh \
--workspace "$PWD/components" \
--check
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
verify-tag-protection \
--owner "$owner" \
--repo "$repo" \
--required-pattern 'v*'
- name: Derive release channel and URLs
shell: bash
env:
TAG: ${{ gitea.ref_name }}
API_URL: ${{ gitea.api_url }}
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
RUN_NUMBER: ${{ gitea.run_number }}
run: |
set -euo pipefail
version=${TAG#v}
test "$version" != "$TAG"
python3 scripts/validate-semver.py "$version"
project_version=$(
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
cmake-project-version \
--cmake-file CMakeLists.txt
)
tag_base=${version%%[-+]*}
test "$tag_base" = "$project_version"
channel=stable
prerelease=false
if [[ "$version" == *-* ]]; then
channel=beta
prerelease=true
fi
feed_url="${SERVER_URL}/${REPOSITORY}/raw/branch/release-feed/feeds/${channel}/catalog.json"
artifact_url="${SERVER_URL}/${REPOSITORY}/releases/download/${TAG}"
{
printf 'RELEASE_TAG=%s\n' "$TAG"
printf 'RELEASE_VERSION=%s\n' "$version"
printf 'RELEASE_CHANNEL=%s\n' "$channel"
printf 'RELEASE_PRERELEASE=%s\n' "$prerelease"
printf 'RELEASE_SEQUENCE=%s\n' "$RUN_NUMBER"
printf 'RELEASE_ARTIFACT_BASE_URL=%s\n' "$artifact_url"
printf 'RELEASE_FEED_URL=%s\n' "$feed_url"
} >>"$GITHUB_ENV"
- name: Check out the protected release-feed branch
shell: bash
env:
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
run: |
set -euo pipefail
feed_credentials="$RUNNER_TEMP/echoion-release-feed-ssh"
trap 'rm -rf -- "$feed_credentials"' EXIT
. scripts/lib/component-ssh.sh
echoion_configure_component_ssh \
"$feed_credentials" "$ECHOION_COMPONENT_SSH_KEY"
git clone --filter=blob:none --branch release-feed --single-branch \
ssh://gitea@git.faumaray.ru/Void/Echoion.git feed-state
- name: Verify every locked component was independently published
shell: bash
env:
FEED_PUBLIC_KEY: ${{ secrets.RELEASE_FEED_ED25519_PUBLIC_KEY }}
run: |
set -euo pipefail
feed_key="$RUNNER_TEMP/echoion-feed-ed25519.pub.pem"
trap 'rm -f -- "$feed_key"' EXIT
printf '%s\n' "$FEED_PUBLIC_KEY" >"$feed_key"
chmod 0644 "$feed_key"
openssl pkey -pubin -in "$feed_key" -noout
python3 scripts/verify-locked-component-feeds.py \
--registry components.json \
--lock components.lock.json \
--feed-root feed-state \
--channel "$RELEASE_CHANNEL" \
--key-id "${{ vars.ECHOION_FEED_SIGNING_KEY_ID }}" \
--public-key "$feed_key"
- name: Build, test, and package all locked repositories in Docker
shell: bash
run: |
set -euo pipefail
scripts/release.sh \
--version "$RELEASE_VERSION" \
--skip-component-packages \
--component-workspace "$PWD/components" \
--void-source "$PWD/dependencies/VoidLibrary" \
--void-teamspeak-source "$PWD/dependencies/VoidTeamspeak" \
--official-update-feed-url "$RELEASE_FEED_URL" \
--update-channel "$RELEASE_CHANNEL" \
--update-sequence "$RELEASE_SEQUENCE"
- name: Create draft, upload, download-verify, and publish
shell: bash
env:
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
prerelease=()
if [[ "$RELEASE_PRERELEASE" = true ]]; then
prerelease+=(--prerelease)
fi
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
publish \
--owner "$owner" \
--repo "$repo" \
--tag "$RELEASE_TAG" \
--target "$RELEASE_TARGET" \
--name "Echoion $RELEASE_VERSION" \
--body-file "$RUNNER_TEMP/release-notes.md" \
--artifacts dist \
"${prerelease[@]}"