Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .github/workflows/dotnet-tool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: dotnet-tool

on:
push:
pull_request:

permissions:
contents: read

jobs:
build_release_artifacts:
name: Build dotnet tool artifact (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: psign-tool-linux-x64.zip
binary: psign-tool

- name: linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: psign-tool-linux-arm64.zip
binary: psign-tool

- name: windows-x64
os: windows-2022
target: x86_64-pc-windows-msvc
archive: psign-tool-windows-x64.zip
binary: psign-tool.exe

- name: windows-arm64
os: windows-2022
target: aarch64-pc-windows-msvc
archive: psign-tool-windows-arm64.zip
binary: psign-tool.exe

- name: macos-x64
os: macos-14
target: x86_64-apple-darwin
archive: psign-tool-macos-x64.zip
binary: psign-tool

- name: macos-arm64
os: macos-14
target: aarch64-apple-darwin
archive: psign-tool-macos-arm64.zip
binary: psign-tool

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal --target "${{ matrix.target }}"
rustup default stable

- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2.8.2

- 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 psign-tool
shell: pwsh
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: |
cargo build --locked --release -p psign --bin psign-tool --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@v7
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
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@v6

- name: Download native artifacts
uses: actions/download-artifact@v8
with:
path: dist

- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
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-psign-dotnet-tool.ps1 `
-Version $version `
-ArtifactsRoot "dist" `
-StagingRoot $stagingRoot `
-OutputDir "dist/nuget"

- name: Upload dry-run dotnet tool artifact
uses: actions/upload-artifact@v7
with:
name: devolutions-psign-tool-nupkg-dry-run
path: dist/nuget/Devolutions.Psign.Tool*.nupkg
if-no-files-found: error
Loading
Loading