mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
[release/v7.5] Convert Azure DevOps Linux Packaging pipeline to GitHub Actions workflow (#26391)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
TravisEz13
parent
053db9864e
commit
dcf85e0200
@@ -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
|
||||
@@ -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/github-script@v7.0.0
|
||||
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'
|
||||
@@ -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
|
||||
|
||||
@@ -227,24 +227,22 @@ jobs:
|
||||
- linux_test_unelevated_ci
|
||||
- linux_test_unelevated_others
|
||||
- analyze
|
||||
- linux_packaging
|
||||
if: always()
|
||||
uses: PowerShell/compliance/.github/workflows/ready-to-merge.yml@v1.0.0
|
||||
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@v4.1.0
|
||||
# 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"
|
||||
|
||||
+1
-1
@@ -2241,7 +2241,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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user