Build & Release .NET Package #26
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@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Publish | |
| run: | | |
| version=$(git describe --tags --abbrev=0) | |
| projects=("BangumiNet.Api" | |
| "BangumiNet.Common" | |
| "BangumiNet.Archive" | |
| "BangumiNet.BangumiData") | |
| for project in "${projects[@]}"; do | |
| dotnet pack $project -p:Version=${version#v} -c Release -o . | |
| done | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: pkg-archive | |
| path: BangumiNet.*nupkg | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: pkg-archive | |
| path: . | |
| - name: Push | |
| run: | | |
| find . -name "*.nupkg" | while read -r pkg; do | |
| dotnet nuget push $pkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| done |