gpt大人,我们这么做工作流真的可以工作吗 #16
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: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_NOLOGO: true | |
| NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
| jobs: | |
| build-and-publish: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch tags | |
| run: git fetch --tags | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore all projects | |
| run: | | |
| dotnet restore src/AutoSettingUI.Core/AutoSettingUI.Core.csproj | |
| dotnet restore src/AutoSettingUI.Generator/AutoSettingUI.Generator.csproj | |
| dotnet restore src/Extensions/AutoSettingUI.Extension.Shared/AutoSettingUI.Extension.Shared.csproj | |
| dotnet restore src/Extensions/AutoSettingUI.Avalonia/AutoSettingUI.Avalonia.csproj | |
| dotnet restore src/Extensions/AutoSettingUI.Ursa/AutoSettingUI.Ursa.csproj | |
| dotnet restore src/Extensions/AutoSettingUI.WPF/AutoSettingUI.WPF.csproj | |
| dotnet restore src/AutoSettingUI.Generator.Tests/AutoSettingUI.Generator.Tests.csproj | |
| - name: Build all projects | |
| run: | | |
| dotnet build src/AutoSettingUI.Core/AutoSettingUI.Core.csproj --configuration Release | |
| dotnet build src/AutoSettingUI.Generator/AutoSettingUI.Generator.csproj --configuration Release | |
| dotnet build src/Extensions/AutoSettingUI.Extension.Shared/AutoSettingUI.Extension.Shared.csproj --configuration Release | |
| dotnet build src/Extensions/AutoSettingUI.Avalonia/AutoSettingUI.Avalonia.csproj --configuration Release | |
| dotnet build src/Extensions/AutoSettingUI.Ursa/AutoSettingUI.Ursa.csproj --configuration Release | |
| dotnet build src/Extensions/AutoSettingUI.WPF/AutoSettingUI.WPF.csproj --configuration Release | |
| dotnet build src/AutoSettingUI.Generator.Tests/AutoSettingUI.Generator.Tests.csproj --configuration Release | |
| - name: Test | |
| run: dotnet test src/AutoSettingUI.Generator.Tests/AutoSettingUI.Generator.Tests.csproj --configuration Release --verbosity minimal | |
| - name: Pack | |
| run: | | |
| mkdir -p artifacts | |
| dotnet pack src/AutoSettingUI.Core/AutoSettingUI.Core.csproj --configuration Release --output artifacts | |
| dotnet pack src/AutoSettingUI.Generator/AutoSettingUI.Generator.csproj --configuration Release --output artifacts | |
| dotnet pack src/Extensions/AutoSettingUI.Extension.Shared/AutoSettingUI.Extension.Shared.csproj --configuration Release --output artifacts | |
| dotnet pack src/Extensions/AutoSettingUI.Avalonia/AutoSettingUI.Avalonia.csproj --configuration Release --output artifacts | |
| dotnet pack src/Extensions/AutoSettingUI.Ursa/AutoSettingUI.Ursa.csproj --configuration Release --output artifacts | |
| dotnet pack src/Extensions/AutoSettingUI.WPF/AutoSettingUI.WPF.csproj --configuration Release --output artifacts | |
| ls -R artifacts | |
| - name: Publish to NuGet | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| shell: pwsh | |
| run: | | |
| Write-Host "Publishing NuGet packages..." | |
| $files = Get-ChildItem -Path "artifacts" -Filter "*.nupkg" | |
| foreach ($f in $files) { | |
| dotnet nuget push $f.FullName --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | |
| } | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/*.nupkg | |
| retention-days: 30 |