Skip to content

Publish to NuGet

Publish to NuGet #32

Workflow file for this run

name: Publish to NuGet
on:
workflow_dispatch:
concurrency:
group: publish
cancel-in-progress: false
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
env:
HUSKY: 0
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.x'
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Display version
run: echo "Publishing version ${{ steps.gitversion.outputs.semVer }}"
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Download Windows profiler from latest CI
uses: dawidd6/action-download-artifact@v18
with:
workflow: build-and-test.yml
commit: ${{ github.sha }}
name: profiler-windows
path: bin/Release
- name: Download macOS profiler from latest CI
uses: dawidd6/action-download-artifact@v18
with:
workflow: build-and-test.yml
commit: ${{ github.sha }}
name: profiler-macos
path: bin/Release
- name: Verify native binaries
run: |
ls -la bin/Release/
test -f bin/Release/Metreja.Profiler.dll
test -f bin/Release/libMetreja.Profiler.dylib
- name: Restore .NET dependencies
run: dotnet restore
- name: Build Metreja.Tool
run: dotnet build src/Metreja.Tool/Metreja.Tool.csproj -c Release --no-restore
- name: Pack NuGet package
run: dotnet pack src/Metreja.Tool/Metreja.Tool.csproj -c Release --no-build -o artifacts /p:PackageVersion=${{ steps.gitversion.outputs.semVer }}
- name: Inspect package contents
run: |
for f in artifacts/*.nupkg; do
echo "=== $f ==="
unzip -l "$f" | grep -q "Metreja\.Profiler\.dll"
unzip -l "$f" | grep -q "libMetreja\.Profiler\.dylib"
done
- name: Push to NuGet.org
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "v${{ steps.gitversion.outputs.semVer }}" artifacts/*.nupkg --title "v${{ steps.gitversion.outputs.semVer }}" --generate-notes
- name: Update website version
run: |
curl -sf -X POST https://metreja.io/api/version \
-H "Authorization: Bearer ${{ secrets.VERSION_UPDATE_SECRET }}" \
-H "Content-Type: application/json" \
-d '{"tag": "v${{ steps.gitversion.outputs.semVer }}"}'