|
| 1 | +name: Harp.FastStepper |
| 2 | +on: |
| 3 | + push: |
| 4 | + # This prevents tag pushes from triggering this workflow |
| 5 | + branches: ['*'] |
| 6 | + pull_request: |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + workflow_dispatch: |
| 10 | +env: |
| 11 | + DOTNET_NOLOGO: true |
| 12 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 13 | + DOTNET_GENERATE_ASPNET_CERTIFICATE: false |
| 14 | + ContinuousIntegrationBuild: true |
| 15 | + CiBuildVersion: ${{github.event.release.tag_name || 'api42.42.42'}} |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + configuration: ['Release'] |
| 22 | + include: |
| 23 | + - configuration: Release |
| 24 | + collect-packages: true |
| 25 | + name: Build |
| 26 | + runs-on: windows-latest |
| 27 | + if: github.event_name != 'release' || startsWith(github.event.release.tag_name, 'api') |
| 28 | + steps: |
| 29 | + # ----------------------------------------------------------------------- Checkout |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + # ----------------------------------------------------------------------- Set up tools |
| 34 | + - name: Set up .NET |
| 35 | + uses: actions/setup-dotnet@v4 |
| 36 | + with: |
| 37 | + dotnet-version: 8.x |
| 38 | + |
| 39 | + - name: Set up T4 |
| 40 | + run: dotnet tool install -g dotnet-t4 --version 3.0.0 |
| 41 | + |
| 42 | + # ----------------------------------------------------------------------- Regenerate |
| 43 | + - name: Restore generators |
| 44 | + run: dotnet restore Generators |
| 45 | + |
| 46 | + - name: Run generators |
| 47 | + run: dotnet build Generators --no-restore --configuration ${{matrix.configuration}} |
| 48 | + |
| 49 | + - name: Verify pre-generated code was up-to-date |
| 50 | + id: verify-dist |
| 51 | + run: | |
| 52 | + git add . --intent-to-add --ignore-removal |
| 53 | + git diff --name-status --exit-code |
| 54 | +
|
| 55 | + # ----------------------------------------------------------------------- Build interface package |
| 56 | + - name: Restore interface |
| 57 | + run: dotnet restore Interface |
| 58 | + |
| 59 | + - name: Build interface |
| 60 | + run: dotnet build Interface --no-restore --configuration ${{matrix.configuration}} |
| 61 | + |
| 62 | + - name: Pack interface |
| 63 | + id: pack |
| 64 | + run: dotnet pack Interface --no-restore --no-build --configuration ${{matrix.configuration}} |
| 65 | + |
| 66 | + # ----------------------------------------------------------------------- Collect artifacts |
| 67 | + - name: Collect NuGet packages |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + if: matrix.collect-packages && steps.pack.outcome == 'success' && always() |
| 70 | + with: |
| 71 | + name: Packages |
| 72 | + if-no-files-found: error |
| 73 | + path: Interface/bin/${{matrix.configuration}}/** |
| 74 | + |
| 75 | + publish-packages-nuget-org: |
| 76 | + name: Publish packages to NuGet.org |
| 77 | + runs-on: ubuntu-latest |
| 78 | + permissions: |
| 79 | + # Needed to attach files to releases |
| 80 | + contents: write |
| 81 | + environment: public-release |
| 82 | + needs: build |
| 83 | + if: github.event_name == 'release' |
| 84 | + steps: |
| 85 | + # ----------------------------------------------------------------------- Set up .NET |
| 86 | + - name: Setup .NET |
| 87 | + uses: actions/setup-dotnet@v4 |
| 88 | + with: |
| 89 | + dotnet-version: 8.x |
| 90 | + |
| 91 | + # ----------------------------------------------------------------------- Download built packages |
| 92 | + - name: Download built packages |
| 93 | + uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + name: Packages |
| 96 | + path: artifacts/packages/ |
| 97 | + |
| 98 | + # ----------------------------------------------------------------------- Push to NuGet.org |
| 99 | + - name: Push to NuGet.org |
| 100 | + run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}} |
| 101 | + env: |
| 102 | + # This is a workaround for https://github.com/NuGet/Home/issues/9775 |
| 103 | + DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0 |
0 commit comments