|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + tags: |
| 7 | + - "*" |
| 8 | + pull_request: |
| 9 | +jobs: |
| 10 | + calculate-version: |
| 11 | + runs-on: ubuntu-20.04 |
| 12 | + outputs: |
| 13 | + version: ${{ steps.version.outputs.version }} |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@master |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Install GitVersion |
| 20 | + uses: gittools/actions/gitversion/setup@v0.9.9 |
| 21 | + with: |
| 22 | + versionSpec: "5.6.9" |
| 23 | + - name: Run GitVersion |
| 24 | + id: gitversion |
| 25 | + uses: gittools/actions/gitversion/execute@v0.9.9 |
| 26 | + - name: Version |
| 27 | + id: version |
| 28 | + run: | |
| 29 | + version=${{ steps.gitversion.outputs.nuGetVersionV2 }} |
| 30 | + if [ "${{ github.event_name }}" == "pull_request" ] |
| 31 | + then |
| 32 | + version=${version}-${{ steps.gitversion.outputs.shortSha }} |
| 33 | + fi |
| 34 | + echo "::set-output name=version::${version}" |
| 35 | + build: |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + needs: [calculate-version] |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + include: |
| 41 | + - os: ubuntu-20.04 |
| 42 | + integrationTest: true |
| 43 | + nugetPush: false |
| 44 | + - os: windows-2019 |
| 45 | + integrationTest: false |
| 46 | + nugetPush: true |
| 47 | + - os: macos-10.15 |
| 48 | + integrationTest: false |
| 49 | + nugetPush: false |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@master |
| 53 | + with: |
| 54 | + fetch-depth: 0 |
| 55 | + submodules: recursive |
| 56 | + - name: Setup dotnet SDK 3 |
| 57 | + uses: actions/setup-dotnet@v1 |
| 58 | + with: |
| 59 | + dotnet-version: "3.1.411" |
| 60 | + - name: Setup dotnet SDK 5 # This gets us net461 |
| 61 | + uses: actions/setup-dotnet@v1 |
| 62 | + with: |
| 63 | + dotnet-version: "5.0.300" |
| 64 | + - name: Build |
| 65 | + run: | |
| 66 | + dotnet build -c Release -p:Version=${{ needs.calculate-version.outputs.version }} |
| 67 | + shell: bash |
| 68 | + - name: Test |
| 69 | + run: dotnet test -c Release --no-build |
| 70 | + shell: bash |
| 71 | + - name: Integration Tests |
| 72 | + if: ${{ matrix.integrationTest }} |
| 73 | + run: ./test/Website/IntegrationTests/run.sh |
| 74 | + shell: bash |
| 75 | + - name: Archive NuGet Packages |
| 76 | + uses: actions/upload-artifact@v2 |
| 77 | + if: ${{ matrix.nugetPush }} |
| 78 | + with: |
| 79 | + name: packages |
| 80 | + path: | |
| 81 | + **/*.nupkg |
| 82 | + **/*.snupkg |
| 83 | + retention-days: 1 |
| 84 | + nuget-push: |
| 85 | + runs-on: ubuntu-20.04 |
| 86 | + needs: [build] |
| 87 | + if: github.event_name != 'pull_request' |
| 88 | + steps: |
| 89 | + - name: Download NuGet Packages |
| 90 | + uses: actions/download-artifact@v2 |
| 91 | + with: |
| 92 | + name: packages |
| 93 | + - name: NuGet Push |
| 94 | + run: dotnet nuget push **/*.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} |
0 commit comments