Files
CommandForge/.gitea/workflows/release.yml
T
poli0981andClaude Opus 5.5 d39f188ea6 ci(release): Velopack to Cloudflare R2, CycloneDX SBOM, SHA256SUMS, Gitea release
GitHub Releases is gone. A v* tag now builds and packs on the Windows runner
as before (scripts/pack.ps1), then `vpk upload s3` puts the packages and the
feed on R2 (releases.poli0981.dev/commandforge, feed last), the ops
publish-r2.yml adds <version>/SHA256SUMS and the SBOM, a Gitea release gets
the notes and the links (no binaries), and the ops announcer posts to
Discord. R2 credentials stay in VPK_* environment variables of this
tag/dispatch-only workflow.

scripts/release-assets.ps1 (also runs locally) writes the CycloneDX SBOM
(CycloneDX tool 6.3.2, replacing GitHub's dependency-graph SBOM, decision
D7), SHA256SUMS of the files this version ships, and the notes from
CHANGELOG.md. The feed files are no longer hashed: vpk rewrites them on
upload, which is what made checksums.txt wrong for RELEASES and
releases.win.json in 2.1.0 and 2.2.0.

A manual run on a branch is a dry run: it builds, packs, reads the previous
release from R2 and keeps the files as an artifact, but uploads nothing.
Attestations go (no OIDC on Gitea). VirusTotal stays optional.

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

236 lines
11 KiB
YAML

