Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/actions/infrastructure/path-filters/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ outputs:
buildModuleChanged:
description: 'Build module changes'
value: ${{ steps.filter.outputs.buildModuleChanged }}
packagingChanged:
description: 'Packaging related changes'
value: ${{ steps.filter.outputs.packagingChanged }}
runs:
using: composite
steps:
Expand Down Expand Up @@ -85,6 +88,19 @@ runs:

const globalConfigChanged = files.some(file => file.filename.startsWith('.globalconfig')) || files.some(file => file.filename.startsWith('nuget.config')) || files.some(file => file.filename.startsWith('global.json'));

const packagingChanged = files.some(file =>
file.filename === '.github/workflows/windows-ci.yml' ||
file.filename.startsWith('assets/wix/') ||
file.filename === 'PowerShell.Common.props' ||
file.filename.match(/^src\/.*\.csproj$/) ||
file.filename.startsWith('test/packaging/windows/') ||
file.filename.startsWith('tools/packaging/') ||
file.filename.startsWith('tools/wix/')
) ||
buildModuleChanged ||
globalConfigChanged ||
toolsCiPsm1Changed;

const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged || globalConfigChanged;

core.setOutput('toolsChanged', toolsChanged);
Expand All @@ -94,6 +110,7 @@ runs:
core.setOutput('mainSourceChanged', mainSourceChanged);
core.setOutput('buildModuleChanged', buildModuleChanged);
core.setOutput('globalConfigChanged', globalConfigChanged);
core.setOutput('packagingChanged', packagingChanged);
core.setOutput('source', source);


Expand All @@ -106,4 +123,5 @@ runs:
Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}"
Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}"
Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}"
Write-Verbose -Verbose "packaging: ${{ steps.filter.outputs.packagingChanged }}"
shell: pwsh
112 changes: 57 additions & 55 deletions .github/actions/test/linux-packaging/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
name: linux_packaging
description: 'Test very basic Linux packaging'

# This isn't working yet
# It fails with

# ERROR: While executing gem ... (Gem::FilePermissionError)
# You don't have write permissions for the /var/lib/gems/2.7.0 directory.
# WARNING: Installation of gem dotenv 2.8.1 failed! Must resolve manually.
description: 'Linux packaging for PowerShell'

runs:
using: composite
Expand All @@ -15,58 +8,64 @@ runs:
if: success() || failure()
run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose'
shell: pwsh

- uses: actions/setup-dotnet@v5
with:
global-json-file: ./global.json

- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
path: "${{ github.workspace }}"
name: build
path: "${{ runner.workspace }}/build"

- name: Capture Artifacts Directory
continue-on-error: true
run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
run: Get-ChildItem "${{ runner.workspace }}/build/*" -Recurse
shell: pwsh

- name: Bootstrap
run: |-
Import-Module ./build.psm1
Start-PSBootstrap -Scenario Package
Write-Verbose -Verbose "Start Sync-PSTags"
Sync-PSTags -AddRemoteIfMissing
Write-Verbose -Verbose "End Sync-PSTags"
shell: pwsh
- name: Capture Artifacts Directory
continue-on-error: true
run: Import-Module ./build.psm1

- name: Extract Build ZIP
run: |-
$destinationFolder = "${{ runner.workspace }}/bins"
$archiveFile = "${{ runner.workspace }}/build/build.zip"

Write-Verbose "Extracting $archiveFile to $destinationFolder" -Verbose
New-Item -ItemType Directory -Path $destinationFolder -Force | Out-Null
Expand-Archive -Path $archiveFile -DestinationPath $destinationFolder -Force
shell: pwsh
- name: Extract Files
uses: actions/[email protected]
env:
DESTINATION_FOLDER: "${{ github.workspace }}/bins"
ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip"
with:
script: |-
const fs = require('fs').promises
const path = require('path')
const target = path.resolve(process.env.DESTINATION_FOLDER)
const patterns = process.env.ARCHIVE_FILE_PATTERNS
const globber = await glob.create(patterns)
await io.mkdirP(path.dirname(target))
for await (const file of globber.globGenerator()) {
if ((await fs.lstat(file)).isDirectory()) continue
await exec.exec(`7z x ${file} -o${target} -aoa`)
}

- name: Fix permissions
continue-on-error: true
run: |-
find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \;
find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \;
find "${{ runner.workspace }}/bins" -type d -exec chmod +rwx {} \;
find "${{ runner.workspace }}/bins" -type f -exec chmod +rw {} \;
shell: bash

