diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c68d161..d820679 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-24.04 steps: - - name: Checkout + - name: Check out the sources uses: actions/checkout@v6 - name: Set up .NET SDK uses: actions/setup-dotnet@v5 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f7b370..5352981 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,17 +18,29 @@ on: jobs: verify-workflows: runs-on: ubuntu-24.04 + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: 1 + NUGET_PACKAGES: ${{ github.workspace }}/.github/nuget-packages steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 - name: Set up .NET SDK uses: actions/setup-dotnet@v5 + - name: Cache NuGet packages + uses: actions/cache@v5 + with: + key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.*proj', '**/*.props') }} + path: ${{ env.NUGET_PACKAGES }} - run: dotnet fsi ./scripts/github-actions.fsx verify check: strategy: matrix: image: - - macos-15 + - macos-14 - ubuntu-24.04 + - ubuntu-24.04-arm + - windows-11-arm - windows-2025 fail-fast: false runs-on: ${{ matrix.image }} @@ -37,15 +49,14 @@ jobs: DOTNET_NOLOGO: 1 NUGET_PACKAGES: ${{ github.workspace }}/.github/nuget-packages steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 - name: Set up .NET SDK - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: NuGet cache - uses: actions/cache@v4 + uses: actions/setup-dotnet@v5 + - name: Cache NuGet packages + uses: actions/cache@v5 with: - key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.csproj') }} + key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.*proj', '**/*.props') }} path: ${{ env.NUGET_PACKAGES }} - name: Build run: dotnet build @@ -55,19 +66,35 @@ jobs: licenses: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 - name: REUSE license check uses: fsfe/reuse-action@v6 encoding: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 - name: Verify encoding shell: pwsh run: scripts/Test-Encoding.ps1 nowarn-empty: runs-on: ubuntu-24.04 + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: 1 + NUGET_PACKAGES: ${{ github.workspace }}/.github/nuget-packages steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 + - name: Set up .NET SDK + uses: actions/setup-dotnet@v5 + - name: Cache NuGet packages + uses: actions/cache@v5 + with: + key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.*proj', '**/*.props') }} + path: ${{ env.NUGET_PACKAGES }} + - name: Check out the sources + uses: actions/checkout@v6 - name: Verify with NoWarn as empty run: dotnet build /p:NoWarn='' --no-incremental diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c747ba..c85c42c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,8 @@ jobs: contents: write runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v6 + - name: Check out the sources + uses: actions/checkout@v6 - id: version name: Get version shell: pwsh @@ -54,8 +55,8 @@ jobs: ./TruePath.SystemIo/bin/Release/TruePath.SystemIo.${{ steps.version.outputs.version }}.snupkg name: TruePath v${{ steps.version.outputs.version }} - if: startsWith(github.ref, 'refs/tags/v') - name: Push artifact to NuGet + name: Push TruePath to NuGet run: dotnet nuget push ./TruePath/bin/Release/TruePath.${{ steps.version.outputs.version }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN_TRUE_PATH }} - if: startsWith(github.ref, 'refs/tags/v') - name: Push artifact to NuGet + name: Push TruePath.SystemIo to NuGet run: dotnet nuget push ./TruePath.SystemIo/bin/Release/TruePath.SystemIo.${{ steps.version.outputs.version }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN_TRUE_PATH_SYSTEM_IO }} diff --git a/TruePath.sln b/TruePath.sln index 01b534b..d0459f9 100644 --- a/TruePath.sln +++ b/TruePath.sln @@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution REUSE.toml = REUSE.toml renovate.json = renovate.json renovate.json.license = renovate.json.license + global.json = global.json + global.json.license = global.json.license EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{8C064598-EE83-463D-9822-BAFA70B2C278}" diff --git a/global.json b/global.json new file mode 100644 index 0000000..c2af57a --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "10.0.102" + } +} diff --git a/global.json.license b/global.json.license new file mode 100644 index 0000000..ab33d72 --- /dev/null +++ b/global.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2026 Friedrich von Never + +SPDX-License-Identifier: MIT diff --git a/scripts/github-actions.fsx b/scripts/github-actions.fsx index 13561d7..dcf6494 100644 --- a/scripts/github-actions.fsx +++ b/scripts/github-actions.fsx @@ -5,14 +5,12 @@ let licenseHeader = """ # This file is auto-generated.""".Trim() -#r "nuget: Generaptor.Library, 1.9.1" +#r "nuget: Generaptor, 1.9.1" open System open Generaptor open Generaptor.GitHubActions open type Generaptor.GitHubActions.Commands -open type Generaptor.Library.Actions -open type Generaptor.Library.Patterns let mainBranch = "main" let ubuntu = "ubuntu-24.04" @@ -36,43 +34,83 @@ let workflows = [ yield! actions ] - workflow "main" [ - name "Main" - yield! mainTriggers + let checkOut = step( + name = "Check out the sources", + usesSpec = Auto "actions/checkout" + ) - job "verify-workflows" [ - runsOn "ubuntu-24.04" + let dotNetJob id steps = + job id [ + setEnv "DOTNET_CLI_TELEMETRY_OPTOUT" "1" + setEnv "DOTNET_NOLOGO" "1" + setEnv "NUGET_PACKAGES" "${{ github.workspace }}/.github/nuget-packages" - checkout + checkOut step( name = "Set up .NET SDK", usesSpec = Auto "actions/setup-dotnet" ) + step( + name = "Cache NuGet packages", + usesSpec = Auto "actions/cache", + options = Map.ofList [ + "key", "${{ runner.os }}.nuget.${{ hashFiles('**/*.*proj', '**/*.props') }}" + "path", "${{ env.NUGET_PACKAGES }}" + ] + ) + + yield! steps + ] + + workflow "main" [ + name "Main" + yield! mainTriggers + + dotNetJob "verify-workflows" [ + runsOn "ubuntu-24.04" step(run = "dotnet fsi ./scripts/github-actions.fsx verify") ] - job "check" [ - checkout - yield! dotNetBuildAndTest(projectFileExtensions = [".csproj"]) - ] |> addMatrix images + dotNetJob "check" [ + strategy(failFast = false, matrix = [ + "image", [ + "macos-14" + "ubuntu-24.04" + "ubuntu-24.04-arm" + "windows-11-arm" + "windows-2025" + ] + ]) + runsOn "${{ matrix.image }}" + + step( + name = "Build", + run = "dotnet build" + ) + step( + name = "Test", + run = "dotnet test", + timeoutMin = 10 + ) + ] job "licenses" [ runsOn ubuntu - checkout + checkOut step(name = "REUSE license check", usesSpec = Auto "fsfe/reuse-action") ] job "encoding" [ runsOn ubuntu - checkout + checkOut step(name = "Verify encoding", shell = "pwsh", run = "scripts/Test-Encoding.ps1") ] - job "nowarn-empty" [ + dotNetJob "nowarn-empty" [ runsOn ubuntu - checkout + checkOut step(name = "Verify with NoWarn as empty", run = "dotnet build /p:NoWarn='' --no-incremental") ] @@ -84,15 +122,22 @@ let workflows = [ onPushTags "v*" job "nuget" [ runsOn ubuntu - checkout + checkOut jobPermission(PermissionKind.Contents, AccessKind.Write) let configuration = "Release" let versionStepId = "version" let versionField = "${{ steps." + versionStepId + ".outputs.version }}" - getVersionWithScript(stepId = versionStepId, scriptPath = "scripts/Get-Version.ps1") - dotNetPack(version = versionField) + step( + id = "version", + name = "Get version", + shell = "pwsh", + run = "echo \"version=$(scripts/Get-Version.ps1 -RefName $env:GITHUB_REF)\" >> $env:GITHUB_OUTPUT" + ) + step( + run = "dotnet pack --configuration Release -p:Version=${{ steps.version.outputs.version }}" + ) let releaseNotes = "./release-notes.md" step( @@ -112,23 +157,35 @@ let workflows = [ yield! artifacts "TruePath" true yield! artifacts "TruePath.SystemIo" true ] - uploadArtifacts [ - releaseNotes - yield! allArtifacts - ] - yield! ifCalledOnTagPush [ - createRelease( - name = $"TruePath v{versionField}", - releaseNotesPath = releaseNotes, - files = allArtifacts - ) - yield! pushToNuGetOrg "NUGET_TOKEN_TRUE_PATH" ( - artifacts "TruePath" false - ) - yield! pushToNuGetOrg "NUGET_TOKEN_TRUE_PATH_SYSTEM_IO" ( - artifacts "TruePath.SystemIo" false - ) - ] + + step( + name = "Upload artifacts", + usesSpec = Auto "actions/upload-artifact", + options = Map.ofList [ + "path", [ releaseNotes; yield! allArtifacts ] |> String.concat "\n" + ] + ) + + step( + condition = "startsWith(github.ref, 'refs/tags/v')", + name = "Create a release", + usesSpec = Auto "softprops/action-gh-release", + options = Map.ofList [ + "body_path", "./release-notes.md" + "files", allArtifacts |> String.concat "\n" + "name", $"TruePath v{versionField}" + ] + ) + step( + condition = "startsWith(github.ref, 'refs/tags/v')", + name = "Push TruePath to NuGet", + run = $"dotnet nuget push ./TruePath/bin/Release/TruePath.{versionField}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{{{ secrets.NUGET_TOKEN_TRUE_PATH }}}}" + ) + step( + condition = "startsWith(github.ref, 'refs/tags/v')", + name = "Push TruePath.SystemIo to NuGet", + run = $"dotnet nuget push ./TruePath.SystemIo/bin/Release/TruePath.SystemIo.{versionField}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{{{ secrets.NUGET_TOKEN_TRUE_PATH_SYSTEM_IO }}}}" + ) ] ] @@ -146,10 +203,7 @@ let workflows = [ job "publish-docs" [ environment(name = "github-pages", url = "${{ steps.deployment.outputs.page_url }}") runsOn "ubuntu-24.04" - step( - name = "Checkout", - usesSpec = Auto "actions/checkout" - ) + checkOut step( name = "Set up .NET SDK", usesSpec = Auto "actions/setup-dotnet",