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 all src NuGet Packages | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # 仅在推送像 v1.0.0 这样的 tag 时触发 | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v5.0.1 | |
| with: | |
| dotnet-version: '10.0.x' # 可根据你的项目适当调整 | |
| - name: Copy icon.png to all project directories | |
| run: | | |
| for proj in src/**/*.csproj; do | |
| cp logo.png "$(dirname "$proj")/" | |
| done | |
| - name: Restore dependencies | |
| run: | | |
| for proj in src/**/*.csproj; do | |
| dotnet restore "$proj" | |
| done | |
| - name: Set VERSION from git tag | |
| run: | | |
| echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Build | |
| run: | | |
| for proj in src/**/*.csproj; do | |
| dotnet build "$proj" --configuration Release --no-restore | |
| done | |
| - name: Pack all projects in src | |
| run: | | |
| for proj in src/**/*.csproj; do | |
| dotnet pack "$proj" --configuration Release --no-build --output ./nupkgs /p:Version=${VERSION} /p:Pack=true | |
| done | |
| - name: Push all packages to NuGet | |
| run: | | |
| for nupkg in ./nupkgs/*.nupkg; do | |
| dotnet nuget push "$nupkg" --api-key ${{ secrets.NUGET_AUTH_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| done |