- name: Capture Extracted Build ZIP
continue-on-error: true
run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
run: Get-ChildItem "${{ runner.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
shell: pwsh
- name: Packaging Tests
if: success()

- name: Create Packages
env:
BUILD_ARTIFACTSTAGINGDIRECTORY: ${{ runner.workspace }}/packages
run: |-
# Create the artifacts staging directory
New-Item -ItemType Directory -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY" -Force | Out-Null

Import-Module ./tools/ci.psm1
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json'
Restore-PSOptions -PSOptionsPath '${{ runner.workspace }}/build/psoptions.json'
$options = (Get-PSOptions)
$rootPath = '${{ github.workspace }}/bins'
$rootPath = '${{ runner.workspace }}/bins'
$originalRootPath = Split-Path -path $options.Output
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)
$pwshPath = Join-Path -path $path -ChildPath 'pwsh'
Expand All @@ -75,21 +74,24 @@ runs:
Set-PSOptions $options
Invoke-CIFinish
shell: pwsh
- name: Upload packages
run: |-
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.deb" -Recurse | ForEach-Object {
$packagePath = $_.FullName
Write-Host "Uploading $packagePath"
Write-Host "##vso[artifact.upload containerfolder=deb;artifactname=deb]$packagePath"
}
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.rpm" -Recurse | ForEach-Object {
$packagePath = $_.FullName
Write-Host "Uploading $packagePath"
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath"
}
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.tar.gz" -Recurse | ForEach-Object {
$packagePath = $_.FullName
Write-Host "Uploading $packagePath"
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath"
}
shell: pwsh

- name: Upload deb packages
uses: actions/upload-artifact@v4
with:
name: packages-deb
path: ${{ runner.workspace }}/packages/*.deb
if-no-files-found: ignore

- name: Upload rpm packages
uses: actions/upload-artifact@v4
with:
name: packages-rpm
path: ${{ runner.workspace }}/packages/*.rpm
if-no-files-found: ignore

- name: Upload tar.gz packages
uses: actions/upload-artifact@v4
with:
name: packages-tar
path: ${{ runner.workspace }}/packages/*.tar.gz
if-no-files-found: ignore
32 changes: 15 additions & 17 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,22 @@ jobs:
- linux_test_unelevated_ci
- linux_test_unelevated_others
- analyze
- linux_packaging
if: always()
uses: PowerShell/compliance/.github/workflows/[email protected]
with:
needs_context: ${{ toJson(needs) }}
# TODO: Enable this when we have a Linux packaging workflow

# ERROR: While executing gem ... (Gem::FilePermissionError)
# You don't have write permissions for the /var/lib/gems/2.7.0 directory.
# WARNING: Installation of gem dotenv 2.8.1 failed! Must resolve manually.

# linux_packaging:
# name: Attempt Linux Packaging
# needs: ci_build
# runs-on: ubuntu-20.04
# steps:
# - name: checkout
# uses: actions/checkout@v5
# with:
# fetch-depth: 1000
# - name: Verify xUnit test results
# uses: "./.github/actions/test/linux-packaging"
linux_packaging:
name: Linux Packaging
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Linux Packaging
uses: "./.github/actions/test/linux-packaging"
10 changes: 10 additions & 0 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ env:
POWERSHELL_TELEMETRY_OPTOUT: 1
__SuppressAnsiEscapeSequences: 1
nugetMultiFeedWarnLevel: none
SYSTEM_ARTIFACTSDIRECTORY: ${{ github.workspace }}/artifacts
BUILD_ARTIFACTSTAGINGDIRECTORY: ${{ github.workspace }}/artifacts
jobs:
changes:
name: Change Detection
Expand All @@ -54,6 +56,7 @@ jobs:
# Set job outputs to values from filter step
outputs:
source: ${{ steps.filter.outputs.source }}
packagingChanged: ${{ steps.filter.outputs.packagingChanged }}
steps:
- name: checkout
uses: actions/checkout@v5
Expand Down Expand Up @@ -158,6 +161,12 @@ jobs:
fetch-depth: 1000
- name: Verify xUnit test results
uses: "./.github/actions/test/verify_xunit"
windows_packaging:
name: Windows Packaging
needs:
- changes
if: ${{ needs.changes.outputs.packagingChanged == 'true' }}
uses: ./.github/workflows/windows-packaging-reusable.yml
ready_to_merge:
name: windows ready to merge
needs:
Expand All @@ -166,6 +175,7 @@ jobs:
- windows_test_elevated_others
- windows_test_unelevated_ci
- windows_test_unelevated_others
- windows_packaging
if: always()
uses: PowerShell/compliance/.github/workflows/[email protected]
with:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/windows-packaging-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Windows Packaging (Reusable)

on:
workflow_call:

env:
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"
DOTNET_CLI_TELEMETRY_OPTOUT: 1
POWERSHELL_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
__SuppressAnsiEscapeSequences: 1
nugetMultiFeedWarnLevel: none
SYSTEM_ARTIFACTSDIRECTORY: ${{ github.workspace }}/artifacts
BUILD_ARTIFACTSTAGINGDIRECTORY: ${{ github.workspace }}/artifacts

jobs:
package:
name: ${{ matrix.architecture }} - ${{ matrix.channel }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- architecture: x64
channel: preview
runtimePrefix: win7
- architecture: x86
channel: stable
runtimePrefix: win7
- architecture: x86
channel: preview
runtimePrefix: win7
- architecture: arm64
channel: preview
runtimePrefix: win

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 1000

- name: Capture Environment
if: success() || failure()
run: |
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
shell: pwsh

- name: Capture PowerShell Version Table
if: success() || failure()
run: |
$PSVersionTable
shell: pwsh

- name: Switch to Public Feeds
if: success()
run: |
Import-Module .\tools\ci.psm1
Switch-PSNugetConfig -Source Public
shell: pwsh

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json

- name: Bootstrap
if: success()
run: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
shell: pwsh

- name: Build and Package
run: |
Import-Module .\tools\ci.psm1
New-CodeCoverageAndTestPackage
Invoke-CIFinish -Runtime ${{ matrix.runtimePrefix }}-${{ matrix.architecture }} -channel ${{ matrix.channel }}
shell: pwsh

- name: Upload Build Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-packaging-${{ matrix.architecture }}-${{ matrix.channel }}
path: |
${{ github.workspace }}/artifacts/**/*
!${{ github.workspace }}/artifacts/**/*.pdb
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,10 @@ Want to chat with other members of the PowerShell community?

