update build #26
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: build | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
packregistry: | |
description: 'Package registry to publish to' | |
type: choice | |
required: true | |
options: | |
- 'GitHub' | |
- 'NuGet' | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
DOTNET_NOLOGO: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 | |
# Only one build instance | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: build-${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ windows-latest, ubuntu-latest, macOS-latest ] | |
dotnet-version: [ '9.0.x' ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
dotnet-quality: 'ga' | |
- name: Build | |
run: ./build compile --Configuration Release | |
package: | |
name: Create NuGet Packages | |
runs-on: 'ubuntu-latest' | |
needs: [build] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
dotnet-quality: 'ga' | |
- name: Create Packages | |
run: ./build pack --Configuration Release | |
- name: Upload packages to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: | | |
artifacts/packages/*.nupkg | |
artifacts/packages/*.snupkg | |
publish: | |
name: publish-packages | |
runs-on: 'ubuntu-latest' | |
needs: [package] | |
if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
dotnet-quality: 'ga' | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: ./artifacts/packages | |
- name: Publish packages to GitHub | |
if: github.event.inputs.packregistry == 'GitHub' | |
run: | | |
dotnet nuget push ./artifacts/packages/*.nupkg --source https://nuget.pkg.github.com/cecilphillip-stripe/index.json --api-key ${{ secrets.NUGET_GITHUB_TOKEN }} | |
- name: Publish packages to NuGet | |
if: github.event.inputs.packregistry == 'NuGet' | |
run: | | |
dotnet nuget push ./artifacts/packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} | |