Publish To Nuget #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish To Nuget | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# pull_request: | |
# push: | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: Build | |
#Needs windows to build the windows version | |
runs-on: windows-latest | |
environment: Default | |
env: | |
NUPKG_MAJOR: 1.0.1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_NOLOGO: true | |
PROJECT: MauiGestures/MauiGestures.csproj | |
# CODESIGN_PFX: ${{ secrets.CODESIGN_PFX }} | |
steps: | |
- uses: actions/checkout@v4 | |
#Saves a nuget config | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
source-url: https://www.nuget.org/api/v2/package | |
env: | |
NUGET_AUTH_TOKEN: ${{secrets.NUGETAPIKEY}} | |
# - name: Install MAUI workload | |
# run: dotnet workload install maui | |
- name: Build | |
shell: pwsh | |
run: dotnet build -c Release $PROJECT | |
- name: Package & Publish NuGets | |
shell: pwsh | |
run: | | |
$VERSION="$env:NUPKG_MAJOR-ci$env:GITHUB_RUN_ID" | |
if ($env:GITHUB_EVENT_NAME -eq "release") { | |
$VERSION = $env:GITHUB_REF.Substring($env:GITHUB_REF.LastIndexOf('/') + 1) | |
} | |
echo "PACKAGE VERSION: $VERSION" | |
New-Item -ItemType Directory -Force -Path ./artifacts | |
dotnet pack --output ./artifacts -c Release -p:PackageVersion=$VERSION $PROJECT | |
# needs to CD because nuget push can't find nuget packages with a linux style path | |
cd ./artifacts | |
dotnet nuget push *.nupkg --skip-duplicate | |
# github package uses storage space, which is a limited resource | |
# echo "pkgverci=$VERSION" >> $GITHUB_OUTPUT | |
#$pfxPath = Join-Path -Path $pwd -ChildPath "codesigncert.pfx" | |
#[IO.File]::WriteAllBytes("$pfxPath", [System.Convert]::FromBase64String($env:CODESIGN_PFX)) | |
#nuget sign .\artifacts\*.nupkg -CertificatePath $pfxPath -Timestamper http://timestamp.entrust.net/TSS/RFC3161sha2TS | |
# - name: Artifacts | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: nupkg | |
# path: ./artifacts | |
# publish: | |
# name: Publish | |
# needs: build | |
# runs-on: windows-latest | |
# environment: Default | |
# if: github.event_name == 'release' | |
# steps: | |
# - name: Download Artifacts | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: nupkg | |
# - name: Setup .NET Core | |
# uses: actions/setup-dotnet@v3 | |
# with: | |
# dotnet-version: 8.0.x | |
# - name: Push to nuget | |
## does not find the nupkg file when used without download artifact. | |
# run: dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NuGetAPIKey }} |