Build & Release .NET Package #10
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: Build & Release .NET Package | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10' | |
| - name: Publish | |
| run: | | |
| version=$(git describe --tags --abbrev=0) | |
| dotnet pack BangumiNet.Api -p:PackageVersion=${version#v} -o . -c Release | |
| dotnet pack BangumiNet.Shared -p:PackageVersion=${version#v} -o . -c Release | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pkg-archive | |
| path: BangumiNet.*.nupkg | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: pkg-archive | |
| path: . | |
| - name: Push | |
| run: | | |
| apiPkg=$(find . -name "BangumiNet.Api.*.nupkg" | head -n 1) | |
| sharedPkg=$(find . -name "BangumiNet.Shared.*.nupkg" | head -n 1) | |
| dotnet nuget push $apiPkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| dotnet nuget push $sharedPkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |