-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Fix linux_packaging job being skipped when only packaging files change #26315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
65ae71d
Initial plan
Copilot 5635127
Make linux_packaging independent of ci_build
Copilot 0162f0f
Add Linux packaging paths to packagingChanged filter
Copilot 5b9659e
Fix trailing spaces in path-filters YAML
Copilot 0114e2f
Combine build and packaging into single step per reviewer feedback
Copilot d41793e
Add Start-PSBootstrap -Scenario Package to install packaging dependen…
Copilot 8232073
Remove redundant Sync-PSTags and -PSModuleRestore per reviewer feedback
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
.github/instructions/build-and-packaging-steps.instructions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| --- | ||
| applyTo: | ||
| - ".github/actions/**/*.yml" | ||
| - ".github/workflows/**/*.yml" | ||
| --- | ||
|
|
||
| # Build and Packaging Steps Pattern | ||
|
|
||
| ## Important Rule | ||
|
|
||
| **Build and packaging must run in the same step OR you must save and restore PSOptions between steps.** | ||
|
|
||
| ## Why This Matters | ||
|
|
||
| When `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. | ||
|
|
||
| GitHub Actions steps run in separate PowerShell sessions. This means PSOptions from one step are not available in the next step. | ||
|
|
||
| ## Pattern 1: Combined Build and Package (Recommended) | ||
|
|
||
| Run build and packaging in the same step to keep PSOptions in memory: | ||
|
|
||
| ```yaml | ||
| - name: Build and Package | ||
| run: |- | ||
| Import-Module ./tools/ci.psm1 | ||
| $releaseTag = Get-ReleaseTag | ||
| Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag | ||
| Invoke-CIFinish | ||
| shell: pwsh | ||
TravisEz13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| **Benefits:** | ||
| - Simpler code | ||
| - No need for intermediate files | ||
| - PSOptions automatically available to packaging | ||
|
|
||
| ## Pattern 2: Separate Steps with Save/Restore | ||
|
|
||
| If you must separate build and packaging into different steps: | ||
|
|
||
| ```yaml | ||
| - name: Build PowerShell | ||
| run: |- | ||
| Import-Module ./tools/ci.psm1 | ||
| $releaseTag = Get-ReleaseTag | ||
| Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag | ||
| Save-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json" | ||
| shell: pwsh | ||
|
|
||
| - name: Create Packages | ||
| run: |- | ||
| Import-Module ./tools/ci.psm1 | ||
| Restore-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json" | ||
| Invoke-CIFinish | ||
| shell: pwsh | ||
| ``` | ||
|
|
||
| **When to use:** | ||
| - When you need to run other steps between build and packaging | ||
| - When build and packaging require different permissions or environments | ||
|
|
||
| ## Common Mistakes | ||
|
|
||
| ### ❌ Incorrect: Separate steps without save/restore | ||
|
|
||
| ```yaml | ||
| - name: Build PowerShell | ||
| run: |- | ||
| Start-PSBuild -Configuration 'Release' | ||
| shell: pwsh | ||
|
|
||
| - name: Create Packages | ||
| run: |- | ||
| Invoke-CIFinish # ❌ FAILS: PSOptions not available | ||
| shell: pwsh | ||
| ``` | ||
|
|
||
| ### ❌ Incorrect: Using artifacts without PSOptions | ||
|
|
||
| ```yaml | ||
| - name: Download Build Artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: build | ||
|
|
||
| - name: Create Packages | ||
| run: |- | ||
| Invoke-CIFinish # ❌ FAILS: PSOptions not restored | ||
| shell: pwsh | ||
| ``` | ||
|
|
||
| ## Related Functions | ||
|
|
||
| - `Start-PSBuild` - Builds PowerShell and sets PSOptions | ||
| - `Save-PSOptions` - Saves PSOptions to a JSON file | ||
| - `Restore-PSOptions` - Loads PSOptions from a JSON file | ||
| - `Get-PSOptions` - Gets current PSOptions | ||
| - `Set-PSOptions` - Sets PSOptions | ||
| - `Start-PSPackage` - Creates packages (requires PSOptions) | ||
| - `Invoke-CIFinish` - Calls packaging (requires PSOptions on Linux/macOS) | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Linux Packaging Action | ||
|
|
||
| ```yaml | ||
| - name: Build and Package | ||
| run: |- | ||
| Import-Module ./tools/ci.psm1 | ||
| $releaseTag = Get-ReleaseTag | ||
| Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag | ||
| Invoke-CIFinish | ||
| shell: pwsh | ||
| ``` | ||
|
|
||
| ### Windows Packaging Workflow | ||
|
|
||
| ```yaml | ||
| - name: Build and Package | ||
| run: | | ||
| Import-Module .\tools\ci.psm1 | ||
| Invoke-CIFinish -Runtime ${{ matrix.runtimePrefix }}-${{ matrix.architecture }} -channel ${{ matrix.channel }} | ||
| shell: pwsh | ||
| ``` | ||
|
|
||
| Note: `Invoke-CIFinish` for Windows includes both build and packaging in its logic when `Stage` contains 'Build'. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.