Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: build and publish

on:
push:
branches: [master]
tags: ["v*"]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
build:
name: build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

- name: Test
run: dotnet test EppLib.UnitTests/EppLib.UnitTests.csproj -c Release

- name: Check tag matches package version
if: startsWith(github.ref, 'refs/tags/v')
run: |
version=$(dotnet msbuild EppLib/EppLib.csproj -getProperty:Version)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "Tag $GITHUB_REF_NAME does not match package version $version"
exit 1
fi

- name: Pack
run: dotnet pack EppLib/EppLib.csproj -c Release -o artifacts

- uses: actions/upload-artifact@v7
with:
name: nupkg
path: artifacts/*.nupkg

publish:
name: publish to NuGet
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: nupkg
path: artifacts

- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

# Trusted publishing: exchanges the GitHub OIDC token for a short-lived NuGet API key.
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: ademar

- name: Push
run: dotnet nuget push "artifacts/*.nupkg" --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json
Loading
Loading