Publish to NuGet #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to NuGet | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (leave empty to use version from Directory.Build.props)' | |
| required: false | |
| type: string | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Update version if specified | |
| if: ${{ github.event.inputs.version != '' }} | |
| run: | | |
| sed -i "s/<Version>.*<\/Version>/<Version>${{ github.event.inputs.version }}<\/Version>/" Directory.Build.props | |
| echo "Updated version to ${{ github.event.inputs.version }}" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack LuYao.ResourcePacker | |
| run: dotnet pack ./LuYao.ResourcePacker/LuYao.ResourcePacker.csproj --configuration Release --no-build --output ./packages | |
| - name: Pack LuYao.ResourcePacker.MSBuild | |
| run: dotnet pack ./LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj --configuration Release --no-build --output ./packages | |
| - name: Publish to NuGet | |
| run: | | |
| dotnet nuget push ./packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./packages/*.nupkg |