|
| 1 | +name: .NET |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - 'preview/**' |
| 7 | + - 'release/**' |
| 8 | + - 'support/**' |
| 9 | + paths-ignore: |
| 10 | + - '!src/**' |
| 11 | + |
| 12 | +permissions: |
| 13 | + actions: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: build-${{ github.head_ref || github.ref }} |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +env: |
| 22 | + dotnet-sdk-version: '9.x' |
| 23 | + build-configuration: 'Release' |
| 24 | + build-platform: 'Any CPU' |
| 25 | + git-version: '6.0.x' |
| 26 | + test-result-directory: 'test-results' |
| 27 | + |
| 28 | +jobs: |
| 29 | + versioning: |
| 30 | + name: Versioning with GitVersion |
| 31 | + runs-on: ubuntu-latest |
| 32 | + outputs: |
| 33 | + ASSEMBLY_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }} |
| 34 | + ASSEMBLY_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}+${{ steps.gitversion.outputs.sha }} |
| 35 | + FILE_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }} |
| 36 | + PACKAGE_VERSION: ${{ fromJSON(format('[ "{0}{1}", "{0}" ]', steps.gitversion.outputs.assemblySemVer, steps.gitversion.outputs.preReleaseLabelWithDash))[fromJSON(env.is-release)] }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + - name: Install GitVersion ${{ env.git-version }} |
| 44 | + uses: gittools/actions/gitversion/setup@v3.1.11 |
| 45 | + with: |
| 46 | + versionSpec: ${{ env.git-version }} |
| 47 | + preferLatestVersion: true |
| 48 | + - name: Determine version with GitVersion ${{ env.git-version }} |
| 49 | + id: gitversion |
| 50 | + uses: gittools/actions/gitversion/execute@v3.1.11 |
| 51 | + with: |
| 52 | + useConfigFile: true |
| 53 | + configFilePath: ./.gitversion/version.yml |
| 54 | + |
| 55 | + build: |
| 56 | + name: Build with .NET |
| 57 | + needs: [versioning] |
| 58 | + runs-on: ubuntu-latest |
| 59 | + env: |
| 60 | + ASSEMBLY_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_VERSION }} |
| 61 | + ASSEMBLY_INFORMATIONAL_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_INFORMATIONAL_VERSION }} |
| 62 | + FILE_VERSION: ${{ needs.versioning.outputs.FILE_VERSION }} |
| 63 | + steps: |
| 64 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - uses: ./.github/actions/build |
| 68 | + with: |
| 69 | + assembly-version: ${{ env.ASSEMBLY_VERSION }} |
| 70 | + assembly-informational-version: ${{ env.ASSEMBLY_INFORMATIONAL_VERSION }} |
| 71 | + assembly-file-version: ${{ env.FILE_VERSION }} |
| 72 | + treat-warnins-as-error: ${{ env.is-release }} |
| 73 | + build-glob-pattern: ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} |
| 74 | + |
| 75 | + test: |
| 76 | + name: Test with .NET |
| 77 | + needs: [build] |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 81 | + uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: 'Setup .NET' |
| 84 | + uses: actions/setup-dotnet@v4 |
| 85 | + with: |
| 86 | + dotnet-version: ${{ env.dotnet-sdk-version }} |
| 87 | + |
| 88 | + - uses: ./.github/actions/test |
| 89 | + with: |
| 90 | + test-project-glob-pattern: ${{ vars.TEST_DEFAULT_GLOB_PATTERN }} |
| 91 | + test-results-directory: '${{ runner.temp }}/test-results/' |
| 92 | + code-coverage-settings-file: '${{ github.workspace}}/code-coverage-settings.xml' |
| 93 | + |
| 94 | + - uses: ./.github/actions/test-report |
| 95 | + id: test-report |
| 96 | + with: |
| 97 | + test-result-folder: '${{ runner.temp }}/test-results/' |
| 98 | + |
| 99 | + - name: Write test report summary |
| 100 | + uses: ./.github/action/write-file-to-summary |
| 101 | + with: |
| 102 | + file-path: ${{ steps.test-report.outputs.test-report-file }} |
| 103 | + |
| 104 | + - uses: ./.github/actions/code-coverage |
| 105 | + id: code-coverage-report |
| 106 | + with: |
| 107 | + test-result-folder: '${{ runner.temp }}/test-results/' |
| 108 | + |
| 109 | + - name: Write code coverage report summary |
| 110 | + uses: ./.github/action/write-file-to-summary |
| 111 | + with: |
| 112 | + file-path: ${{ steps.code-coverage-report.outputs.code-coverage-report-file }} |
| 113 | + |
| 114 | + pack: |
| 115 | + name: Pack with .NET |
| 116 | + needs: [build, versioning] |
| 117 | + runs-on: ubuntu-latest |
| 118 | + env: |
| 119 | + ASSEMBLY_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_VERSION }} |
| 120 | + ASSEMBLY_INFORMATIONAL_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_INFORMATIONAL_VERSION }} |
| 121 | + FILE_VERSION: ${{ needs.versioning.outputs.FILE_VERSION }} |
| 122 | + PACKAGE_VERSION: ${{ needs.versioning.outputs.PACKAGE_VERSION }} |
| 123 | + steps: |
| 124 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 125 | + uses: actions/checkout@v4 |
| 126 | + - name: Setup .NET |
| 127 | + uses: actions/setup-dotnet@v4 |
| 128 | + with: |
| 129 | + dotnet-version: ${{ env.dotnet-sdk-version }} |
| 130 | + - name: Download Build |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + name: build |
| 134 | + - name: Pack with .NET |
| 135 | + run: | |
| 136 | + dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.PACKAGE_VERSION }} /p:Version=${{ env.ASSEMBLY_VERSION }} /p:AssemblyInformationalVersion=${{ env.ASSEMBLY_INFORMATIONAL_VERSION }} /p:FileVersion=${{ env.FILE_VERSION }} --output ${{ runner.temp }}/packages/ |
| 137 | + - name: Upload Package |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: package |
| 141 | + path: | |
| 142 | + ${{ runner.temp }}/packages/**/*.nupkg |
| 143 | + ${{ runner.temp }}/packages/**/*.snupkg |
| 144 | +
|
| 145 | + publish-internal-package: |
| 146 | + if: ${{ !github.env.is_release }} |
| 147 | + name: Publish package with .NET CLI |
| 148 | + needs: [pack] |
| 149 | + runs-on: ubuntu-latest |
| 150 | + steps: |
| 151 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 152 | + uses: actions/checkout@v4 |
| 153 | + - name: Dotnet Setup |
| 154 | + uses: actions/setup-dotnet@v4 |
| 155 | + with: |
| 156 | + dotnet-version: ${{ env.dotnet-sdk-version }} |
| 157 | + - name: Download Packages |
| 158 | + uses: actions/download-artifact@v4 |
| 159 | + with: |
| 160 | + name: package |
| 161 | + path: ${{ runner.temp }}/packages/ |
| 162 | + - run: | |
| 163 | + dotnet nuget add source ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_URL }} --name private-feed --username username --password ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }} --store-password-in-clear-text |
| 164 | + dotnet nuget push **/*.nupkg --source private-feed --api-key ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }} |
| 165 | + working-directory: ${{ runner.temp }}/packages/ |
0 commit comments