|
| 1 | +name: Plan |
| 2 | + |
| 3 | +# The Plan job is the single decision point for the workflow. |
| 4 | +# It runs two steps: |
| 5 | +# 1. Get-PSModuleSettings - loads and resolves configuration |
| 6 | +# 2. Resolve-PSModuleVersion - calculates the next version from settings + PR labels |
| 7 | +# The resolved version is merged into the Settings object (Settings.Module.*) by the Enrich-Settings step. |
| 8 | +# All downstream jobs receive one self-contained Settings JSON with no separate version outputs. |
| 9 | + |
| 10 | +on: |
| 11 | + workflow_call: |
| 12 | + inputs: |
| 13 | + SettingsPath: |
| 14 | + type: string |
| 15 | + description: The path to the settings file. |
| 16 | + required: false |
| 17 | + Debug: |
| 18 | + type: boolean |
| 19 | + description: Enable debug output. |
| 20 | + required: false |
| 21 | + default: false |
| 22 | + Verbose: |
| 23 | + type: boolean |
| 24 | + description: Enable verbose output. |
| 25 | + required: false |
| 26 | + default: false |
| 27 | + Version: |
| 28 | + type: string |
| 29 | + description: Specifies the version of the GitHub module to be installed. The value must be an exact version. |
| 30 | + required: false |
| 31 | + default: '' |
| 32 | + Prerelease: |
| 33 | + type: boolean |
| 34 | + description: Whether to use a prerelease version of the 'GitHub' module. |
| 35 | + required: false |
| 36 | + default: false |
| 37 | + WorkingDirectory: |
| 38 | + type: string |
| 39 | + description: The path to the root of the repo. |
| 40 | + required: false |
| 41 | + default: '.' |
| 42 | + ImportantFilePatterns: |
| 43 | + type: string |
| 44 | + description: | |
| 45 | + Newline-separated list of regex patterns that identify important files. |
| 46 | + Changes matching these patterns trigger build, test, and publish stages. |
| 47 | + When set, fully replaces the defaults (^src/ and ^README\.md$). |
| 48 | + required: false |
| 49 | + default: | |
| 50 | + ^src/ |
| 51 | + ^README\.md$ |
| 52 | +
|
| 53 | + outputs: |
| 54 | + Settings: |
| 55 | + description: The complete settings object including test suites and resolved module version. |
| 56 | + value: ${{ jobs.Plan.outputs.Settings }} |
| 57 | + |
| 58 | +permissions: |
| 59 | + contents: read # to checkout the repo |
| 60 | + pull-requests: write # to add labels / comments to PRs |
| 61 | + |
| 62 | +jobs: |
| 63 | + Plan: |
| 64 | + name: Plan |
| 65 | + runs-on: ubuntu-latest |
| 66 | + outputs: |
| 67 | + Settings: ${{ steps.Enrich-Settings.outputs.Settings }} |
| 68 | + steps: |
| 69 | + - name: Checkout Code |
| 70 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 71 | + with: |
| 72 | + persist-credentials: false |
| 73 | + fetch-depth: 0 |
| 74 | + |
| 75 | + - name: Get-Settings |
| 76 | + uses: PSModule/Get-PSModuleSettings@1e3d156786c56e6fbd839a1ba5ab21ff8858090e # v1.5.0 |
| 77 | + id: Get-Settings |
| 78 | + with: |
| 79 | + SettingsPath: ${{ inputs.SettingsPath }} |
| 80 | + Debug: ${{ inputs.Debug }} |
| 81 | + Prerelease: ${{ inputs.Prerelease }} |
| 82 | + Verbose: ${{ inputs.Verbose }} |
| 83 | + Version: ${{ inputs.Version }} |
| 84 | + WorkingDirectory: ${{ inputs.WorkingDirectory }} |
| 85 | + ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }} |
| 86 | + |
| 87 | + - name: Resolve-Version |
| 88 | + uses: PSModule/Resolve-PSModuleVersion@d53326c7687d20a7949d457fccd71223856b1890 # v1.1.0 |
| 89 | + id: Resolve-Version |
| 90 | + env: |
| 91 | + GH_TOKEN: ${{ github.token }} |
| 92 | + with: |
| 93 | + Settings: ${{ steps.Get-Settings.outputs.Settings }} |
| 94 | + Name: ${{ fromJson(steps.Get-Settings.outputs.Settings).Name }} |
| 95 | + Debug: ${{ inputs.Debug }} |
| 96 | + Verbose: ${{ inputs.Verbose }} |
| 97 | + WorkingDirectory: ${{ inputs.WorkingDirectory }} |
| 98 | + |
| 99 | + - name: Enrich-Settings |
| 100 | + # Merge the resolved version into the Settings object so all downstream jobs |
| 101 | + # receive a single, self-contained Settings JSON with no separate version outputs. |
| 102 | + id: Enrich-Settings |
| 103 | + shell: pwsh |
| 104 | + env: |
| 105 | + SETTINGS: ${{ steps.Get-Settings.outputs.Settings }} |
| 106 | + VERSION: ${{ steps.Resolve-Version.outputs.Version }} |
| 107 | + PRERELEASE: ${{ steps.Resolve-Version.outputs.Prerelease }} |
| 108 | + FULL_VERSION: ${{ steps.Resolve-Version.outputs.FullVersion }} |
| 109 | + RELEASE_TYPE: ${{ steps.Resolve-Version.outputs.ReleaseType }} |
| 110 | + CREATE_RELEASE: ${{ steps.Resolve-Version.outputs.CreateRelease }} |
| 111 | + run: | |
| 112 | + $settings = $env:SETTINGS | ConvertFrom-Json |
| 113 | + $settings | Add-Member -MemberType NoteProperty -Name Module -Value ([pscustomobject]@{ |
| 114 | + Version = $env:VERSION |
| 115 | + Prerelease = $env:PRERELEASE |
| 116 | + FullVersion = $env:FULL_VERSION |
| 117 | + ReleaseType = if ([string]::IsNullOrEmpty($env:RELEASE_TYPE)) { 'None' } else { $env:RELEASE_TYPE } |
| 118 | + CreateRelease = $env:CREATE_RELEASE -eq 'true' |
| 119 | + }) |
| 120 | + $enriched = $settings | ConvertTo-Json -Depth 10 -Compress |
| 121 | + "Settings=$enriched" >> $env:GITHUB_OUTPUT |
0 commit comments