You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
242 lines
8.3 KiB
242 lines
8.3 KiB
name: build
|
|
|
|
on:
|
|
push:
|
|
branches: [ dev, release/* ]
|
|
tags: [ '*' ]
|
|
pull_request:
|
|
branches: [ dev, release/* ]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
DOTNET_MULTILEVEL_LOOKUP: 0
|
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
|
|
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
|
|
NUGET_XMLDOC_MODE: skip
|
|
TERM: xterm
|
|
ContinuousIntegrationBuild: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
name: build-${{ matrix.os }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
outputs:
|
|
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}
|
|
|
|
permissions:
|
|
attestations: write
|
|
contents: read
|
|
id-token: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ xcode-27, ubuntu-24.04, windows-2022 ]
|
|
include:
|
|
- os: xcode-27
|
|
os_name: macos
|
|
- os: ubuntu-24.04
|
|
os_name: linux
|
|
- os: windows-2022
|
|
os_name: windows
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Select Xcode 27.2
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
run: |
|
|
export DEVELOPER_DIR=/Applications/Xcode_27.2.app/Contents/Developer
|
|
xcodebuild -version
|
|
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
|
|
|
|
- name: Set up .NET SDK
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
id: setup-dotnet
|
|
|
|
- name: Set up .NET 10 SDK and runtime
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
with:
|
|
dotnet-version: 10.0.115
|
|
|
|
- name: Set package version
|
|
shell: pwsh
|
|
run: |
|
|
$Version = dotnet msbuild src/OpenIddict.Core/OpenIddict.Core.csproj -getProperty:PreReleaseVersionLabel,PreReleaseVersionIteration,VersionSuffix
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Failed to determine the version suffix (exit code $LASTEXITCODE)."
|
|
}
|
|
$Version = $Version | ConvertFrom-Json
|
|
$Suffix = $Version.Properties.VersionSuffix
|
|
|
|
if (-not $env:GITHUB_REF.StartsWith("refs/pull/") -and -not [string]::IsNullOrWhiteSpace($Version.Properties.PreReleaseVersionLabel)) {
|
|
$Suffix = $Version.Properties.PreReleaseVersionLabel
|
|
if (-not [string]::IsNullOrWhiteSpace($Version.Properties.PreReleaseVersionIteration)) {
|
|
$Suffix += ".$($Version.Properties.PreReleaseVersionIteration)"
|
|
}
|
|
$Suffix += ".$env:GITHUB_RUN_NUMBER"
|
|
}
|
|
|
|
"VersionSuffix=$Suffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
- name: Restore .NET workloads
|
|
shell: pwsh
|
|
run: dotnet workload restore
|
|
|
|
- name: Restore dependencies
|
|
shell: pwsh
|
|
run: dotnet restore --artifacts-path artifacts -p:Configuration=Release "-p:VersionSuffix=$env:VersionSuffix"
|
|
|
|
- name: Build solution
|
|
shell: pwsh
|
|
run: dotnet build --configuration Release --no-restore --artifacts-path artifacts "-p:VersionSuffix=$env:VersionSuffix" -bl:artifacts/log/Release/build.binlog
|
|
|
|
- name: Run tests
|
|
shell: pwsh
|
|
run: |
|
|
$projects = Get-ChildItem test -Filter "*.csproj" -Recurse
|
|
foreach ($project in $projects) {
|
|
$metadata = dotnet msbuild $project.FullName -getProperty:TargetFrameworks,TargetFramework | ConvertFrom-Json
|
|
$frameworks = $metadata.Properties.TargetFrameworks
|
|
if ([string]::IsNullOrWhiteSpace($frameworks)) {
|
|
$frameworks = $metadata.Properties.TargetFramework
|
|
}
|
|
|
|
foreach ($framework in $frameworks -split ";" | ForEach-Object { $_.Trim() } | Where-Object { $_ }) {
|
|
if ($framework -eq "net48" -and $env:RUNNER_OS -ne "Windows") {
|
|
continue
|
|
}
|
|
|
|
dotnet test $project.FullName --framework $framework --configuration Release --no-build --no-restore --artifacts-path artifacts "-p:VersionSuffix=$env:VersionSuffix" --logger trx --results-directory artifacts/TestResults/Release
|
|
if ($LASTEXITCODE -ne 0) {
|
|
exit $LASTEXITCODE
|
|
}
|
|
}
|
|
}
|
|
|
|
- name: Pack NuGet packages
|
|
shell: pwsh
|
|
run: dotnet pack --configuration Release --no-build --no-restore --artifacts-path artifacts "-p:VersionSuffix=$env:VersionSuffix" "-p:PackageOutputPath=$env:GITHUB_WORKSPACE/artifacts/packages/Release/Shipping"
|
|
|
|
- name: Attest artifacts
|
|
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
|
|
if: |
|
|
runner.os == 'Windows' &&
|
|
github.event.repository.fork == false &&
|
|
startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
subject-path: |
|
|
./artifacts/bin/**/OpenIddict.*.dll
|
|
./artifacts/packages/Release/Shipping/*
|
|
|
|
- name: Publish logs
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: logs-${{ matrix.os_name }}
|
|
path: ./artifacts/log/Release
|
|
|
|
- name: Publish NuGet packages
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: packages-${{ matrix.os_name }}
|
|
path: ./artifacts/packages/Release/Shipping
|
|
|
|
- name: Publish test results
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: testresults-${{ matrix.os_name }}
|
|
path: ./artifacts/TestResults/Release
|
|
|
|
validate-packages:
|
|
needs: build
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download packages
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: packages-windows
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
with:
|
|
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
|
|
|
|
- name: Validate NuGet packages
|
|
shell: pwsh
|
|
run: |
|
|
dotnet tool install --global dotnet-validate --version 0.0.1-preview.304 --allow-roll-forward
|
|
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
|
|
$invalidPackages = 0
|
|
foreach ($package in $packages) {
|
|
dotnet validate package local $package
|
|
if ($LASTEXITCODE -ne 0) {
|
|
$invalidPackages++
|
|
}
|
|
}
|
|
if ($invalidPackages -gt 0) {
|
|
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
|
|
exit 1
|
|
}
|
|
|
|
push-packages-myget:
|
|
needs: [ build, validate-packages ]
|
|
runs-on: ubuntu-24.04
|
|
if: |
|
|
(github.ref_name == github.event.repository.default_branch ||
|
|
startsWith(github.ref, 'refs/heads/dev') ||
|
|
startsWith(github.ref, 'refs/heads/release/') ||
|
|
startsWith(github.ref, 'refs/tags/'))
|
|
steps:
|
|
- name: Download packages
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: packages-windows
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
with:
|
|
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
|
|
|
|
- name: Push packages to MyGet.org
|
|
env:
|
|
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
|
|
run: dotnet nuget push "*.nupkg" --api-key "${MYGET_API_KEY}" --skip-duplicate --source https://www.myget.org/F/openiddict/api/v3/index.json
|
|
|
|
push-packages-nuget:
|
|
needs: [ build, validate-packages ]
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
if: |
|
|
github.event.repository.fork == false &&
|
|
startsWith(github.ref, 'refs/tags/')
|
|
steps:
|
|
- name: Download packages
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: packages-windows
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
with:
|
|
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
|
|
|
|
- name: Login to NuGet.org (Trusted Publishing)
|
|
id: nuget-login
|
|
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
|
|
with:
|
|
user: ${{ secrets.NUGET_USER }}
|
|
|
|
- name: Push packages to NuGet.org
|
|
env:
|
|
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
|
|
run: dotnet nuget push "*.nupkg" --api-key "${NUGET_API_KEY}" --skip-duplicate --source https://api.nuget.org/v3/index.json
|
|
|