From 52cd5585b1520d7f3530d199fa0a17f4985f9e01 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 25 May 2026 21:31:17 -0700 Subject: [PATCH] ci: delegate to PowerShellOrg reusable workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CI.yml now calls powershell-ci.yml@main (PS 5.1 + 7.x, all platforms, installs deps and runs Init/Test/Analyze directly via Invoke-psake) - publish.yml added: triggers on v* tags, calls powershell-release.yml@main (Init → Test → Analyze → Build → Publish → GitHub Release) - psakeFile.ps1: add Analyze task (required by both reusable workflows) and wire $PSBPreference.Publish.ApiKey from $env:PSGALLERY_API_KEY Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 83 ++++------------------------------- .github/workflows/publish.yml | 32 ++++++++++++++ psakeFile.ps1 | 8 +++- 3 files changed, 47 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e01c24c..6c56d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,80 +1,13 @@ name: CI on: - push: - branches: [main] - paths: - - "PSDepend/**" - - "Tests/**" - - "build.ps1" - - "psakeFile.ps1" - - "requirements.psd1" pull_request: - paths: - - "PSDepend/**" - - "Tests/**" - - "build.ps1" - - "psakeFile.ps1" - - "requirements.psd1" workflow_dispatch: - +permissions: + checks: write + pull-requests: write + contents: read + issues: write jobs: - test_pwsh: - name: Test (${{ matrix.os }}) - runs-on: ${{ matrix.os }} - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - steps: - - uses: actions/checkout@v6 - - name: Bootstrap - shell: pwsh - run: ./build.ps1 -Bootstrap -Task Init - - name: Test - shell: pwsh - run: ./build.ps1 -Task Test - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v7 - with: - name: testResults-${{ matrix.os }} - path: ./Tests/out/testResults.xml - - test_ps51: - name: Test (Windows PowerShell 5.1) - runs-on: windows-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v6 - - name: Bootstrap - shell: powershell - run: ./build.ps1 -Bootstrap -Task Init - - name: Test - shell: powershell - run: ./build.ps1 -Task Test - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v7 - with: - name: testResults-ps51 - path: ./Tests/out/testResults.xml - publish-test-results: - name: Publish Test Results - needs: - - test_pwsh - - test_ps51 - runs-on: ubuntu-latest - permissions: - checks: write - pull-requests: write - if: ${{ !cancelled() }} - steps: - - uses: actions/download-artifact@v8 - with: - path: artifacts - - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - files: artifacts/**/*.xml + ci: + name: Continuous Integration + uses: PowerShellOrg/.github/.github/workflows/powershell-ci.yml@main diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..68578ca --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Publish Module +on: + push: + branches: + - main + workflow_dispatch: + inputs: + version: + description: "The version to publish. Leave empty to use the version in the module manifest." + required: false + type: string + isPrerelease: + description: "Is this a prerelease version?" + required: false + type: boolean + default: false + dry_run: + description: "If true, skip actual publishing and just validate the workflow logic." + required: false + type: boolean + default: false +permissions: + contents: write +jobs: + publish: + name: Publish Module + uses: PowerShellOrg/.github/.github/workflows/powershell-release.yml@main + with: + version: ${{ inputs.version || '' }} + isPrerelease: ${{ inputs.isPrerelease || false }} + dry_run: ${{ inputs.dry_run || false }} + secrets: inherit diff --git a/psakeFile.ps1 b/psakeFile.ps1 index 4880197..52d3f4c 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -22,6 +22,8 @@ Properties { if (-not $IsWindows) { $PSBPreference.Test.ExcludeTagFilter = @('WindowsOnly') } + + $PSBPreference.Publish.ApiKey = $env:PSGALLERY_API_KEY } # Pre-set before -FromModule so PowerShellBuild 0.7.x's null-check doesn't override it. @@ -31,7 +33,11 @@ $PSBBuildDependency = @('StageFiles') # Override with: .\build.ps1 InstallLocal -Properties @{PreReleaseLabel='rc1'} Task InstallLocal -Depends StageFiles { - $label = if ($PreReleaseLabel) { $PreReleaseLabel } else { "pre-$(git rev-parse --short HEAD)" } + $label = if ($PreReleaseLabel) { + $PreReleaseLabel + } else { + "pre-$(git rev-parse --short HEAD)" + } $moduleName = $PSBPreference.General.ModuleName $stagedDir = $PSBPreference.Build.ModuleOutDir