1ff1a2273e
Package-Agent gains -Runtimes and picks the right flavor per RID (net10.0-windows for win, portable net10.0 elsewhere) — this also fixes publishing after the multi-targeting change, which requires an explicit framework. Unix binaries ship as executer-agent; the MSI still harvests the win-x64 output. CI packages the agent for win-x64/linux-x64/linux-arm64/osx-x64/ osx-arm64 plus the combined standalone server (win-x64, linux-x64) and uploads everything as a "binaries" artifact with checksums. Releases attach the same set (Server zips included), and the release workflow sets up Node 22 for the static WebUI build the server bundle needs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
240 lines
9.4 KiB
YAML
240 lines
9.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [dev, main]
|
|
|
|
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
|
|
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,linux-x64,linux-arm64,osx-x64,osx-arm64
|
|
$stage = 'artifacts/agent-package'
|
|
New-Item -ItemType Directory -Force $stage | Out-Null
|
|
$msi = "artifacts/Agent-${{ steps.ver.outputs.version }}.msi"
|
|
$zip = "artifacts/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" }
|
|
'${{ 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/Agent-*.zip
|
|
artifacts/Agent-*.msi
|
|
artifacts/Agent-*-checksums.txt
|
|
artifacts/Server-*.zip
|
|
artifacts/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 version and registry target
|
|
id: ver
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
echo "version=$(date -u +%Y.%m.%d.%H%M)" >> "$GITHUB_OUTPUT"
|
|
|
|
# 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: ${{ steps.ver.outputs.version }}
|
|
PREFIX: ${{ steps.ver.outputs.prefix }}
|
|
run: |
|
|
set -e
|
|
docker build -f src/Infra/backend/Dockerfile --build-arg UNIFIED_VERSION="$VERSION" -t "${PREFIX}-backend:$VERSION" .
|
|
docker build -f src/Infra/webui/Dockerfile --build-arg UNIFIED_VERSION="$VERSION" -t "${PREFIX}-webui:$VERSION" .
|
|
|
|
- name: Tag and push
|
|
env:
|
|
VERSION: ${{ steps.ver.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"
|