Skip to content

.NET NuGet Release

.NET NuGet Release #55

name: .NET NuGet Release
on:
create:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
environment: NuGet
strategy:
matrix:
configuration: [Release]
runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Solution_Name: Scintilla.NET.sln
App_Project_Directory: Scintilla.NET
App_Project_Path: Scintilla.NET\Scintilla.NET.csproj
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
NUGETAPI: ${{ secrets.NUGETAPI }}
GH_PACKAGES_APIKEY: ${{ secrets.GH_PACKAGES_APIKEY }}
PACKAGESAPI: ${{ secrets.PACKAGESAPI }}
NUGETCONFIG: ${{ secrets.NUGETCONFIG }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# Install the .NET 6 workload
- name: Install .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}
# Create the app package by building and packaging the Windows Application Packaging project
- name: Create the app NuGet package
run: msbuild $env:App_Project_Path /p:Configuration=$env:Configuration
- name: Decode nuget.config
if: ${{ github.event_name != 'pull_request' }}
run: |
$nuget_config_bytes = [System.Convert]::FromBase64String("$env:NUGETCONFIG")
$currentDirectory = Get-Location
$nugetConfigFile = Join-Path -Path $currentDirectory -ChildPath "nuget.config"
[IO.File]::WriteAllBytes("$nugetConfigFile", $nuget_config_bytes)
- name: NuGet push
if: ${{ github.event_name != 'pull_request' }}
run: |
$currentDirectory = Get-Location
$files = Get-ChildItem $currentDirectory -r -Filter *Scintilla.NET*.nupkg # use the mask to discard possible third party packages..
Write-Output $files.Count
for ($i = 0; $i -lt $files.Count; $i++)
{
$file = $files[$i].FullName
$arguments = @("push", $file, "$env:NUGET_APIKEY", "-Source", "$env:NUGETAPI", "-SkipDuplicate")
# sign the NuGet packages.
Write-Output (-join("Pushing NuGet:", $file, " ..."))
nuget.exe $arguments
$arguments = @("push", $file, "$env:GH_PACKAGES_APIKEY", "-Source", "$env:PACKAGESAPI", "-SkipDuplicate")
nuget.exe $arguments
}