Skip to content

🐛 Fix bug in publish workflow #12

🐛 Fix bug in publish workflow

🐛 Fix bug in publish workflow #12

on:
workflow_call:
inputs:
dotnet-version:
required: true
type: string
secrets:
NUGET_API_KEY:
required: true
GITHUB_TOKEN:

Check failure on line 10 in .github/workflows/dotnet-publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/dotnet-publish.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
jobs:
dotnet-publish:
name: Publish .NET
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
# The version number can be extracted from the currently checked out tag,
# which has the format 'refs/tags/v*'.
- name: Extract version number
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# Create the NuGet package
# Note that we substr the release version to get the numbers only, without
# the 'v' prefix.
- name: Build NuGet packages
run: dotnet pack --configuration Release --no-restore -p:PackageVersion=${RELEASE_VERSION:1}
- name: Create a Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.RELEASE_VERSION }}
name: Release ${{ env.RELEASE_VERSION }}
draft: false
prerelease: ${{ contains(env.RELEASE_VERSION, '-') }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
files: "**/*.nupkg"
- name: Push release to NuGet
run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate