Skip to content

Add output encoding options and bump version to 0.5.0 #75

Add output encoding options and bump version to 0.5.0

Add output encoding options and bump version to 0.5.0 #75

Workflow file for this run

name: CI
on:
push:
branches:
- "**"
tags-ignore:
- "v*"
pull_request:
permissions:
contents: read
jobs:
lint:
name: Lint (Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup component add rustfmt clippy --toolchain stable
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2.8.2
- name: Check formatting
run: cargo fmt --all --check
- name: Run clippy (deny warnings)
run: cargo clippy --workspace --all-targets -- -D warnings -A clippy::self_named_module_files
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal
rustup default stable
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2.8.2
- name: Configure static MSVC runtime
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
"RUSTFLAGS=-C target-feature=+crt-static" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Run tests
run: cargo test --workspace
build_release_artifacts:
name: Build release artifact (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: test
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: cirup-linux-x64.zip
binary: cirup
- name: linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: cirup-linux-arm64.zip
binary: cirup
- name: windows-x64
os: windows-latest
target: x86_64-pc-windows-msvc
archive: cirup-windows-x64.zip
binary: cirup.exe
- name: windows-arm64
os: windows-latest
target: aarch64-pc-windows-msvc
archive: cirup-windows-arm64.zip
binary: cirup.exe
- name: macos-x64
os: macos-14
target: x86_64-apple-darwin
archive: cirup-macos-x64.zip
binary: cirup
- name: macos-arm64
os: macos-14
target: aarch64-apple-darwin
archive: cirup-macos-arm64.zip
binary: cirup
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal --target "${{ matrix.target }}"
rustup default stable
- name: Install Linux ARM64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure static MSVC runtime
if: contains(matrix.target, 'windows-msvc')
shell: pwsh
run: |
"RUSTFLAGS=-C target-feature=+crt-static" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build binary
shell: pwsh
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: |
cargo build --locked --release --package cirup_cli --bin cirup --target "${{ matrix.target }}"
- name: Package artifact
shell: pwsh
env:
TARGET: ${{ matrix.target }}
BIN_NAME: ${{ matrix.binary }}
ARCHIVE_NAME: ${{ matrix.archive }}
run: |
$target = $env:TARGET
$binName = $env:BIN_NAME
$archiveName = $env:ARCHIVE_NAME
$binaryPath = [System.IO.Path]::Combine("target", $target, "release", $binName)
if (-not (Test-Path -Path $binaryPath)) {
throw "Binary not found: $binaryPath"
}
if (Test-Path -Path $archiveName) {
Remove-Item -Path $archiveName -Force
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::Open($archiveName, [System.IO.Compression.ZipArchiveMode]::Create)
try {
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive,
$binaryPath,
$binName,
[System.IO.Compression.CompressionLevel]::Optimal
) | Out-Null
}
finally {
$archive.Dispose()
}
Write-Host "Created $archiveName"
- name: Upload packaged artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
if-no-files-found: error
pack_nuget_dry_run:
name: Dry-run NuGet pack
runs-on: ubuntu-latest
needs: build_release_artifacts
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download native artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Import binaries and pack NuGet (dry-run)
shell: pwsh
env:
CI_RUN_NUMBER: ${{ github.run_number }}
run: |
$version = "0.0.0-ci.$env:CI_RUN_NUMBER"
$stagingRoot = Join-Path $PWD "nuget/staging"
./nuget/pack-cirup-nuget.ps1 `
-Version $version `
-ArtifactsRoot "dist" `
-StagingRoot $stagingRoot `
-OutputDir "dist/nuget"
- name: Upload dry-run NuGet artifact
uses: actions/upload-artifact@v4
with:
name: devolutions-cirup-build-nupkg-dry-run
path: dist/nuget/Devolutions.Cirup.Build.*.nupkg
if-no-files-found: error
pack_dotnet_tool_dry_run:
name: Dry-run dotnet tool pack
runs-on: ubuntu-latest
needs: build_release_artifacts
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download native artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Import binaries and pack dotnet tool (dry-run)
shell: pwsh
env:
CI_RUN_NUMBER: ${{ github.run_number }}
run: |
$version = "0.0.0-ci.$env:CI_RUN_NUMBER"
$stagingRoot = Join-Path $PWD "nuget/staging"
./nuget/pack-cirup-dotnet-tool.ps1 `
-Version $version `
-ArtifactsRoot "dist" `
-StagingRoot $stagingRoot `
-OutputDir "dist/nuget"
- name: Upload dry-run dotnet tool artifact
uses: actions/upload-artifact@v4
with:
name: devolutions-cirup-tool-nupkg-dry-run
path: dist/nuget/Devolutions.Cirup.Tool*.nupkg
if-no-files-found: error