Skip to content

ci: attach the built nupkg to a GitHub Release on develop #35

ci: attach the built nupkg to a GitHub Release on develop

ci: attach the built nupkg to a GitHub Release on develop #35

Workflow file for this run

name: CI
on:
push:
branches: [master, develop, release-*]
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
pull_request:
workflow_dispatch:
env:
DOTNET_NOLOGO: true
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Fetch native binaries
# Downloads + SHA256-verifies the prebuilt native payload pinned in natives.lock.json into
# native/ (replaces the old NativeBinaries.UiPath PackageReference). pwsh ships on all runners.
shell: pwsh
run: ./fetch.natives.ps1
- name: Build
run: dotnet build LibGit2Sharp.sln --configuration Release
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: NuGet packages
path: bin/Packages/
retention-days: 7
test:
name: Test / ${{ matrix.os }} / ${{ matrix.tfm }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Native runners, one per OS. macos-14 is Apple Silicon, so it exercises the osx-arm64
# native; windows-latest -> win-x64, ubuntu-latest -> linux-x64. The win-arm64/linux-arm64
# and osx-x64 natives ship in the package but are not runtime-tested here (would need arm
# Windows/Linux runners and a scarce Intel mac). The old dockerized multi-distro matrix was
# dropped: it pinned .NET 6/7 SDK images and included alpine/musl, which our glibc-linked
# linux natives can't run anyway.
os: [ windows-latest, ubuntu-latest, macos-14 ]
# Mirror NetCoreVersion in Directory.Build.props (net6.0). A workflow matrix can't read an
# MSBuild property, so keep the two in sync by hand when bumping the target framework.
tfm: [ net6.0 ]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Fetch native binaries
shell: pwsh
run: ./fetch.natives.ps1
- name: Run ${{ matrix.tfm }} tests
# CanInspectCertificateOnClone is an upstream network-integration test that asserts GitHub's
# hardcoded SSH host-key MD5 fingerprint; it is unstable on CI (external host key, network)
# and does not exercise our native packaging, so it is excluded here.
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING --filter "FullyQualifiedName!~CanInspectCertificateOnClone"
release:
name: Release nupkg
needs: build
# On develop, attach the built LibGit2Sharp.UiPath nupkg to a GitHub Release so the interactive
# feed-publish step can pull it straight from the release (gh release download) instead of
# rebuilding locally. No feed push happens here — that stays a deliberate manual step.
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: NuGet packages
path: packages
- name: Publish nupkg to GitHub Release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
# This job has no checkout, so point gh at the repo explicitly — otherwise gh tries to read a
# local .git and fails with "not a git repository".
GH_REPO: ${{ github.repository }}
run: |
$ErrorActionPreference = 'Continue'
$PSNativeCommandUseErrorActionPreference = $false
$nupkg = Get-ChildItem packages -Recurse -File |
Where-Object { $_.Extension -eq '.nupkg' } | Select-Object -First 1
if (-not $nupkg) { throw "No .nupkg found in the build artifact." }
# Version = the nupkg filename minus the package-id prefix. The tag is prefixed 'pkg-' so it
# is NOT a bare SemVer and MinVer ignores it (only the manual X.Y.Z-vN tag drives versions).
$version = $nupkg.BaseName -replace '^LibGit2Sharp\.UiPath\.', ''
$tag = "pkg-$version"
Write-Host "Publishing $($nupkg.Name) to release $tag"
gh release view $tag *> $null
if ($LASTEXITCODE -ne 0) {
gh release create $tag --target $env:GITHUB_SHA --title $tag --notes "LibGit2Sharp.UiPath $version, built from develop. Fetch with: gh release download $tag --pattern '*.nupkg'"
}
gh release upload $tag "$($nupkg.FullName)" --clobber
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
Write-Host "Published $($nupkg.Name) to release $tag"