Skip to content

Publish Sakura.Framework.SourceGenerators to NuGet #4

Publish Sakura.Framework.SourceGenerators to NuGet

Publish Sakura.Framework.SourceGenerators to NuGet #4

name: Publish Sakura.Framework.SourceGenerators to NuGet
on:
workflow_dispatch:
inputs:
patch:
description: 'Patch number (the last segment of YYYY.MMDD.patch)'
required: false
default: '0'
permissions:
contents: write
id-token: write
jobs:
publish:
name: Pack and Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Compute CalVer version
id: version
run: |
YEAR=$(TZ='Asia/Bangkok' date +'%Y')
MM=$(TZ='Asia/Bangkok' date +'%-m')
DD=$(TZ='Asia/Bangkok' date +'%d')
PATCH=${{ github.event.inputs.patch }}
VERSION="${YEAR}.${MM}${DD}.${PATCH}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Pack SourceGenerators
run: |
dotnet pack Sakura.Framework.SourceGenerators/Sakura.Framework.SourceGenerators.csproj \
--configuration Release \
-p:Version=${{ steps.version.outputs.version }} \
--output ./nupkg
- name: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to nuget.org
run: |
dotnet nuget push ./nupkg/*.nupkg \
--api-key ${{ steps.login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Upload nupkg artifact
uses: actions/upload-artifact@v7
with:
name: nupkg
path: ./nupkg/*.nupkg