name: Release
# A signed `vX.Y.Z` tag on main releases CommandForge (RELEASING.md; ops runbook §3.3 and §5.1):
#
# build publish + Velopack pack (scripts/pack.ps1) on the maintainer's PC (host mode), the
# CycloneDX SBOM, SHA256SUMS and the release notes (scripts/release-assets.ps1), an
# optional VirusTotal scan, then `vpk upload s3` to Cloudflare R2: packages first, the
# feed (releases.win.json) last, so a client never sees a feed whose files are missing.
# Installed copies (2.3.0 and later) update from https://releases.poli0981.dev/commandforge.
# publish the ops repo's publish-r2.yml puts SHA256SUMS and the SBOM under <version>/.
# release a Gitea release with the notes and the links (no binaries: the forge's disk is not for
# them, runbook §1).
# announce Discord, through the ops repo's announce-release.yml: a release made with the job
# token fires no `release` event, so announce-release.yml would never run by itself.
#
# Manual run (Actions → Release → Run workflow) on a branch is a DRY RUN: it builds, packs, writes
# the SBOM/checksums/notes from <Version> in Directory.Build.props, and reads the previous release
# from R2 (a check of the R2 credentials), but uploads nothing; the files stay as the `r2-release`
# artifact. Uploads, the release and the announcement happen only for a `v*` tag. A file uploaded
# under a versioned name is never replaced: to ship a fix, bump the version.
#
# Release credentials (user-level secrets R2_RELEASES_ACCESS_KEY_ID / _SECRET_ACCESS_KEY, variable
# R2_ACCOUNT_ID) exist only in steps of this tag/dispatch-only workflow (runbook §2 rule 10), as VPK_*
# environment variables, never on a command line. Optional repository secret VT_API_KEY turns on
# the VirusTotal scan. No dependency caches: a poisoned cache could end up inside the installer.
# No code signing yet (SECURITY.md), no build-provenance attestations (no OIDC on Gitea, D7).
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release
cancel-in-progress: false
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build:
name: Build, pack and upload to R2
runs-on: windows-latest # host mode on the maintainer's PC (PowerShell)
timeout-minutes: 60
permissions:
contents: read
outputs:
version: ${{ steps.ver.outputs.version }}
env:
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }}
# Velopack's S3 options (vpk reads VPK_<OPTION>): bucket poli0981-releases, folder commandforge/
VPK_BUCKET: poli0981-releases
VPK_PREFIX: commandforge/
VPK_ENDPOINT: https://${{ vars.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Keep .NET SDK installs in the runner tool cache (host mode)
shell: pwsh
run: |
$base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' }
"DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
# A tag must name the version Directory.Build.props carries (the release commit sets both).
- name: Resolve the version
id: ver
shell: pwsh
env:
REF_NAME: ${{ github.ref_name }}
R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }}
run: |
function Fail([string]$msg) { Write-Host "::error::$msg"; exit 1 }
$props = "$(dotnet msbuild src/CommandForge.Domain/CommandForge.Domain.csproj -getProperty:Version | Select-Object -Last 1)".Trim()
if ($LASTEXITCODE -ne 0 -or $props -notmatch '^\d+\.\d+\.\d+$') { Fail "Unexpected <Version> '$props' in Directory.Build.props" }
if ($env:IS_TAG -eq 'true') {
$version = $env:REF_NAME -replace '^v', ''
if ($version -ne $props) { Fail "Tag $($env:REF_NAME) does not match <Version> $props in Directory.Build.props" }
} else {
$version = $props
Write-Host "::notice::Dry run on $($env:REF_NAME): builds $version, uploads nothing."
}
if ($env:R2_ACCOUNT_ID -notmatch '^[0-9a-f]{32}$') { Fail 'Actions variable R2_ACCOUNT_ID is missing or not a 32-hex Cloudflare account ID' }
"version=$version" >> $env:GITHUB_OUTPUT
Write-Host "Releasing CommandForge $version"
- name: Restore pinned tools (vpk, CycloneDX)
run: dotnet tool restore
# The previous release, so vpk can build a delta package. Nothing to find before the first
# release on R2 (2.3.0): the step then fails and the job goes on.
- name: Download the previous release from R2
continue-on-error: true
shell: pwsh
env:
VPK_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
VPK_SECRET: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: |
dotnet vpk download s3 --channel win --outputDir Releases
exit $LASTEXITCODE
- name: Publish + pack (Velopack)
shell: pwsh
env:
VERSION: ${{ steps.ver.outputs.version }}
run: ./scripts/pack.ps1 -Version $env:VERSION
# A step's own env is not visible to its `if:`, so a step of its own looks for the key.
- name: Look for VT_API_KEY
id: vtkey
shell: pwsh
env:
VT_API_KEY: ${{ secrets.VT_API_KEY }}
run: |
"available=$(if ($env:VT_API_KEY) { 'true' } else { 'false' })" >> $env:GITHUB_OUTPUT
- name: VirusTotal scan (optional)
id: vt
if: ${{ env.IS_TAG == 'true' && steps.vtkey.outputs.available == 'true' }}
uses: crazy-max/ghaction-virustotal@936d8c5c00afe97d3d9a1af26d017cfdf26800a2 # v5.0.0
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
files: |
Releases/CommandForge-win-Setup.exe
Releases/CommandForge-${{ steps.ver.outputs.version }}-full.nupkg
- name: SBOM, SHA256SUMS and release notes
shell: pwsh
env:
VERSION: ${{ steps.ver.outputs.version }}
VT_ANALYSIS: ${{ steps.vt.outputs.analysis }}
run: ./scripts/release-assets.ps1 -Version $env:VERSION -VirusTotalAnalysis "$env:VT_ANALYSIS"
# vpk uploads the packages, the installer and the portable zip first and the feed last, and
# keeps the 10 newest releases in the feed folder (the only deletion CI does, runbook §3.3).
# Should R2 refuse the AWS SDK's default checksums, the upload is tried once more with
# --disableChecksumValidation, and the log says so.
- name: Upload to R2 (Velopack)
if: ${{ env.IS_TAG == 'true' }}
shell: pwsh
env:
VPK_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
VPK_SECRET: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: |
dotnet vpk upload s3 --channel win --outputDir Releases --keepMaxReleases 10
if ($LASTEXITCODE -ne 0) {
Write-Host '::warning::vpk upload s3 failed; trying once more with --disableChecksumValidation'
dotnet vpk upload s3 --channel win --outputDir Releases --keepMaxReleases 10 --disableChecksumValidation
}
exit $LASTEXITCODE
- name: Smoke test the public files
if: ${{ env.IS_TAG == 'true' }}
shell: pwsh
env:
VERSION: ${{ steps.ver.outputs.version }}
run: |
$base = 'https://releases.poli0981.dev/commandforge'
foreach ($name in 'releases.win.json', 'CommandForge-win-Setup.exe', 'CommandForge-win-Portable.zip', "CommandForge-$($env:VERSION)-full.nupkg") {
$code = curl.exe -sS -o NUL -I -w '%{http_code}' --retry 3 --retry-all-errors "$base/$name"
Write-Host "HEAD $base/$name -> $code"
if ($code -ne '200') { Write-Host "::error::Not reachable after upload: $base/$name"; exit 1 }
}
$feed = curl.exe -fsS --retry 3 "$base/releases.win.json" | ConvertFrom-Json
if (-not ($feed.Assets | Where-Object { $_.Version -eq $env:VERSION })) { Write-Host "::error::releases.win.json does not list $($env:VERSION)"; exit 1 }
- name: Keep the release files
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: r2-release
path: r2-release/
if-no-files-found: error
retention-days: 7
publish:
name: SHA256SUMS and SBOM to R2
needs: build
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
permissions:
contents: read
uses: poli0981/.github/.gitea/workflows/publish-r2.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4
with:
app: commandforge
artifact: r2-release
versioned-dir: versioned # versioned/2.3.0/SHA256SUMS → commandforge/2.3.0/SHA256SUMS
runs-on: ubuntu-latest
secrets:
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
release:
name: Gitea release (notes + links)
needs: [build, publish]
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # which of contents / releases Gitea enforces is unverified (runbook §3.2 item 5)
releases: write
steps:
- name: Download the release files
uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4
with:
name: r2-release
path: r2-release
- name: Create the release
uses: https://gitea.com/actions/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac # v1.3.7
with:
tag_name: ${{ github.ref_name }}
name: CommandForge ${{ needs.build.outputs.version }}
body_path: r2-release/release-notes.md
announce:
needs: release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
permissions:
contents: read
uses: poli0981/.github/.gitea/workflows/announce-release.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4
with:
tag_override: ${{ github.ref_name }}
ops_ref: c133a00dc7a0bd7bd68253d415758b408d615fa4
secrets:
DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }}
DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }}
DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }}