|
| 1 | +name: Publish to NuGet |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 13 | + DOTNET_NOLOGO: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-publish: |
| 17 | + runs-on: windows-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Setup .NET |
| 26 | + uses: actions/setup-dotnet@v4 |
| 27 | + with: |
| 28 | + dotnet-version: | |
| 29 | + 8.0.x |
| 30 | + 9.0.x |
| 31 | + 10.0.x |
| 32 | +
|
| 33 | +
|
| 34 | + - name: Restore dependencies |
| 35 | + run: dotnet restore AutoSettingUI.sln |
| 36 | + |
| 37 | + - name: Build |
| 38 | + run: dotnet build AutoSettingUI.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true |
| 39 | + |
| 40 | + - name: Run tests |
| 41 | + run: dotnet test AutoSettingUI.sln --configuration Release --no-build --verbosity normal |
| 42 | + |
| 43 | + - name: Pack AutoSettingUI.Core |
| 44 | + run: dotnet pack src/AutoSettingUI.Core/AutoSettingUI.Core.csproj --configuration Release --no-build --output artifacts |
| 45 | + |
| 46 | + - name: Pack AutoSettingUI.Generator |
| 47 | + run: dotnet pack src/AutoSettingUI.Generator/AutoSettingUI.Generator.csproj --configuration Release --no-build --output artifacts |
| 48 | + |
| 49 | + - name: Pack AutoSettingUI.Extension.Shared |
| 50 | + run: dotnet pack src/Extensions/AutoSettingUI.Extension.Shared/AutoSettingUI.Extension.Shared.csproj --configuration Release --no-build --output artifacts |
| 51 | + |
| 52 | + - name: Pack AutoSettingUI.Avalonia |
| 53 | + run: dotnet pack src/Extensions/AutoSettingUI.Avalonia/AutoSettingUI.Avalonia.csproj --configuration Release --no-build --output artifacts |
| 54 | + |
| 55 | + - name: Pack AutoSettingUI.Ursa |
| 56 | + run: dotnet pack src/Extensions/AutoSettingUI.Ursa/AutoSettingUI.Ursa.csproj --configuration Release --no-build --output artifacts |
| 57 | + |
| 58 | + - name: Pack AutoSettingUI.WPF |
| 59 | + run: dotnet pack src/Extensions/AutoSettingUI.WPF/AutoSettingUI.WPF.csproj --configuration Release --no-build --output artifacts |
| 60 | + |
| 61 | + - name: Publish to NuGet |
| 62 | + if: startsWith(github.ref, 'refs/tags/v') |
| 63 | + run: dotnet nuget push artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |
| 64 | + |
| 65 | + - name: Upload artifacts |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: nuget-packages |
| 69 | + path: artifacts/*.nupkg |
| 70 | + retention-days: 30 |
0 commit comments