Skip to content

Unions2 (#156)

Unions2 (#156) #453

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: publish
on:
workflow_dispatch:
push:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/dist/release
defaults:
run:
shell: pwsh
jobs:
#TODO: check nuget/GH auth flows, is token required etc.?
#TODO: check if publish job sees dist/nuget, see publish-artifact for reference
#TODO: omit push if built version is lower than or equal to latest published nuget package
build:
if: github.ref_type != 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
- name: Run Tests
run: dotnet test -c Release -p:Version=1.0.0
deploy:
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
- name: Run Tests
run: dotnet test -c Release -p:Version=${{github.ref_name}}
- name: Dotnet Build
run: dotnet build -c Release -p:Version=${{github.ref_name}}
- name: Create Nuget Packages
run: dotnet pack -c Release -o "$Env:NuGetDirectory" -p:PackageVersion=${{github.ref_name}} -p:Version=${{github.ref_name}}
- name: Publish NuGet Package
run: |
foreach($file in (Get-ChildItem "$Env:NuGetDirectory" -Recurse -Exclude *.Dev.${{github.ref_name}}.nupkg -Include *.*nupkg)) {
dotnet nuget push $file --api-key "$Env:NUGETAPITOKEN" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
env:
NUGETAPITOKEN: ${{ secrets.NUGETAPITOKEN }}