Skip to content

Commit 1413b06

Browse files
pwshBotCopilotTravisEz13
authored
[release/v7.4] Convert Azure DevOps Linux Packaging pipeline to GitHub Actions workflow (#26336)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
1 parent fc5d5fa commit 1413b06

3 files changed

Lines changed: 73 additions & 73 deletions

File tree

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
name: linux_packaging
2-
description: 'Test very basic Linux packaging'
3-
4-
# This isn't working yet
5-
# It fails with
6-
7-
# ERROR: While executing gem ... (Gem::FilePermissionError)
8-
# You don't have write permissions for the /var/lib/gems/2.7.0 directory.
9-
# WARNING: Installation of gem dotenv 2.8.1 failed! Must resolve manually.
2+
description: 'Linux packaging for PowerShell'
103

114
runs:
125
using: composite
@@ -15,58 +8,64 @@ runs:
158
if: success() || failure()
169
run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose'
1710
shell: pwsh
11+
12+
- uses: actions/setup-dotnet@v5
13+
with:
14+
global-json-file: ./global.json
15+
1816
- name: Download Build Artifacts
1917
uses: actions/download-artifact@v4
2018
with:
21-
path: "${{ github.workspace }}"
19+
name: build
20+
path: "${{ runner.workspace }}/build"
21+
2222
- name: Capture Artifacts Directory
2323
continue-on-error: true
24-
run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
24+
run: Get-ChildItem "${{ runner.workspace }}/build/*" -Recurse
2525
shell: pwsh
2626

2727
- name: Bootstrap
2828
run: |-
2929
Import-Module ./build.psm1
3030
Start-PSBootstrap -Scenario Package
31+
Write-Verbose -Verbose "Start Sync-PSTags"
32+
Sync-PSTags -AddRemoteIfMissing
33+
Write-Verbose -Verbose "End Sync-PSTags"
3134
shell: pwsh
32-
- name: Capture Artifacts Directory
33-
continue-on-error: true
34-
run: Import-Module ./build.psm1
35+
36+
- name: Extract Build ZIP
37+
run: |-
38+
$destinationFolder = "${{ runner.workspace }}/bins"
39+
$archiveFile = "${{ runner.workspace }}/build/build.zip"
40+
41+
Write-Verbose "Extracting $archiveFile to $destinationFolder" -Verbose
42+
New-Item -ItemType Directory -Path $destinationFolder -Force | Out-Null
43+
Expand-Archive -Path $archiveFile -DestinationPath $destinationFolder -Force
3544
shell: pwsh
36-
- name: Extract Files
37-
uses: actions/github-script@v7.0.0
38-
env:
39-
DESTINATION_FOLDER: "${{ github.workspace }}/bins"
40-
ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip"
41-
with:
42-
script: |-
43-
const fs = require('fs').promises
44-
const path = require('path')
45-
const target = path.resolve(process.env.DESTINATION_FOLDER)
46-
const patterns = process.env.ARCHIVE_FILE_PATTERNS
47-
const globber = await glob.create(patterns)
48-
await io.mkdirP(path.dirname(target))
49-
for await (const file of globber.globGenerator()) {
50-
if ((await fs.lstat(file)).isDirectory()) continue
51-
await exec.exec(`7z x ${file} -o${target} -aoa`)
52-
}
45+
5346
- name: Fix permissions
5447
continue-on-error: true
5548
run: |-
56-
find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \;
57-
find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \;
49+
find "${{ runner.workspace }}/bins" -type d -exec chmod +rwx {} \;
50+
find "${{ runner.workspace }}/bins" -type f -exec chmod +rw {} \;
5851
shell: bash
52+
5953
- name: Capture Extracted Build ZIP
6054
continue-on-error: true
61-
run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
55+
run: Get-ChildItem "${{ runner.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
6256
shell: pwsh
63-
- name: Packaging Tests
64-
if: success()
57+
58+
- name: Create Packages
59+
env:
60+
BUILD_ARTIFACTSTAGINGDIRECTORY: ${{ runner.workspace }}/packages
6561
run: |-
62+
# Create the artifacts staging directory
63+
New-Item -ItemType Directory -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY" -Force | Out-Null
64+
6665
Import-Module ./tools/ci.psm1
67-
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json'
66+
Restore-PSOptions -PSOptionsPath '${{ runner.workspace }}/build/psoptions.json'
6867
$options = (Get-PSOptions)
69-
$rootPath = '${{ github.workspace }}/bins'
68+
$rootPath = '${{ runner.workspace }}/bins'
7069
$originalRootPath = Split-Path -path $options.Output
7170
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)
7271
$pwshPath = Join-Path -path $path -ChildPath 'pwsh'
@@ -75,21 +74,24 @@ runs:
7574
Set-PSOptions $options
7675
Invoke-CIFinish
7776
shell: pwsh
78-
- name: Upload packages
79-
run: |-
80-
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.deb" -Recurse | ForEach-Object {
81-
$packagePath = $_.FullName
82-
Write-Host "Uploading $packagePath"
83-
Write-Host "##vso[artifact.upload containerfolder=deb;artifactname=deb]$packagePath"
84-
}
85-
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.rpm" -Recurse | ForEach-Object {
86-
$packagePath = $_.FullName
87-
Write-Host "Uploading $packagePath"
88-
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath"
89-
}
90-
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.tar.gz" -Recurse | ForEach-Object {
91-
$packagePath = $_.FullName
92-
Write-Host "Uploading $packagePath"
93-
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath"
94-
}
95-
shell: pwsh
77+
78+
- name: Upload deb packages
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: packages-deb
82+
path: ${{ runner.workspace }}/packages/*.deb
83+
if-no-files-found: ignore
84+
85+
- name: Upload rpm packages
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: packages-rpm
89+
path: ${{ runner.workspace }}/packages/*.rpm
90+
if-no-files-found: ignore
91+
92+
- name: Upload tar.gz packages
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: packages-tar
96+
path: ${{ runner.workspace }}/packages/*.tar.gz
97+
if-no-files-found: ignore

.github/workflows/linux-ci.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,22 @@ jobs:
227227
- linux_test_unelevated_ci
228228
- linux_test_unelevated_others
229229
- analyze
230+
- linux_packaging
230231
if: always()
231232
uses: PowerShell/compliance/.github/workflows/ready-to-merge.yml@v1.0.0
232233
with:
233234
needs_context: ${{ toJson(needs) }}
234-
# TODO: Enable this when we have a Linux packaging workflow
235-
236-
# ERROR: While executing gem ... (Gem::FilePermissionError)
237-
# You don't have write permissions for the /var/lib/gems/2.7.0 directory.
238-
# WARNING: Installation of gem dotenv 2.8.1 failed! Must resolve manually.
239-
240-
# linux_packaging:
241-
# name: Attempt Linux Packaging
242-
# needs: ci_build
243-
# runs-on: ubuntu-20.04
244-
# steps:
245-
# - name: checkout
246-
# uses: actions/checkout@v4.1.0
247-
# with:
248-
# fetch-depth: 1000
249-
# - name: Verify xUnit test results
250-
# uses: "./.github/actions/test/linux-packaging"
235+
linux_packaging:
236+
name: Linux Packaging
237+
needs:
238+
- ci_build
239+
- changes
240+
if: ${{ needs.changes.outputs.source == 'true' }}
241+
runs-on: ubuntu-latest
242+
steps:
243+
- name: checkout
244+
uses: actions/checkout@v5
245+
with:
246+
fetch-depth: 0
247+
- name: Linux Packaging
248+
uses: "./.github/actions/test/linux-packaging"

build.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ function Install-GlobalGem {
22342234
# We cannot guess if the user wants to run gem install as root on linux and windows,
22352235
# but macOs usually requires sudo
22362236
$gemsudo = ''
2237-
if($environment.IsMacOS -or $env:TF_BUILD) {
2237+
if($environment.IsMacOS -or $env:TF_BUILD -or $env:GITHUB_ACTIONS) {
22382238
$gemsudo = $sudo
22392239
}
22402240

0 commit comments

Comments
 (0)