Publish To Nuget #37
Workflow file for this run
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: | |
# pull_request: | |
# push: | |
release: | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
#Needs windows to build the windows version | |
runs-on: windows-latest | |
env: | |
NUPKG_MAJOR: 1.0.4 | |
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@v4 | |
with: | |
dotnet-version: 8.0.x | |
# - name: Install MAUI workload | |
# run: dotnet workload install maui | |
- name: Build | |
shell: pwsh | |
run: dotnet build -c Release $env:PROJECT | |
- name: Package NuGets | |
shell: pwsh | |
env: | |
#required so if it contains special characters they are not interpreted by powershell | |
NUGET_AUTH_TOKEN: ${{secrets.NUGETAPIKEY}} | |
NUGET_TARGET: https://api.nuget.org/v3/index.json | |
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 --no-build --output ./artifacts -c Release -p:PackageVersion=$VERSION $env: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 -k $env:NUGET_AUTH_TOKEN -s $env:NUGET_TARGET | |
# 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' | |
# env: | |
# #required so if it contains special characters they are not interpreted by powershell | |
# NUGET_AUTH_TOKEN: ${{secrets.NUGETAPIKEY}} | |
# NUGET_TARGET: https://api.nuget.org/v3/index.json | |
# steps: | |
# - name: Download Artifacts | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: nupkg | |
# - name: Setup .NET Core | |
# uses: actions/setup-dotnet@v4 | |
# 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 -s $env:NUGETAPIKEY -k $env:NUGET_AUTH_TOKEN |