Files
ExecuteR/.gitea/workflows/ci.yml
T
gsadmin 578ac93249
CI / build-test (push) Successful in 15m36s
CI / images (push) Successful in 39s
Release / agent-artifacts (push) Successful in 8m20s
CI: add workflow_dispatch for on-demand runs
Adds a manual trigger to the CI workflow (Gitea Actions "Run workflow" /
API dispatch) so a build can be kicked off without a dummy commit. This
commit itself (touching .gitea/workflows, no skip-ci) exercises the pipeline
under the now-deterministic version, so the images and binaries carry the
same version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-11 11:53:55 -04:00

288 lines
11 KiB
YAML

name: CI
# Runs only when something buildable changes — docs-only commits (README,
# docs/, compose examples) skip the queue entirely.
on:
# Manual trigger from the Gitea Actions UI (or API), for an on-demand build
# without a dummy commit.
workflow_dispatch:
pull_request:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'scripts/**'
- 'assets/**'
- '.gitea/workflows/**'
- 'ExecuteR.slnx'
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'global.json'
- 'dotnet-tools.json'
push:
branches: [dev, main]
paths:
- 'src/**'
- 'tests/**'
- 'scripts/**'
- 'assets/**'
- '.gitea/workflows/**'
- 'ExecuteR.slnx'
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'global.json'
- 'dotnet-tools.json'
jobs:
build-test:
# Windows is required to build/test the agent (CIM, ConPTY, DPAPI, service).
# Label must match a registered runner: windows-host.
runs-on: windows-host
# Single source of truth for the version: the images job consumes this
# instead of recomputing, so binaries and container images never drift.
outputs:
version: ${{ steps.ver.outputs.version }}
steps:
# This repository uses the SHA-256 object format. actions/checkout
# cannot clone it (it inits a SHA-1 repo then fetches: "mismatched
# algorithms"), so check out with plain git clone, which negotiates
# the object format correctly.
- name: Checkout
shell: pwsh
env:
CHECKOUT_TOKEN: ${{ github.token }}
run: |
$ErrorActionPreference = 'Stop'
Get-ChildItem -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
$ref = '${{ github.head_ref }}'
if (-not $ref) { $ref = '${{ github.ref_name }}' }
$url = '${{ github.server_url }}/${{ github.repository }}.git' -replace '^https://', "https://x-access-token:$env:CHECKOUT_TOKEN@"
git clone --depth 1 --branch $ref $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:
# @nats-io/* packages require Node >= 22.
node-version: '22'
- name: Compute unified version
id: ver
shell: pwsh
run: |
$v = & ./scripts/Get-UnifiedVersion.ps1
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
Write-Host "Unified version: $v"
- name: Restore
run: dotnet restore ExecuteR.slnx
- name: Build
run: dotnet build ExecuteR.slnx -c Release --no-restore "-p:UnifiedVersion=${{ steps.ver.outputs.version }}"
- name: Unit tests
run: |
dotnet test tests/Shared.Tests -c Release --no-build --nologo
dotnet test tests/Agent.Tests -c Release --no-build --nologo
dotnet test tests/Backend.Tests -c Release --no-build --nologo
- name: Integration tests
run: dotnet test tests/Integration.Tests -c Release --no-build --nologo
- name: WebUI install
run: npm ci
working-directory: src/WebUI
- name: WebUI check
run: npm run check
working-directory: src/WebUI
- name: WebUI build
env:
PUBLIC_BUILD_VERSION: ${{ steps.ver.outputs.version }}
run: npm run build
working-directory: src/WebUI
# Package the agent for every platform here (only Windows can build the
# windows flavor and the MSI) so the Linux image job can bake the Windows
# package into the backend image — no manual seeding at deploy.
- name: Package agent (all platforms)
if: ${{ github.event_name == 'push' }}
shell: pwsh
run: |
./scripts/Package-Agent.ps1 -Version ${{ steps.ver.outputs.version }} `
-Runtimes win-x64,win-arm64,linux-x64,linux-arm64,osx-x64,osx-arm64
$stage = 'artifacts/agent-package'
New-Item -ItemType Directory -Force $stage | Out-Null
$msi = "artifacts/ExecuteR-Agent-${{ steps.ver.outputs.version }}.msi"
$zip = "artifacts/ExecuteR-Agent-${{ steps.ver.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.ver.outputs.version }}-$rid.zip"
if (Test-Path $unix) { Copy-Item $unix "$stage/Agent-$rid.zip" }
}
'${{ steps.ver.outputs.version }}' | Set-Content "$stage/VERSION" -NoNewline
Get-ChildItem $stage | Select-Object Name, Length
# The combined standalone server (UI + API + NATS sidecar in one binary).
- name: Package server (win-x64 + linux-x64)
if: ${{ github.event_name == 'push' }}
shell: pwsh
run: ./scripts/Package-Server.ps1 -Version ${{ steps.ver.outputs.version }} -SkipIcon
- name: Upload agent package
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v3
with:
name: agent-package
path: artifacts/agent-package/
retention-days: 7
- name: Upload platform binaries
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
artifacts/ExecuteR-Agent-*.zip
artifacts/ExecuteR-Agent-*.msi
artifacts/ExecuteR-Agent-*-checksums.txt
artifacts/ExecuteR-Server-*.zip
artifacts/ExecuteR-Server-*.msi
artifacts/ExecuteR-Server-*-checksums.txt
retention-days: 7
images:
# Build the backend + webui images and publish them to the Gitea container
# registry. Image names match what docker-compose.yml pulls:
# <gitea-host>/<owner>/executer-backend:<tag>
# <gitea-host>/<owner>/executer-webui:<tag>
needs: build-test
if: ${{ github.event_name == 'push' }}
# Needs Docker; label must match a registered Linux runner.
runs-on: ubuntu-host
env:
# Gitea's built-in container registry lives on the Gitea host itself and
# needs no configuration: Actions injects GITEA_TOKEN per run and it is
# accepted as the registry password for the triggering actor.
# The REGISTRY_* secrets are only an override for an EXTERNAL registry.
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 build-test).
- name: Checkout
shell: bash
env:
CHECKOUT_TOKEN: ${{ github.token }}
run: |
set -e
find . -mindepth 1 -maxdepth 1 -exec rm -rf {} + 2>/dev/null || true
REF='${{ github.head_ref }}'
[ -z "$REF" ] && REF='${{ github.ref_name }}'
URL="$(echo '${{ github.server_url }}/${{ github.repository }}.git' | sed "s#^https://#https://x-access-token:${CHECKOUT_TOKEN}@#")"
git clone --depth 1 --branch "$REF" "$URL" .
git log -1 --format='%H %s'
- name: Resolve registry target
id: ver
shell: bash
run: |
set -e
# The version is NOT recomputed here — it comes from build-test's
# output (needs.build-test.outputs.version) so images match the binaries.
# Default to Gitea's own registry on this instance; fall back to the
# REGISTRY_* secrets only when an external registry is configured.
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
# Gitea package paths are lowercase.
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.ver.outputs.host }}" -u "${{ steps.ver.outputs.user }}" --password-stdin
# Bake the Windows-built agent into the backend image so the URL install
# flow serves it with no manual seeding.
- name: Download agent package
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: agent-package
path: src/Infra/backend/agent-package
- name: Confirm agent package staged
run: |
if ls src/Infra/backend/agent-package/Agent.* >/dev/null 2>&1; then
echo "Agent package will be baked into the backend image:"
ls -la src/Infra/backend/agent-package/
else
echo "::warning::No agent package staged - the backend image will ship without an installer and /api/enrollment/agent-package will 404 until one is mounted or offloaded to S3."
fi
- name: Build images
env:
VERSION: ${{ needs.build-test.outputs.version }}
PREFIX: ${{ steps.ver.outputs.prefix }}
SOURCE_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
set -e
GIT_COMMIT="$(git rev-parse HEAD)"
GIT_COMMIT_SHORT="$(git rev-parse --short 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.build-test.outputs.version }}
PREFIX: ${{ steps.ver.outputs.prefix }}
REF_NAME: ${{ github.ref_name }}
run: |
set -e
for svc in backend webui; do
docker push "${PREFIX}-${svc}:$VERSION"
if [ "$REF_NAME" = "main" ]; then
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:latest"
docker push "${PREFIX}-${svc}:latest"
else
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:dev"
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:${VERSION}-dev"
docker push "${PREFIX}-${svc}:dev"
docker push "${PREFIX}-${svc}:${VERSION}-dev"
fi
done
echo "Published ${PREFIX}-backend and ${PREFIX}-webui"