Files
local-ci-cd-system/.gitea/workflows/build-ns7zip.yml
T
Simone eec3f42fe0 ci: single build-command for ns7zip (Linux has python)
Linux template provides `python`, so the OS-aware split is
unnecessary. Use `python build_plugin.py` for both matrix legs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 20:28:39 +02:00

111 lines
5.0 KiB
YAML

# Build ns7zip (Local CI) — pipeline per nsis-plugin-ns7zip
#
# Cross-platform matrix build: runs in parallel on both windows-build (WinRM)
# and linux-build (SSH) runners using the reusable composite action.
# Uses: https://gitea.emulab.it/Simone/local-ci-cd-system/.gitea/actions/local-ci-build@main
#
# Trigger: push su tag v*, oppure run manuale
name: Build ns7zip (Local CI)
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
strategy:
matrix:
target: [windows, linux]
fail-fast: false
# Runner label must match config.yaml labels: windows-build or linux-build
runs-on: ${{ matrix.target }}-build
steps:
- uses: https://gitea.emulab.it/Simone/local-ci-cd-system/.gitea/actions/local-ci-build@main
with:
# build_plugin.py auto-detects host/toolset and builds all
# configs by default; --final/--dist-dir do not exist (they were
# forwarded to the per-version script and rejected). Output DLLs
# are copied to <repo>/plugins/{x86-ansi,x86-unicode,amd64-unicode}.
build-command: 'python build_plugin.py'
artifact-source: 'plugins'
submodules: 'true'
guest-os: ${{ matrix.target == 'linux' && 'Linux' || 'Windows' }}
# repo-url uses the host SSH alias `gitea-ci` (~/.ssh/config),
# which exists only on the host — so the clone MUST run on the
# host, not in the guest. use-git-clone:'false' selects the
# host-side clone + zip transfer transport.
use-git-clone: 'false'
repo-url: 'ssh://gitea-ci/Simone/nsis-plugin-ns7zip.git'
# Cross-repo build: github.ref_name is this repo's branch, not
# nsis-plugin-ns7zip's. Pin the target repo's branch.
repo-branch: 'main'
# Suffix disambiguates artifact dirs: F:\CI\Artifacts\{run_id}-{attempt}-windows
job-id-suffix: '${{ matrix.target }}'
artifact-name: 'nsis-plugin-ns7zip-${{ matrix.target }}-${{ github.ref_name }}'
# ── Publish Gitea release with build artifacts ────────────────────────────
# Runs only on tag pushes, after both matrix legs succeed.
# Requires a GITEA_TOKEN secret with repo write permissions.
release:
needs: build
if: github.ref_type == 'tag'
runs-on: windows-build
steps:
# No actions/download-artifact (its code is fetched from github.com).
# The runner host is single and shared; the build matrix legs left
# their outputs at F:\CI\Artifacts\{run_id}-{run_attempt}-{target}
# (job-id-suffix = matrix.target). Read them directly from disk.
- name: Create Gitea release and upload assets
shell: powershell
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_URL: ${{ github.server_url }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
#Requires -Version 5.1
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$authHeader = @{ Authorization = "token $env:GITEA_TOKEN" }
$apiBase = "$env:GITEA_URL/api/v1/repos/$env:REPO"
# Create the release (non-draft, non-prerelease)
$releaseBody = @{
tag_name = $env:TAG
name = $env:TAG
draft = $false
prerelease = $false
} | ConvertTo-Json
$jsonHeaders = $authHeader + @{ 'Content-Type' = 'application/json' }
$release = Invoke-RestMethod -Method Post -Uri "$apiBase/releases" `
-Headers $jsonHeaders -Body $releaseBody
$releaseId = $release.id
Write-Host "Release created: id=$releaseId name=$($release.name)"
# Compress each host-side artifact directory and upload as a
# release asset. The build legs collected to
# F:\CI\Artifacts\{run_id}-{run_attempt}-{target}.
foreach ($target in @('windows', 'linux')) {
$srcDir = "F:\CI\Artifacts\$env:RUN_ID-$env:RUN_ATTEMPT-$target"
if (-not (Test-Path -LiteralPath $srcDir) -or
-not (Get-ChildItem -Force -LiteralPath $srcDir)) {
throw "artifact dir missing or empty: $srcDir"
}
$zipName = "nsis-plugin-ns7zip-$target-$env:TAG.zip"
Compress-Archive -Path "$srcDir\*" -DestinationPath $zipName -Force
$uploadUrl = "$apiBase/releases/$releaseId/assets?name=$zipName"
$uploadHeaders = $authHeader + @{ 'Content-Type' = 'application/zip' }
$zipBytes = [System.IO.File]::ReadAllBytes(
(Resolve-Path $zipName).ProviderPath)
Invoke-RestMethod -Method Post -Uri $uploadUrl `
-Headers $uploadHeaders -Body $zipBytes | Out-Null