Skip to content

Commit 1c072ff

Browse files
committed
Show .NET info on all hosted images
1 parent 17cb827 commit 1c072ff

File tree

1 file changed

+3
-280
lines changed

1 file changed

+3
-280
lines changed

.github/workflows/build.yml

+3-280
Original file line numberDiff line numberDiff line change
@@ -30,288 +30,11 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
os: [ubuntu-latest, windows-latest, macos-latest]
33+
os: [ubuntu-latest, ubuntu-24.04, ubuntu-20.04, windows-latest, windows-2019, macos-latest, macos-latest-large, macos-13, macos-13-xlarge, macos-12, macos-11]
3434
runs-on: ${{ matrix.os }}
3535
permissions:
3636
contents: read
3737
steps:
38-
- name: Tune GitHub-hosted runner network
39-
uses: smorimoto/tune-github-hosted-runner-network@v1
40-
- name: Setup PostgreSQL
41-
uses: ikalnytskyi/action-setup-postgres@v6
42-
with:
43-
username: postgres
44-
password: postgres
45-
- name: Setup .NET
46-
uses: actions/setup-dotnet@v4
47-
with:
48-
dotnet-version: |
49-
6.0.x
50-
8.0.x
51-
- name: Setup PowerShell (Ubuntu)
52-
if: matrix.os == 'ubuntu-latest'
38+
- name: Show .NET info
5339
run: |
54-
dotnet tool install --global PowerShell
55-
- name: Find latest PowerShell version (Windows)
56-
if: matrix.os == 'windows-latest'
57-
shell: pwsh
58-
run: |
59-
$packageName = "powershell"
60-
$outputText = dotnet tool search $packageName --take 1
61-
$outputLine = ("" + $outputText)
62-
$indexOfVersionLine = $outputLine.IndexOf($packageName)
63-
$latestVersion = $outputLine.substring($indexOfVersionLine + $packageName.length).trim().split(" ")[0].trim()
64-
65-
Write-Output "Found PowerShell version: $latestVersion"
66-
Write-Output "POWERSHELL_LATEST_VERSION=$latestVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
67-
- name: Setup PowerShell (Windows)
68-
if: matrix.os == 'windows-latest'
69-
shell: cmd
70-
run: |
71-
set DOWNLOAD_LINK=https://github.com/PowerShell/PowerShell/releases/download/v%POWERSHELL_LATEST_VERSION%/PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
72-
set OUTPUT_PATH=%RUNNER_TEMP%\PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
73-
echo Downloading from: %DOWNLOAD_LINK% to: %OUTPUT_PATH%
74-
curl --location --output %OUTPUT_PATH% %DOWNLOAD_LINK%
75-
msiexec.exe /package %OUTPUT_PATH% /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1
76-
- name: Setup PowerShell (macOS)
77-
if: matrix.os == 'macos-latest'
78-
run: |
79-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
80-
brew install --cask powershell
81-
- name: Show installed versions
82-
shell: pwsh
83-
run: |
84-
Write-Host "$(pwsh --version) is installed at $PSHOME"
85-
psql --version
86-
Write-Host "Active .NET SDK: $(dotnet --version)"
87-
- name: Git checkout
88-
uses: actions/checkout@v4
89-
- name: Restore tools
90-
run: |
91-
dotnet tool restore
92-
- name: Restore packages
93-
run: |
94-
dotnet restore
95-
- name: Calculate version suffix
96-
shell: pwsh
97-
run: |
98-
if ($env:GITHUB_REF_TYPE -eq 'tag') {
99-
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
100-
$segments = $env:GITHUB_REF_NAME -split "-"
101-
$versionPrefix = $segments[0].TrimStart('v')
102-
$versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'
103-
104-
[xml]$xml = Get-Content Directory.Build.props
105-
$configuredVersionPrefix = $xml.Project.PropertyGroup.JsonApiDotNetCoreVersionPrefix | Select-Object -First 1
106-
107-
if ($configuredVersionPrefix -ne $versionPrefix) {
108-
Write-Error "Version prefix from git release tag '$versionPrefix' does not match version prefix '$configuredVersionPrefix' stored in Directory.Build.props."
109-
# To recover from this:
110-
# - Delete the GitHub release
111-
# - Run: git push --delete origin the-invalid-tag-name
112-
# - Adjust JsonApiDotNetCoreVersionPrefix in Directory.Build.props, commit and push
113-
# - Recreate the GitHub release
114-
}
115-
}
116-
else {
117-
# Get the version suffix from the auto-incrementing build number. For example: '123' => 'master-00123'
118-
$revision = "{0:D5}" -f [convert]::ToInt32($env:GITHUB_RUN_NUMBER, 10)
119-
$branchName = ![string]::IsNullOrEmpty($env:GITHUB_HEAD_REF) ? $env:GITHUB_HEAD_REF : $env:GITHUB_REF_NAME
120-
$safeName = $branchName.Replace('/', '-').Replace('_', '-')
121-
$versionSuffix = "$safeName-$revision"
122-
}
123-
Write-Output "Using version suffix: $versionSuffix"
124-
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
125-
- name: Build
126-
shell: pwsh
127-
run: |
128-
dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
129-
- name: Test
130-
env:
131-
# Override log levels, to reduce logging output when running tests in ci-build.
132-
Logging__LogLevel__Microsoft.Hosting.Lifetime: 'None'
133-
Logging__LogLevel__Microsoft.AspNetCore.Hosting.Diagnostics: 'None'
134-
Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host: 'None'
135-
Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command: 'None'
136-
Logging__LogLevel__JsonApiDotNetCore: 'None'
137-
run: |
138-
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
139-
- name: Upload coverage to codecov.io
140-
if: matrix.os == 'ubuntu-latest'
141-
env:
142-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
143-
uses: codecov/codecov-action@v4
144-
with:
145-
fail_ci_if_error: true
146-
verbose: true
147-
- name: Generate packages
148-
shell: pwsh
149-
run: |
150-
dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
151-
- name: Upload packages to artifacts
152-
if: matrix.os == 'ubuntu-latest'
153-
uses: actions/upload-artifact@v4
154-
with:
155-
name: packages
156-
path: artifacts/packages
157-
- name: Generate documentation
158-
shell: pwsh
159-
env:
160-
# This contains the git tag name on release; in that case we build the docs without publishing them.
161-
DOCFX_SOURCE_BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
162-
run: |
163-
cd docs
164-
& ./generate-examples.ps1
165-
dotnet docfx docfx.json
166-
if ($LastExitCode -ne 0) {
167-
Write-Error "docfx failed with exit code $LastExitCode."
168-
}
169-
Copy-Item CNAME _site/CNAME
170-
Copy-Item home/*.html _site/
171-
Copy-Item home/*.ico _site/
172-
New-Item -Force _site/styles -ItemType Directory | Out-Null
173-
Copy-Item -Recurse home/assets/* _site/styles/
174-
- name: Upload documentation to artifacts
175-
if: matrix.os == 'ubuntu-latest'
176-
uses: actions/upload-artifact@v4
177-
with:
178-
name: documentation
179-
path: docs/_site
180-
181-
inspect-code:
182-
timeout-minutes: 60
183-
strategy:
184-
fail-fast: false
185-
matrix:
186-
os: [ubuntu-latest, windows-latest, macos-latest]
187-
runs-on: ${{ matrix.os }}
188-
permissions:
189-
contents: read
190-
steps:
191-
- name: Tune GitHub-hosted runner network
192-
uses: smorimoto/tune-github-hosted-runner-network@v1
193-
- name: Setup .NET
194-
uses: actions/setup-dotnet@v4
195-
with:
196-
dotnet-version: |
197-
6.0.x
198-
8.0.x
199-
- name: Git checkout
200-
uses: actions/checkout@v4
201-
- name: Restore tools
202-
run: |
203-
dotnet tool restore
204-
- name: InspectCode
205-
shell: pwsh
206-
run: |
207-
$inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml'
208-
Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
209-
dotnet jb inspectcode JsonApiDotNetCore.sln --build --dotnetcoresdk=$(dotnet --version) --output="$inspectCodeOutputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
210-
- name: Verify outcome
211-
shell: pwsh
212-
run: |
213-
[xml]$xml = Get-Content $env:INSPECT_CODE_OUTPUT_PATH
214-
if ($xml.report.Issues -and $xml.report.Issues.Project) {
215-
foreach ($project in $xml.report.Issues.Project) {
216-
if ($project.Issue.Count -gt 0) {
217-
$project.ForEach({
218-
Write-Output "`nProject $($project.Name)"
219-
$failed = $true
220-
221-
$_.Issue.ForEach({
222-
$issueType = $xml.report.IssueTypes.SelectSingleNode("IssueType[@Id='$($_.TypeId)']")
223-
$severity = $_.Severity ?? $issueType.Severity
224-
225-
Write-Output "[$severity] $($_.File):$($_.Line) $($_.TypeId): $($_.Message)"
226-
})
227-
})
228-
}
229-
}
230-
231-
if ($failed) {
232-
Write-Error "One or more projects failed code inspection."
233-
}
234-
}
235-
236-
cleanup-code:
237-
timeout-minutes: 60
238-
strategy:
239-
fail-fast: false
240-
matrix:
241-
os: [ubuntu-latest, windows-latest, macos-latest]
242-
runs-on: ${{ matrix.os }}
243-
permissions:
244-
contents: read
245-
steps:
246-
- name: Tune GitHub-hosted runner network
247-
uses: smorimoto/tune-github-hosted-runner-network@v1
248-
- name: Setup .NET
249-
uses: actions/setup-dotnet@v4
250-
with:
251-
dotnet-version: |
252-
6.0.x
253-
8.0.x
254-
- name: Git checkout
255-
uses: actions/checkout@v4
256-
with:
257-
fetch-depth: 2
258-
- name: Restore tools
259-
run: |
260-
dotnet tool restore
261-
- name: Restore packages
262-
run: |
263-
dotnet restore
264-
- name: CleanupCode (on PR diff)
265-
if: github.event_name == 'pull_request'
266-
shell: pwsh
267-
run: |
268-
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
269-
# The below works because HEAD is detached (at the merge commit), so HEAD~1 is at the base branch. When a PR contains no commits, this job will not run.
270-
$headCommitHash = git rev-parse HEAD
271-
$baseCommitHash = git rev-parse HEAD~1
272-
273-
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
274-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
275-
- name: CleanupCode (on branch)
276-
if: github.event_name == 'push' || github.event_name == 'release'
277-
shell: pwsh
278-
run: |
279-
Write-Output "Running code cleanup on all files."
280-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff
281-
282-
publish:
283-
timeout-minutes: 60
284-
runs-on: ubuntu-latest
285-
needs: [ build-and-test, inspect-code, cleanup-code ]
286-
if: ${{ !github.event.pull_request.head.repo.fork }}
287-
permissions:
288-
packages: write
289-
contents: write
290-
steps:
291-
- name: Tune GitHub-hosted runner network
292-
uses: smorimoto/tune-github-hosted-runner-network@v1
293-
- name: Download artifacts
294-
uses: actions/download-artifact@v4
295-
- name: Publish to GitHub Packages
296-
if: github.event_name == 'push' || github.event_name == 'release'
297-
env:
298-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
299-
shell: pwsh
300-
run: |
301-
dotnet nuget add source --username 'json-api-dotnet' --password "$env:GITHUB_TOKEN" --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
302-
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:GITHUB_TOKEN" --source 'github'
303-
- name: Publish documentation
304-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
305-
uses: peaceiris/actions-gh-pages@v4
306-
with:
307-
github_token: ${{ secrets.GITHUB_TOKEN }}
308-
publish_branch: gh-pages
309-
publish_dir: ./documentation
310-
commit_message: 'Auto-generated documentation from'
311-
- name: Publish to NuGet
312-
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
313-
env:
314-
NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
315-
shell: pwsh
316-
run: |
317-
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org'
40+
dotnet --info

0 commit comments

Comments
 (0)