name: Native release on: push: tags: ['v*'] # publish.py enforces exactly vX.Y.Z == Cargo.toml. # Requires Gitea >=1.26.2; check it before any artifact transfer. Never cancel # an in-flight publisher. Other publishers for this tag must use the same group. concurrency: group: release-${{ gitea.repository }}-${{ gitea.ref }} cancel-in-progress: false permissions: code: read env: GITEA_API_URL: ${{ gitea.api_url }} GITEA_REPOSITORY: ${{ gitea.repository }} RELEASE_TAG: ${{ gitea.ref_name }} RELEASE_COMMIT: ${{ gitea.sha }} RUSTUP_TOOLCHAIN: nightly-2026-11-24 CARGO_INCREMENTAL: '0' jobs: linux: # Host/image prerequisites: Git, Bash, Node 20, Python 3.11+, # and root or passwordless sudo for the explicit apt packages below. runs-on: ubuntu-latest defaults: run: shell: bash steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ gitea.sha }} persist-credentials: false - name: Check tag, checkout and Gitea prerequisite run: python3 packaging/publish.py check - name: Prepare native Linux build id: stage run: | set -euo pipefail . /etc/os-release [[ "$ID" == ubuntu && "$VERSION_ID" == 24.04 ]] test "$(uname -m)" = x86_64 sudo_cmd=() if [ "$(id -u)" -ne 0 ]; then sudo_cmd=(sudo); fi "${sudo_cmd[@]}" apt-get update "${sudo_cmd[@]}" apt-get install -y ca-certificates curl build-essential cmake perl nasm pkg-config libcurl4-openssl-dev dpkg-dev dist=$(mktemp -d "$RUNNER_TEMP/release-linux.XXXXXXXX") build=$(mktemp -d "$RUNNER_TEMP/build-linux.XXXXXXXX") echo "dist=$dist" >> "$GITHUB_OUTPUT" echo "CARGO_TARGET_DIR=$build" >> "$GITHUB_ENV" - uses: https://github.com/dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc with: toolchain: ${{ env.RUSTUP_TOOLCHAIN }} targets: x86_64-unknown-linux-gnu - name: Build and package Linux env: DIST: ${{ steps.stage.outputs.dist }} run: | set -euo pipefail cargo build --locked --release --target x86_64-unknown-linux-gnu --features vendored-lua binary="$CARGO_TARGET_DIR/x86_64-unknown-linux-gnu/release/rusty-path-of-building" "$binary" --version python3 packaging/package.py linux "$binary" --output "$DIST" python3 packaging/publish.py check --assets "$DIST" --platform linux # Gitea's v4 protocol needs these compatible forks (Gitea 1.22 release notes). # Runtime artifact credentials are supplied by the runner, not GITEA_TOKEN. - uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: packages-linux path: ${{ steps.stage.outputs.dist }}/* if-no-files-found: error compression-level: 0 overwrite: true windows: # Native x64 host: Git, Node 20, Windows PowerShell 5.1+, Python 3.11+, # VS 2022 C++ x64 tools + SDK + vswhere, NASM, CMake, Perl, NSIS 3. # Put Python/NASM/CMake/Perl on PATH; NSIS may use its standard path. runs-on: windows-x64 defaults: run: shell: powershell steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ gitea.sha }} persist-credentials: false - name: Check tag, checkout and Gitea prerequisite run: | python packaging/publish.py check if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - uses: https://github.com/dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc with: toolchain: ${{ env.RUSTUP_TOOLCHAIN }} targets: x86_64-pc-windows-msvc - name: Build and package Windows id: stage run: | $ErrorActionPreference = 'Stop' if (-not [Environment]::Is64BitOperatingSystem) { throw 'Windows x64 is required' } $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' $vs = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath $nsis = Get-Command makensis.exe -ErrorAction SilentlyContinue if (-not $nsis) { $nsisDir = Join-Path ${env:ProgramFiles(x86)} 'NSIS' if (-not (Test-Path (Join-Path $nsisDir 'makensis.exe'))) { throw 'NSIS 3 is required' } $env:PATH = "$nsisDir;$env:PATH" } $nsisVersion = & makensis.exe /VERSION if ($LASTEXITCODE -ne 0 -or $nsisVersion -notmatch '^v?3\.') { throw 'NSIS 3 is required' } $dist = Join-Path $env:RUNNER_TEMP ('release-windows-' + [guid]::NewGuid()) $env:CARGO_TARGET_DIR = Join-Path $env:RUNNER_TEMP ('build-windows-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $dist | Out-Null cargo build --release --features vendored-lua $binary = Join-Path $env:CARGO_TARGET_DIR 'release\rusty-path-of-building.exe' $imports = & dumpbin.exe /DEPENDENTS $binary $dlls = @($imports | ForEach-Object { if ($_ -match '^\s+([\w.-]+\.dll)\s*$') { $Matches[1].ToLowerInvariant() } }) if ($dlls.Count -eq 0) { throw 'Could not inspect PE imports' } # API sets are virtual system DLLs. Other imports must resolve without the build tools. foreach ($dll in $dlls) { if ($dll -match '^(vcruntime|msvcp|msvcr[0-9]|concrt|ucrtbased|libcurl|libssl|libcrypto|lua51|zlib)') { throw "Unexpected redistributable dependency: $dll" } if ($dll -notmatch '^(api|ext)-ms-' -and -not (Test-Path (Join-Path ([Environment]::SystemDirectory) $dll))) { throw "Non-system DLL is missing from the portable package: $dll" } } $dlls | Write-Output python packaging/package.py windows $binary --output $dist if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } python packaging/publish.py check --assets $dist --platform windows if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } [IO.File]::AppendAllText($env:GITHUB_OUTPUT, "dist=$dist" + [Environment]::NewLine) - uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: packages-windows path: ${{ steps.stage.outputs.dist }}/* if-no-files-found: error compression-level: 0 overwrite: true publish: needs: [linux, windows] runs-on: ubuntu-latest permissions: code: read releases: write defaults: run: shell: bash steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ gitea.sha }} persist-credentials: false - name: Check prerequisites and prepare empty download directory id: stage run: | set -euo pipefail python3 packaging/publish.py check dist=$(mktemp -d "$RUNNER_TEMP/release-publish.XXXXXXXX") echo "dist=$dist" >> "$GITHUB_OUTPUT" - uses: https://github.com/ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 with: name: packages-linux path: ${{ steps.stage.outputs.dist }} - uses: https://github.com/ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 with: name: packages-windows path: ${{ steps.stage.outputs.dist }} - name: Publish verified four-attachment release env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} DIST: ${{ steps.stage.outputs.dist }} run: python3 packaging/publish.py publish --assets "$DIST"