|
| 1 | +name: IKVM.Logging |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build |
| 14 | + runs-on: windows-2022 |
| 15 | + steps: |
| 16 | + - name: Checkout Source |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + submodules: recursive |
| 21 | + - name: Setup .NET 3.1 |
| 22 | + uses: actions/setup-dotnet@v3 |
| 23 | + with: |
| 24 | + dotnet-version: 3.1.x |
| 25 | + - name: Setup .NET 6.0 |
| 26 | + uses: actions/setup-dotnet@v3 |
| 27 | + with: |
| 28 | + dotnet-version: 6.0.x |
| 29 | + - name: Setup .NET 7.0 |
| 30 | + uses: actions/setup-dotnet@v3 |
| 31 | + with: |
| 32 | + dotnet-version: 7.0.x |
| 33 | + - name: Install GitVersion |
| 34 | + uses: gittools/actions/gitversion/[email protected] |
| 35 | + with: |
| 36 | + versionSpec: 5.x |
| 37 | + - name: Execute GitVersion |
| 38 | + uses: gittools/actions/gitversion/[email protected] |
| 39 | + with: |
| 40 | + useConfigFile: true |
| 41 | + - name: Move NuGet Directory |
| 42 | + shell: pwsh |
| 43 | + run: Add-Content $env:GITHUB_ENV "`nNUGET_PACKAGES=${{ runner.temp }}\nuget\packages" |
| 44 | + - name: Add NuGet Source (GitHub) |
| 45 | + shell: pwsh |
| 46 | + run: dotnet nuget add source --username USERNAME --password $env:GITHUB_TOKEN --store-password-in-clear-text --name ikvm $env:GITHUB_REPOS |
| 47 | + env: |
| 48 | + GITHUB_REPOS: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + - name: Cache NuGet |
| 51 | + uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: ${{ runner.temp }}\nuget\packages |
| 54 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**\*.csproj', '**\*.msbuildproj') }}-1 |
| 55 | + restore-keys: ${{ runner.os }}-nuget- |
| 56 | + - name: NuGet Restore |
| 57 | + run: dotnet restore IKVM.Logging.sln |
| 58 | + - name: Build |
| 59 | + run: | |
| 60 | + dotnet msbuild /m /bl ` |
| 61 | + /p:Configuration="Release" ` |
| 62 | + /p:Platform="Any CPU" ` |
| 63 | + /p:Version=${env:GitVersion_FullSemVer} ` |
| 64 | + /p:AssemblyVersion=${env:GitVersion_AssemblySemVer} ` |
| 65 | + /p:InformationalVersion=${env:GitVersion_InformationalVersion} ` |
| 66 | + /p:FileVersion=${env:GitVersion_AssemblySemFileVer} ` |
| 67 | + /p:PackageVersion=${env:GitVersion_NuGetVersionV2} ` |
| 68 | + /p:RepositoryUrl="${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}.git" ` |
| 69 | + /p:PackageProjectUrl="${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}" ` |
| 70 | + /p:BuildInParallel=true ` |
| 71 | + /p:CreateHardLinksForAdditionalFilesIfPossible=true ` |
| 72 | + /p:CreateHardLinksForCopyAdditionalFilesIfPossible=true ` |
| 73 | + /p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true ` |
| 74 | + /p:CreateHardLinksForCopyLocalIfPossible=true ` |
| 75 | + /p:CreateHardLinksForPublishFilesIfPossible=true ` |
| 76 | + /p:ContinuousIntegrationBuild=true ` |
| 77 | + IKVM.Logging.dist.msbuildproj |
| 78 | + - name: Upload MSBuild Log |
| 79 | + if: ${{ always() }} |
| 80 | + uses: actions/upload-artifact@v3 |
| 81 | + with: |
| 82 | + name: msbuild.binlog |
| 83 | + path: msbuild.binlog |
| 84 | + - name: Upload NuGet Packages |
| 85 | + uses: actions/upload-artifact@v3 |
| 86 | + with: |
| 87 | + name: nuget |
| 88 | + path: dist/nuget |
| 89 | + - name: Package Tests |
| 90 | + run: tar czvf tests.tar.gz tests |
| 91 | + working-directory: dist |
| 92 | + - name: Upload Tests |
| 93 | + uses: actions/upload-artifact@v3 |
| 94 | + with: |
| 95 | + name: tests |
| 96 | + path: dist/tests.tar.gz |
| 97 | + test: |
| 98 | + strategy: |
| 99 | + matrix: |
| 100 | + sys: |
| 101 | + - windows |
| 102 | + - linux |
| 103 | + - macos |
| 104 | + tfm: |
| 105 | + - net461 |
| 106 | + - netcoreapp3.1 |
| 107 | + - net6.0 |
| 108 | + - net7.0 |
| 109 | + exclude: |
| 110 | + - tfm: net461 |
| 111 | + sys: linux |
| 112 | + - tfm: net461 |
| 113 | + sys: macos |
| 114 | + - tfm: netcoreapp3.1 |
| 115 | + sys: macos |
| 116 | + name: Test (${{ matrix.sys }}:${{ matrix.tfm }}) |
| 117 | + needs: |
| 118 | + - build |
| 119 | + runs-on: ${{ fromJSON('{"windows":["windows-2022"],"linux":["ubuntu-22.04"],"macos":["macos-latest"]}')[matrix.sys] }} |
| 120 | + steps: |
| 121 | + - name: Setup .NET 3.1 |
| 122 | + uses: actions/setup-dotnet@v3 |
| 123 | + with: |
| 124 | + dotnet-version: 3.1.x |
| 125 | + - name: Setup .NET 6.0 |
| 126 | + uses: actions/setup-dotnet@v3 |
| 127 | + with: |
| 128 | + dotnet-version: 6.0.x |
| 129 | + - name: Setup .NET 7.0 |
| 130 | + uses: actions/setup-dotnet@v3 |
| 131 | + with: |
| 132 | + dotnet-version: 7.0.x |
| 133 | + - name: Add NuGet Source (GitHub) |
| 134 | + shell: pwsh |
| 135 | + run: dotnet nuget add source --username USERNAME --password $env:GITHUB_TOKEN --store-password-in-clear-text --name ikvm $env:GITHUB_REPOS |
| 136 | + env: |
| 137 | + GITHUB_REPOS: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json |
| 138 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 139 | + - name: Download Tests |
| 140 | + uses: actions/download-artifact@v3 |
| 141 | + with: |
| 142 | + name: tests |
| 143 | + - name: Restore Tests |
| 144 | + run: tar xzvf tests.tar.gz |
| 145 | + - name: Execute Tests |
| 146 | + timeout-minutes: 480 |
| 147 | + shell: pwsh |
| 148 | + run: | |
| 149 | + # assign powershell variables |
| 150 | + $run = "${{ matrix.run }}" |
| 151 | + $tfm = "${{ matrix.tfm }}" |
| 152 | + $sys = "${{ matrix.sys }}" |
| 153 | +
|
| 154 | + # suite name can contain filter expression after ? |
| 155 | + $split = $run.IndexOf("?") |
| 156 | + if ($split -gt -1) { |
| 157 | + $tst = $run.Substring(0, $split) |
| 158 | + $qry = $run.Substring($split + 1) |
| 159 | + } else { |
| 160 | + $tst = $run |
| 161 | + } |
| 162 | +
|
| 163 | + # scan for test assemblies |
| 164 | + $tests = $(gci .\tests\$tst\$tfm -Recurse -Filter '*.Tests.dll') |
| 165 | +
|
| 166 | + # if a query was specified, add to test command |
| 167 | + if ($tests) { |
| 168 | + if ($qry -ne "" -and $qry -ne $null) { |
| 169 | + Add-Content $env:GITHUB_ENV "`nRET=TestResults--$tst-$qry--$tfm--$sys" |
| 170 | + dotnet test -f $tfm --blame -v 2 --results-directory "TestResults" --logger:"console;verbosity=detailed" --logger:trx --collect "Code Coverage" --filter "$qry" $tests |
| 171 | + } else { |
| 172 | + Add-Content $env:GITHUB_ENV "`nRET=TestResults--$tst--$tfm--$sys" |
| 173 | + dotnet test -f $tfm --blame -v 2 --results-directory "TestResults" --logger:"console;verbosity=detailed" --logger:trx --collect "Code Coverage" $tests |
| 174 | + } |
| 175 | + } |
| 176 | + - name: Archive Test Results |
| 177 | + if: always() && startsWith(env.RET, 'TestResults--') |
| 178 | + run: tar czvf TestResults.tar.gz TestResults |
| 179 | + working-directory: ${{ env.IKVMPATH }} |
| 180 | + - name: Upload Test Results |
| 181 | + if: always() && startsWith(env.RET, 'TestResults--') |
| 182 | + uses: actions/upload-artifact@v3 |
| 183 | + with: |
| 184 | + name: ${{ env.RET }} |
| 185 | + path: TestResults.tar.gz |
| 186 | + release: |
| 187 | + name: Release |
| 188 | + needs: |
| 189 | + - test |
| 190 | + runs-on: ubuntu-latest |
| 191 | + steps: |
| 192 | + - name: Checkout Source |
| 193 | + uses: actions/checkout@v3 |
| 194 | + with: |
| 195 | + fetch-depth: 0 |
| 196 | + - name: Setup .NET 7.0 |
| 197 | + uses: actions/setup-dotnet@v3 |
| 198 | + with: |
| 199 | + dotnet-version: 7.0.x |
| 200 | + - name: Install GitVersion |
| 201 | + uses: gittools/actions/gitversion/[email protected] |
| 202 | + with: |
| 203 | + versionSpec: 5.x |
| 204 | + - name: Execute GitVersion |
| 205 | + id: GitVersion |
| 206 | + uses: gittools/actions/gitversion/[email protected] |
| 207 | + with: |
| 208 | + useConfigFile: true |
| 209 | + - name: Download NuGet Packages |
| 210 | + uses: actions/download-artifact@v3 |
| 211 | + with: |
| 212 | + name: nuget |
| 213 | + path: dist |
| 214 | + - name: Create Release |
| 215 | + if: github.ref_type == 'tag' |
| 216 | + uses: ncipollo/release-action@v1 |
| 217 | + with: |
| 218 | + tag: ${{ github.ref_name }} |
| 219 | + allowUpdates: true |
| 220 | + artifacts: dist/nuget/*.nupkg,dist/nuget/*.snupkg |
| 221 | + draft: false |
| 222 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 223 | + - name: Push NuGet (GitHub) |
| 224 | + shell: pwsh |
| 225 | + run: dotnet nuget push dist/nuget/*.nupkg --source $env:GITHUB_REPOS --api-key $env:GITHUB_TOKEN --skip-duplicate --no-symbols |
| 226 | + env: |
| 227 | + GITHUB_REPOS: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json |
| 228 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 229 | + - name: Push NuGet |
| 230 | + if: github.ref_type == 'tag' |
| 231 | + shell: pwsh |
| 232 | + run: dotnet nuget push dist/nuget/*.nupkg --source $env:NUGET_REPOS --api-key $env:NUGET_TOKEN --skip-duplicate |
| 233 | + env: |
| 234 | + NUGET_REPOS: https://api.nuget.org/v3/index.json |
| 235 | + NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} |
0 commit comments