

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1234567# Build and Packaging Steps Pattern89## Important Rule1011**Build and packaging must run in the same step OR you must save and restore PSOptions between steps.**1213## Why This Matters1415When `Start-PSBuild` runs, it creates PSOptions that contain build configuration details (runtime, configuration, output path, etc.). The packaging functions like `Start-PSPackage` and `Invoke-CIFinish` rely on these PSOptions to know where the build output is located and how it was built.1617GitHub Actions steps run in separate PowerShell sessions. This means PSOptions from one step are not available in the next step.1819## Pattern 1: Combined Build and Package (Recommended)2021Run build and packaging in the same step to keep PSOptions in memory:2223```yaml24- name: Build and Package25 run: |-26 Import-Module ./tools/ci.psm127 $releaseTag = Get-ReleaseTag28 Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag29 Invoke-CIFinish30 shell: pwsh31```3233**Benefits:**34- Simpler code35- No need for intermediate files36- PSOptions automatically available to packaging3738## Pattern 2: Separate Steps with Save/Restore3940If you must separate build and packaging into different steps:4142```yaml43- name: Build PowerShell44 run: |-45 Import-Module ./tools/ci.psm146 $releaseTag = Get-ReleaseTag47 Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag48 Save-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json"49 shell: pwsh5051- name: Create Packages52 run: |-53 Import-Module ./tools/ci.psm154 Restore-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json"55 Invoke-CIFinish56 shell: pwsh57```5859**When to use:**60- When you need to run other steps between build and packaging61- When build and packaging require different permissions or environments6263## Common Mistakes6465### ❌ Incorrect: Separate steps without save/restore6667```yaml68- name: Build PowerShell69 run: |-70 Start-PSBuild -Configuration 'Release'71 shell: pwsh7273- name: Create Packages74 run: |-75 Invoke-CIFinish # ❌ FAILS: PSOptions not available76 shell: pwsh77```7879### ❌ Incorrect: Using artifacts without PSOptions8081```yaml82- name: Download Build Artifacts83 uses: actions/download-artifact@v484 with:85 name: build8687- name: Create Packages88 run: |-89 Invoke-CIFinish # ❌ FAILS: PSOptions not restored90 shell: pwsh91```9293## Related Functions9495- `Start-PSBuild` - Builds PowerShell and sets PSOptions96- `Save-PSOptions` - Saves PSOptions to a JSON file97- `Restore-PSOptions` - Loads PSOptions from a JSON file98- `Get-PSOptions` - Gets current PSOptions99- `Set-PSOptions` - Sets PSOptions100- `Start-PSPackage` - Creates packages (requires PSOptions)101- `Invoke-CIFinish` - Calls packaging (requires PSOptions on Linux/macOS)102103## Examples104105### Linux Packaging Action106107```yaml108- name: Build and Package109 run: |-110 Import-Module ./tools/ci.psm1111 $releaseTag = Get-ReleaseTag112 Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag113 Invoke-CIFinish114 shell: pwsh115```116117### Windows Packaging Workflow118119```yaml120- name: Build and Package121 run: |122 Import-Module .\tools\ci.psm1123 Invoke-CIFinish -Runtime ${{ matrix.runtimePrefix }}-${{ matrix.architecture }} -channel ${{ matrix.channel }}124 shell: pwsh125```126127Note: `Invoke-CIFinish` for Windows includes both build and packaging in its logic when `Stage` contains 'Build'.128
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| PowerShell/PowerShell.github/instructions/build-checkout-prerequisites.instructions.md · 55k | Copilot instructions | setupbuildstylearch+1 | 81/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/code-review-branch-strategy.instructions.md · 55k | Copilot instructions | lint-formatstyletypesgit+1 | 62/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/instruction-file-format.instructions.md · 55k | Copilot instructions | buildlint-formatstylearch+3 | 76/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/log-grouping-guidelines.instructions.md · 55k | Copilot instructions | buildtestdo-not | 77/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-condition-syntax.instructions.md · 55k | Copilot instructions | buildstylearchdeployment+1 | 73/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-restore-phase-pattern.instructions.md · 55k | Copilot instructions | arch | 54/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-signing-configuration.instructions.md · 55k | Copilot instructions | buildstyledeployment | 62/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-module-organization.instructions.md · 55k | Copilot instructions | buildteststylearch+2 | 69/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-parameter-naming.instructions.md · 55k | Copilot instructions | styledo-not | 65/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/publishing-pester-result.instructions.md · 55k | Copilot instructions | testlint-formatstylearch+3 | 69/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/script-module-file-format.instructions.md · 55k | Copilot instructions | lint-format | 54/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/start-native-execution.instructions.md · 55k | Copilot instructions | buildstylearchgit+1 | 86/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/start-psbuild-basics.instructions.md · 55k | Copilot instructions | buildtesting-strategydeploymentagent-behaviour | 54/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/troubleshooting-builds.instructions.md · 55k | Copilot instructions | buildgitdeployment | 54/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/build-configuration-guide.instructions.md · 55k | Copilot instructions | buildteststyletesting-strategy+2 | 74/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/pester-set-itresult-pattern.instructions.md · 55k | Copilot instructions | setupstylearch | 62/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-automatic-variables.instructions.md · 55k | Copilot instructions | stylearchgitdeployment+1 | 69/100 | 14 days ago | |
| PowerShell/PowerShell.github/instructions/pester-test-status-and-working-meaning.instructions.md · 55k | Copilot instructions | teststyle | 54/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 14 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 14 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | 7 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 13 days ago | |
| rtk-ai/rtk.github/copilot-instructions.md · 75k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 14 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 14 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 7 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/powershell-powershell-github-instructions-build-and-packaging-steps-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.