nyx/.github/workflows/release-build.yml
Eli Peter 238ed095a3
Fix/update release pipeline (#15)
* fix: Enhance release packaging for cross-platform compatibility

* fix: Resolve pipeline bug with zip command on Windows

* fix: Clarify changelog entry for Windows zip command issue in release pipeline

* Update CHANGELOG.MD

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-25 02:49:09 +02:00

89 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Release build & publish
on:
release:
types: [created]
permissions:
contents: write
env:
BIN_NAME: nyx
jobs:
build-and-upload:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-apple-darwin
os: macos-14
- target: aarch64-apple-darwin
os: macos-14
runs-on: ${{ matrix.os }}
steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
cache: true
- name: Install target
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --bin ${{ env.BIN_NAME }} --target ${{ matrix.target }}
- name: Install cargo-about
run: cargo install cargo-about --locked
- name: Generate license bundle
run: cargo about generate about.hbs -o THIRDPARTY-LICENSES.html
- name: Package (Linux & macOS)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
BIN=${{ env.BIN_NAME }}
TARGET=${{ matrix.target }}
EXT=$([[ "$TARGET" == *windows* ]] && echo ".exe" || echo "")
BIN_PATH=target/$TARGET/release/$BIN$EXT
mkdir -p dist
ARCHIVE=$BIN-$TARGET.zip
zip -9 "dist/$ARCHIVE" "$BIN_PATH" THIRDPARTY-LICENSES.html LICENSE* COPYING*
echo "ASSET=$ARCHIVE" >> "$GITHUB_ENV"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$Bin = '${{ env.BIN_NAME }}'
$Target = '${{ matrix.target }}'
$Ext = '.exe'
$BinPath = "target/$Target/release/$Bin$Ext"
New-Item -ItemType Directory -Path dist -Force | Out-Null
$Archive = "$Bin-$Target.zip"
# PowerShells native ZIP
Compress-Archive `
-Path $BinPath, 'THIRDPARTY-LICENSES.html', 'LICENSE*', 'COPYING*' `
-DestinationPath "dist/$Archive" `
-CompressionLevel Optimal
Add-Content -Path $env:GITHUB_ENV -Value "ASSET=$Archive"
- name: Upload to the release
uses: softprops/action-gh-release@v2
with:
files: dist/${{ env.ASSET }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}