There are dozens of topic-specific channels on our community-driven PowerShell Virtual User Group, which you can join on:

* [Gitter](https://gitter.im/PowerShell/PowerShell)
* [Discord](https://discord.gg/PowerShell)
* [IRC](https://web.libera.chat/#powershell) on Libera.Chat
* [Slack](https://aka.ms/psslack)

### Build status of nightly builds

| Azure CI (Windows) | Azure CI (Linux) | Azure CI (macOS) | CodeFactor Grade |
|:-----------------------------------------|:-----------------------------------------------|:-----------------------------------------------|:-------------------------|
| [![windows-nightly-image][]][windows-nightly-site] | [![linux-nightly-image][]][linux-nightly-site] | [![macOS-nightly-image][]][macos-nightly-site] | [![cf-image][]][cf-site] |

[windows-nightly-site]: https://powershell.visualstudio.com/PowerShell/_build?definitionId=32
[linux-nightly-site]: https://powershell.visualstudio.com/PowerShell/_build?definitionId=23
[macos-nightly-site]: https://powershell.visualstudio.com/PowerShell/_build?definitionId=24
[windows-nightly-image]: https://powershell.visualstudio.com/PowerShell/_apis/build/status/PowerShell-CI-Windows-daily
[linux-nightly-image]: https://powershell.visualstudio.com/PowerShell/_apis/build/status/PowerShell-CI-linux-daily?branchName=master
[macOS-nightly-image]: https://powershell.visualstudio.com/PowerShell/_apis/build/status/PowerShell-CI-macos-daily?branchName=master
[cf-site]: https://www.codefactor.io/repository/github/powershell/powershell
[cf-image]: https://www.codefactor.io/repository/github/powershell/powershell/badge

## Developing and Contributing

Want to contribute to PowerShell? Please start with the [Contribution Guide][] to learn how to develop and contribute.
Expand Down
2 changes: 1 addition & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ function Install-GlobalGem {
# We cannot guess if the user wants to run gem install as root on linux and windows,
# but macOs usually requires sudo
$gemsudo = ''
if($environment.IsMacOS -or $env:TF_BUILD) {
if($environment.IsMacOS -or $env:TF_BUILD -or $env:GITHUB_ACTIONS) {
$gemsudo = $sudo
}

Expand Down
Loading
Loading