Skip to content

Publish NuGet package #142

Publish NuGet package

Publish NuGet package #142

Workflow file for this run

name: Publish NuGet package
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: true
type: boolean
default: 'true'
schedule:
- cron: '21 3 * * 1' # 3:21 AM UTC every Monday
jobs:
preflight:
name: Preflight
runs-on: ubuntu-20.04
outputs:
dry-run: ${{ steps.get-dry-run.outputs.dry-run }}
steps:
- name: Get dry run
id: get-dry-run
shell: pwsh
run: |
Set-PSDebug -Trace 1
$IsDryRun = '${{ github.event.inputs.dry-run }}' -Eq 'true' -Or '${{ github.event_name }}' -Eq 'schedule'
if ($IsDryRun) {
echo "dry-run=true" >> $Env:GITHUB_OUTPUT
} else {
echo "dry-run=false" >> $Env:GITHUB_OUTPUT
}
build-native:
uses: ./.github/workflows/build-native.yml
build-managed:
name: Managed build
runs-on: windows-2022
needs: [build-native]
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v3
- name: Prepare dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Path "dependencies/runtimes" | Out-Null
- name: Download native components
uses: actions/download-artifact@v3
with:
path: dependencies/runtimes
- name: Rename dependencies
shell: pwsh
run: |
Set-PSDebug -Trace 1
Set-Location "dependencies/runtimes"
$(Get-Item ".\sspi-*-release") | ForEach-Object { Rename-Item $_ $_.Name.Replace("-release", "") }
$(Get-Item ".\sspi-*") | ForEach-Object { Rename-Item $_ $_.Name.Replace("sspi-", "") }
Get-ChildItem * -Recurse
- name: Build sspi (managed)
shell: pwsh
run: |
dotnet build .\ffi\dotnet\Devolutions.Sspi.sln -o package
- name: Upload managed components
uses: actions/upload-artifact@v3
with:
name: sspi-nupkg
path: package/*.nupkg
publish:
name: Publish NuGet package
runs-on: ubuntu-20.04
environment: nuget-publish
if: needs.preflight.outputs.dry-run == 'false'
needs:
- preflight
- build-managed
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@v3
with:
name: sspi-nupkg
path: package
- name: Publish to nuget.org
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Files = Get-ChildItem -Recurse package/*.nupkg
foreach ($File in $Files) {
$PushCmd = @(
'dotnet',
'nuget',
'push',
"$File",
'--api-key',
'${{ secrets.NUGET_API_KEY }}',
'--source',
'https://api.nuget.org/v3/index.json',
'--skip-duplicate'
)
Write-Host "Publishing $($File.Name)..."
$PushCmd = $PushCmd -Join ' '
Invoke-Expression $PushCmd
}