From ac0edb3ce4b5e2c450085faa9a971aa901ab4ae9 Mon Sep 17 00:00:00 2001 From: richardsondev Date: Sat, 18 Apr 2026 19:37:02 -0700 Subject: [PATCH] chore: enable Node.js 24 for GitHub Actions Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true environment variable to all workflows to ensure JavaScript-based actions run on Node.js 24. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/build.yml | 223 +++++++++++++++++---------------- .github/workflows/pages.yml | 241 ++++++++++++++++++------------------ 2 files changed, 235 insertions(+), 229 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7981623..fe28c97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,120 +1,123 @@ -name: Build and Test - -on: - push: - branches: - - main - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - pull_request: - branches: - - main - workflow_dispatch: - -permissions: - contents: read - packages: read - actions: read - -jobs: - build: - runs-on: windows-latest - timeout-minutes: 10 - - outputs: - VERSION: ${{ steps.get_version.outputs.VERSION }} - - steps: - - name: Checkout repository +name: Build and Test + +on: + push: + branches: + - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + packages: read + actions: read + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + build: + runs-on: windows-latest + timeout-minutes: 10 + + outputs: + VERSION: ${{ steps.get_version.outputs.VERSION }} + + steps: + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 1 - - - name: Setup .NET Core SDK + with: + fetch-depth: 1 + + - name: Setup .NET Core SDK uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5 - with: - dotnet-version: '9.0.x' - - - name: Set version - id: get_version - shell: pwsh - run: | - $TAG = if ($env:GITHUB_REF -like "refs/tags/v*") { - $env:GITHUB_REF -replace 'refs/tags/v', '' - } else { - "" - } - - if ($TAG -ne "") { - $VERSION = $TAG - } else { - # Fallback to commit hash if no tag - $COMMIT_HASH = git rev-parse --short HEAD - $VERSION = "0.0.1-$COMMIT_HASH" - } - - echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT - - - name: Generate SBOM for the project + with: + dotnet-version: '9.0.x' + + - name: Set version + id: get_version + shell: pwsh + run: | + $TAG = if ($env:GITHUB_REF -like "refs/tags/v*") { + $env:GITHUB_REF -replace 'refs/tags/v', '' + } else { + "" + } + + if ($TAG -ne "") { + $VERSION = $TAG + } else { + # Fallback to commit hash if no tag + $COMMIT_HASH = git rev-parse --short HEAD + $VERSION = "0.0.1-$COMMIT_HASH" + } + + echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT + + - name: Generate SBOM for the project uses: advanced-security/generate-sbom-action@67c5cda0176c46ce546d2fee672f72cee7fd620f # v1 - id: gensbom - - - name: Build AggregateConfigBuildTask solution in Release mode - run: dotnet build src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} - - - name: Run tests for AggregateConfigBuildTask solution - run: dotnet test src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true --no-build - - - name: Upload SBOM artifact + id: gensbom + + - name: Build AggregateConfigBuildTask solution in Release mode + run: dotnet build src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} + + - name: Run tests for AggregateConfigBuildTask solution + run: dotnet test src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true --no-build + + - name: Upload SBOM artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - name: sbom - path: ${{ steps.gensbom.outputs.fileName }} - - - name: Upload NuGetPackage artifact + with: + name: sbom + path: ${{ steps.gensbom.outputs.fileName }} + + - name: Upload NuGetPackage artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - name: NuGetPackage - path: | - src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg - src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg - - integration_tests: - needs: build - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} - timeout-minutes: 10 - - steps: - - name: Checkout repository + with: + name: NuGetPackage + path: | + src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg + src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg + + integration_tests: + needs: build + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + + steps: + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 1 - - - name: Setup .NET Core SDK + with: + fetch-depth: 1 + + - name: Setup .NET Core SDK uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5 - with: - dotnet-version: '9.0.x' - - - name: Download NuGetPackage artifact + with: + dotnet-version: '9.0.x' + + - name: Download NuGetPackage artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: NuGetPackage - path: ./nuget/local - - - name: Add local NuGet source - run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask - - - name: Build IntegrationTests in Release mode - run: dotnet build test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:UseLocalPackageVersion=true - - - name: Run IntegrationTests - run: dotnet test test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true -p:UseLocalPackageVersion=true - - - name: Upload integration results artifact + with: + name: NuGetPackage + path: ./nuget/local + + - name: Add local NuGet source + run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask + + - name: Build IntegrationTests in Release mode + run: dotnet build test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:UseLocalPackageVersion=true + + - name: Run IntegrationTests + run: dotnet test test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true -p:UseLocalPackageVersion=true + + - name: Upload integration results artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - name: IntegrationTestResults-${{ matrix.os }} + with: + name: IntegrationTestResults-${{ matrix.os }} path: test/IntegrationTests/out/ diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 252f8e6..ea1bbaf 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,124 +1,127 @@ -name: Deploy content to Pages - -on: - push: - branches: ["main"] - - workflow_dispatch: - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - deploy: - environment: - name: github-pages - #url: ${{ steps.deployment.outputs.page_url }} - - runs-on: windows-latest - steps: - - name: Checkout +name: Deploy content to Pages + +on: + push: + branches: ["main"] + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + deploy: + environment: + name: github-pages + #url: ${{ steps.deployment.outputs.page_url }} + + runs-on: windows-latest + steps: + - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup .NET Core SDK + + - name: Setup .NET Core SDK uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5 - with: - dotnet-version: '9.0.x' - dotnet-quality: 'preview' - - - name: Setup Pages + with: + dotnet-version: '9.0.x' + dotnet-quality: 'preview' + + - name: Setup Pages uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 - - - name: Download DocFX - shell: pwsh - run: | - Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.77.0/docfx-win-x64-v2.77.0.zip -OutFile docfx.zip - - - name: Extract DocFX - shell: pwsh - run: | - Expand-Archive -Path docfx.zip -DestinationPath ./docfx - - - name: Download material.zip - shell: pwsh - run: | - Invoke-WebRequest -Uri https://github.com/ovasquez/docfx-material/releases/download/1.0.0/material.zip -OutFile material.zip - - - name: Extract material.zip - shell: pwsh - run: | - Expand-Archive -Path material.zip -DestinationPath ./ - - - name: Add header to README.md - shell: pwsh - run: | - Add-Content -Path temp.md -Value "---" - Add-Content -Path temp.md -Value "outputFileName: index.html" - Add-Content -Path temp.md -Value "---" - Get-Content -Path README.md | Add-Content -Path temp.md - Move-Item -Path temp.md -Destination README.md -Force - - - name: Build documentation - shell: pwsh - run: .\docfx\docfx.exe docfx.json - - - name: Inject canonicals & fix index.html anchors - shell: pwsh - run: | - $Origin = 'https://docs.richardson.dev/AggregateConfigBuildTask' - $SiteRoot = Resolve-Path _site - - # Add canonical to every generated index.html - Get-ChildItem $SiteRoot -Recurse -Filter index.html | ForEach-Object { - $rel = ($_.FullName.Substring($SiteRoot.Path.Length) -replace '\\','/') - $canon = $Origin + ($rel -replace 'index\.html$','') - - (Get-Content $_.FullName -Raw) -replace '', ( - "`n" - ) | Set-Content $_.FullName - } - - # Replace anchor HREFs ending in "/index.html" (with or without fragment) - Get-ChildItem $SiteRoot -Recurse -Filter *.html | ForEach-Object { - (Get-Content $_.FullName -Raw) ` - -replace '(href=`"[^`"]*?)index\.html(?=[#`"])', '$1' ` - -replace '(href=`"[^`"]*?)index\.html`"', '$1`"' | - Set-Content $_.FullName - } - - - name: Install html-minifier-terser - run: npm install -g html-minifier-terser - - - name: Minify HTML output - shell: pwsh - run: | - html-minifier-terser ` - --input-dir _site ` - --output-dir _site ` - --file-ext html ` - --remove-comments ` - --remove-optional-tags ` - --minify-css true ` - --minify-js true - - - name: Upload artifact + + - name: Download DocFX + shell: pwsh + run: | + Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.77.0/docfx-win-x64-v2.77.0.zip -OutFile docfx.zip + + - name: Extract DocFX + shell: pwsh + run: | + Expand-Archive -Path docfx.zip -DestinationPath ./docfx + + - name: Download material.zip + shell: pwsh + run: | + Invoke-WebRequest -Uri https://github.com/ovasquez/docfx-material/releases/download/1.0.0/material.zip -OutFile material.zip + + - name: Extract material.zip + shell: pwsh + run: | + Expand-Archive -Path material.zip -DestinationPath ./ + + - name: Add header to README.md + shell: pwsh + run: | + Add-Content -Path temp.md -Value "---" + Add-Content -Path temp.md -Value "outputFileName: index.html" + Add-Content -Path temp.md -Value "---" + Get-Content -Path README.md | Add-Content -Path temp.md + Move-Item -Path temp.md -Destination README.md -Force + + - name: Build documentation + shell: pwsh + run: .\docfx\docfx.exe docfx.json + + - name: Inject canonicals & fix index.html anchors + shell: pwsh + run: | + $Origin = 'https://docs.richardson.dev/AggregateConfigBuildTask' + $SiteRoot = Resolve-Path _site + + # Add canonical to every generated index.html + Get-ChildItem $SiteRoot -Recurse -Filter index.html | ForEach-Object { + $rel = ($_.FullName.Substring($SiteRoot.Path.Length) -replace '\\','/') + $canon = $Origin + ($rel -replace 'index\.html$','') + + (Get-Content $_.FullName -Raw) -replace '', ( + "`n" + ) | Set-Content $_.FullName + } + + # Replace anchor HREFs ending in "/index.html" (with or without fragment) + Get-ChildItem $SiteRoot -Recurse -Filter *.html | ForEach-Object { + (Get-Content $_.FullName -Raw) ` + -replace '(href=`"[^`"]*?)index\.html(?=[#`"])', '$1' ` + -replace '(href=`"[^`"]*?)index\.html`"', '$1`"' | + Set-Content $_.FullName + } + + - name: Install html-minifier-terser + run: npm install -g html-minifier-terser + + - name: Minify HTML output + shell: pwsh + run: | + html-minifier-terser ` + --input-dir _site ` + --output-dir _site ` + --file-ext html ` + --remove-comments ` + --remove-optional-tags ` + --minify-css true ` + --minify-js true + + - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - name: Documentation - path: | - ./_site - - - name: Upload to Pages + with: + name: Documentation + path: | + ./_site + + - name: Upload to Pages uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4 - with: - path: '_site/' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 + with: + path: '_site/' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0