Files
ExecuteR/.gitea/workflows/release.yml
T
Alphaeus Mote d0bb160537 build: commit the product icon, generated without ImageMagick
scripts/Generate-Icons.ps1 now renders assets/icons/app.ico from
assets/icon-source.png with System.Drawing (no installs, Windows PowerShell
or pwsh, byte-identical across runs): 16, 20, 24, 32, 40, 48, 64 and 128 px
as 32-bit DIBs and 256 px PNG-compressed (124 KB, was 370 KB with six
uncompressed frames).

The .ico is committed and every build embeds it, so local builds match CI.
The packaging scripts and workflows no longer generate it at build time
(the ImageMagick step wrote artifacts/icons/app.ico, which nothing read):
-SkipIcon and the release "Generate icon" step are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 13:53:42 -05:00

246 lines
10 KiB
YAML

name: Release
# README, Versioning. A push to main releases when the conventional commits
# since the last release tag vX.Y.Z call for one: semantic-release (dry run,
# scripts/Get-NextRelease.ps1) bumps the patch for fix/perf, the minor for
# feat and the major for a BREAKING CHANGE footer or "type!:". Only docs,
# tests, chores, refactors... release nothing: the run stops after numbering
# (no tag, no release, no images; CI's X.Y.Z.N build and images stand).
#
# A release builds every binary as X.Y.Z, then scripts/Publish-Release.ps1
# creates the tag vX.Y.Z on the commit and the Gitea release with the notes,
# and the images job publishes the backend and webui images as X.Y.Z and
# latest (CI skips its images for a release commit and builds it as X.Y.Z
# too, so both workflows agree on its version). A re-run of a released commit
# publishes the same version again (missing assets only).
#
# Docs-only merges skip the run the same way CI skips docs-only commits.
on:
push:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'scripts/**'
- 'assets/**'
- 'build/**'
- '.gitea/workflows/**'
- 'ExecuteR.slnx'
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'global.json'
- 'dotnet-tools.json'
workflow_dispatch:
# One release at a time: a second push waits for the first to tag its commit,
# so it numbers after it.
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
# Publishes the self-contained agent for every platform, the MSIs, the
# combined standalone server (win/linux) and checksums, then tags the
# commit and attaches them to the Gitea release.
# Label must match a registered runner: windows-host.
runs-on: windows-host
outputs:
version: ${{ steps.next.outputs.version }}
short: ${{ steps.next.outputs.short }}
steps:
# SHA-256 repo: plain git clone (actions/checkout inits SHA-1 and
# cannot fetch from a SHA-256 server). The whole history and its tags:
# semantic-release reads the commits since the last release tag.
- name: Checkout
shell: pwsh
env:
CHECKOUT_TOKEN: ${{ github.token }}
run: |
$ErrorActionPreference = 'Stop'
Get-ChildItem -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
$url = '${{ github.server_url }}/${{ github.repository }}.git' -replace '^https://', "https://x-access-token:$env:CHECKOUT_TOKEN@"
git clone --single-branch --branch '${{ github.ref_name }}' $url .
git log -1 --format='%H %s'
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Setup Node
uses: actions/setup-node@v4
with:
# semantic-release needs Node >= 20.8.1; @nats-io/* (WebUI) >= 22.
node-version: '22'
# Nothing to release leaves version empty and every later step skips.
- name: Next release
id: next
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$next = ./scripts/Get-NextRelease.ps1 -NotesPath artifacts/release-notes.md
if ($next) {
$short = ./scripts/Get-Version.ps1 -Version $next.Version -Format Short
"version=$($next.Version)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"short=$short" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
$global:LASTEXITCODE = 0
# The Remote View screen host (Rust, ExecuteR-Screen.exe) goes beside the
# agent in the win-x64 zip (also Windows PE's package) and the MSI; Package-Agent
# builds it. Skips itself while src/ScreenHost is not in the tree.
- name: Install Rust (screen host)
if: ${{ steps.next.outputs.version != '' }}
shell: pwsh
run: ./scripts/Install-Rust.ps1
- name: Package agent (all platforms + MSI + checksums)
if: ${{ steps.next.outputs.version != '' }}
shell: pwsh
run: |
./scripts/Package-Agent.ps1 -Version ${{ steps.next.outputs.version }} `
-Runtimes win-x64,win-arm64,linux-x64,linux-arm64,osx-x64,osx-arm64
# The installers the backend image serves (see the images job).
$stage = 'artifacts/agent-package'
New-Item -ItemType Directory -Force $stage | Out-Null
$msi = "artifacts/ExecuteR-Agent-${{ steps.next.outputs.version }}.msi"
$zip = "artifacts/ExecuteR-Agent-${{ steps.next.outputs.version }}-win-x64.zip"
if (Test-Path $msi) { Copy-Item $msi "$stage/Agent.msi" }
if (Test-Path $zip) { Copy-Item $zip "$stage/Agent.zip" }
foreach ($rid in 'linux-x64','linux-arm64','osx-x64','osx-arm64') {
$unix = "artifacts/ExecuteR-Agent-${{ steps.next.outputs.version }}-$rid.zip"
if (Test-Path $unix) { Copy-Item $unix "$stage/Agent-$rid.zip" }
}
'${{ steps.next.outputs.version }}' | Set-Content "$stage/VERSION" -NoNewline
- name: Package server (win-x64 + linux-x64)
if: ${{ steps.next.outputs.version != '' }}
shell: pwsh
run: ./scripts/Package-Server.ps1 -Version ${{ steps.next.outputs.version }}
- name: Upload agent package
if: ${{ steps.next.outputs.version != '' }}
uses: actions/upload-artifact@v3
with:
name: agent-package
path: artifacts/agent-package/
retention-days: 7
- name: Tag, create the Gitea release and upload assets
if: ${{ steps.next.outputs.version != '' }}
shell: pwsh
env:
# GITEA_TOKEN is injected automatically by Gitea Actions; SERVER_URL
# is seeded by scripts/Initialize-GiteaSecrets.ps1 and falls back to
# the instance URL the runner already knows.
GITEA_URL: ${{ vars.SERVER_URL || github.server_url }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_OWNER: ${{ github.repository_owner }}
GITEA_REPOSITORY: ${{ github.event.repository.name }}
run: |
$notes = if (Test-Path artifacts/release-notes.md) { 'artifacts/release-notes.md' } else { '' }
./scripts/Publish-Release.ps1 -Version ${{ steps.next.outputs.version }} -NotesFile $notes -Commit "$(git rev-parse HEAD)"
images:
# The release's backend + webui images, tagged X.Y.Z and latest, in the
# Gitea container registry (the same names CI publishes and
# docker-compose.yml pulls). Only once the release is published.
needs: release
if: ${{ needs.release.outputs.version != '' }}
runs-on: ubuntu-host
env:
# Gitea's built-in registry by default; REGISTRY_* override it with an
# external one (see ci.yml).
REGISTRY_HOST: ${{ secrets.REGISTRY_HOST }}
REGISTRY_USER: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASS: ${{ secrets.REGISTRY_PASSWORD }}
SERVER_URL: ${{ github.server_url }}
ACTOR: ${{ github.actor }}
BUILTIN_TOKEN: ${{ secrets.GITEA_TOKEN }}
OWNER: ${{ github.repository_owner }}
steps:
# SHA-256 repo: plain git clone (see the release job). The image build
# takes its version from the release job, not from git.
- name: Checkout
shell: bash
env:
CHECKOUT_TOKEN: ${{ github.token }}
run: |
set -e
find . -mindepth 1 -maxdepth 1 -exec rm -rf {} + 2>/dev/null || true
URL="$(echo '${{ github.server_url }}/${{ github.repository }}.git' | sed "s#^https://#https://x-access-token:${CHECKOUT_TOKEN}@#")"
git clone --depth 1 --branch '${{ github.ref_name }}' "$URL" .
git log -1 --format='%H %s'
- name: Resolve registry target
id: reg
shell: bash
run: |
set -e
if [ -n "$REGISTRY_HOST" ]; then
HOST="$REGISTRY_HOST"; USER="$REGISTRY_USER"; PASS="$REGISTRY_PASS"
echo "Using external registry $HOST"
else
HOST="$(echo "$SERVER_URL" | sed -E 's#^https?://##; s#/$##')"
USER="$ACTOR"; PASS="$BUILTIN_TOKEN"
echo "Using the built-in Gitea registry at $HOST"
fi
OWNER_LC="$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')"
{
echo "host=$HOST"
echo "user=$USER"
echo "prefix=${HOST}/${OWNER_LC}/executer"
} >> "$GITHUB_OUTPUT"
echo "::add-mask::$PASS"
echo "REGISTRY_LOGIN_PASSWORD=$PASS" >> "$GITHUB_ENV"
- name: Registry login
run: echo "$REGISTRY_LOGIN_PASSWORD" | docker login "${{ steps.reg.outputs.host }}" -u "${{ steps.reg.outputs.user }}" --password-stdin
- name: Download agent package
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: agent-package
path: src/Infra/backend/agent-package
- name: Build images
env:
VERSION: ${{ needs.release.outputs.version }}
GIT_COMMIT_SHORT: ${{ needs.release.outputs.short }}
PREFIX: ${{ steps.reg.outputs.prefix }}
SOURCE_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
set -e
if ! ls src/Infra/backend/agent-package/Agent.* >/dev/null 2>&1; then
echo "::warning::No agent package staged - the backend image will ship without an installer."
fi
GIT_COMMIT="$(git rev-parse HEAD)"
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
for svc in backend webui; do
docker build -f "src/Infra/${svc}/Dockerfile" \
--build-arg UNIFIED_VERSION="$VERSION" \
--build-arg GIT_COMMIT="$GIT_COMMIT" \
--build-arg GIT_COMMIT_SHORT="$GIT_COMMIT_SHORT" \
--build-arg BUILD_DATE="$BUILD_DATE" \
--build-arg SOURCE_URL="$SOURCE_URL" \
-t "${PREFIX}-${svc}:$VERSION" .
done
- name: Tag and push
env:
VERSION: ${{ needs.release.outputs.version }}
PREFIX: ${{ steps.reg.outputs.prefix }}
run: |
set -e
# The registry sometimes times out mid-upload; a retried push skips the layers already there.
push() { for try in 1 2 3 4; do docker push "$1" && return 0; echo "::warning::push of $1 failed (try $try)"; sleep $((try * 15)); done; return 1; }
for svc in backend webui; do
push "${PREFIX}-${svc}:$VERSION"
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:latest"
push "${PREFIX}-${svc}:latest"
done
echo "Published ${PREFIX}-backend and ${PREFIX}-webui as $VERSION and latest"