Skip to content

Commit 003bb62

Browse files
Convert .ci build/test Azure DevOps pipelines to GitHub Actions
Adds GitHub Actions equivalents for the portable CI + test pipelines: - .github/workflows/psresourceget-ci.yml (from .ci/ci.yml build + test stages) - .github/workflows/psresourceget-test.yml (reusable, from .ci/test.yml) Azure-authenticated test steps use azure/login OIDC (federated credentials). Signing, compliance, release and symbol stages are intentionally not converted (Microsoft-internal ESRP / 1ES / ComplianceRepo / symbol server). Original .ci files are kept unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ceb1570e-c42e-4363-8f8e-5abc7f750458
1 parent 0c951b2 commit 003bb62

2 files changed

Lines changed: 447 additions & 0 deletions

File tree

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# CI workflow converted from .ci/ci.yml (Azure DevOps pipeline).
2+
# Builds the Microsoft.PowerShell.PSResourceGet module package and runs the
3+
# cross-platform test suite. Signing / compliance / release / symbol stages from
4+
# the original pipeline are intentionally not converted (they rely on Microsoft
5+
# internal infrastructure: ESRP, 1ES pools, ComplianceRepo, symbol server).
6+
name: PSResourceGet-CI
7+
8+
on:
9+
push:
10+
branches: [ master ]
11+
pull_request:
12+
branches: [ master ]
13+
14+
permissions:
15+
contents: read
16+
id-token: write # required so the reusable test workflow can use azure/login OIDC
17+
18+
jobs:
19+
build:
20+
name: Build Package
21+
runs-on: windows-latest
22+
defaults:
23+
run:
24+
shell: pwsh
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Configure AGENT_TEMPDIRECTORY
30+
run: |
31+
# Map the Azure DevOps $(Agent.TempDirectory) that the carried-over scripts expect.
32+
"AGENT_TEMPDIRECTORY=$env:RUNNER_TEMP" | Out-File -FilePath $env:GITHUB_ENV -Append
33+
34+
- name: Setup .NET
35+
uses: actions/setup-dotnet@v4
36+
with:
37+
global-json-file: global.json
38+
39+
- name: Capture environment for build
40+
if: ${{ always() }}
41+
shell: pwsh
42+
run: |
43+
Get-ChildItem -Path env:
44+
45+
- name: Create temporary module path
46+
shell: pwsh
47+
run: |
48+
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
49+
if (Test-Path -Path $modulePath) {
50+
Write-Verbose -Verbose "Deleting existing temp module path: $modulePath"
51+
Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore
52+
}
53+
if (! (Test-Path -Path $modulePath)) {
54+
Write-Verbose -Verbose "Creating new temp module path: $modulePath"
55+
$null = New-Item -Path $modulePath -ItemType Directory
56+
}
57+
58+
- name: Install Microsoft.PowerShell.PSResourceGet v3
59+
shell: pwsh
60+
run: |
61+
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
62+
Write-Verbose -Verbose "Install PSResourceGet to temp module path"
63+
Save-Module -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 0.9.0-rc1 -Path $modulePath -AllowPrerelease -Force
64+
65+
- name: Capture source code for build
66+
if: ${{ always() }}
67+
shell: pwsh
68+
run: |
69+
Get-ChildItem -Path ${{ github.workspace }}/src/code -Recurse
70+
71+
- name: Build Module
72+
shell: pwsh
73+
run: |
74+
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
75+
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
76+
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
77+
Import-Module -Name ${{ github.workspace }}/buildtools.psd1 -Force
78+
${{ github.workspace }}/build.ps1 -Build -Clean -BuildConfiguration Release -BuildFramework 'net472'
79+
80+
- name: Publish module nuget package
81+
shell: pwsh
82+
run: |
83+
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
84+
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
85+
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
86+
Import-Module -Name ${{ github.workspace }}/buildtools.psd1 -Force
87+
${{ github.workspace }}/build.ps1 -Publish
88+
89+
- name: Stage nuget package for upload
90+
shell: pwsh
91+
run: |
92+
# build.ps1 -Publish drops the .nupkg into a temp local repo folder. Copy it
93+
# to a well-known folder so it can be uploaded as the "nupkg" artifact, matching
94+
# the layout expected by Install-ModulePackageForTest (a "nupkg" subfolder).
95+
$localRepoLocation = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'packagebuild-local-repo'
96+
$nupkg = Get-ChildItem -Path $localRepoLocation -Filter '*.nupkg' -Recurse
97+
if (-not $nupkg) {
98+
throw "Could not find built .nupkg under $localRepoLocation"
99+
}
100+
$stagingPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'nupkg'
101+
$null = New-Item -Path $stagingPath -ItemType Directory -Force
102+
$nupkg | Copy-Item -Destination $stagingPath -Force -Verbose
103+
Get-ChildItem -Path $stagingPath
104+
105+
- name: Upload nuget package artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: nupkg
109+
path: ${{ github.workspace }}/nupkg/*.nupkg
110+
if-no-files-found: error
111+
112+
- name: Upload module artifact
113+
shell: pwsh
114+
run: |
115+
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
116+
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
117+
Import-Module -Name ${{ github.workspace }}/buildtools.psd1 -Force
118+
$config = Get-BuildConfiguration
119+
$srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)"
120+
Get-ChildItem $srcModulePath
121+
"MODULE_ARTIFACT_PATH=$srcModulePath" | Out-File -FilePath $env:GITHUB_ENV -Append
122+
123+
- name: Upload built module artifact
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: Microsoft.PowerShell.PSResourceGet
127+
path: ${{ env.MODULE_ARTIFACT_PATH }}
128+
if-no-files-found: error
129+
130+
test-windows-pwsh:
131+
name: PowerShell Core on Windows
132+
needs: build
133+
uses: ./.github/workflows/psresourceget-test.yml
134+
secrets: inherit
135+
with:
136+
imageName: windows-latest
137+
displayName: PowerShell Core on Windows
138+
powershellExecutable: pwsh
139+
useAzAuth: false
140+
141+
test-windows-winps:
142+
name: Windows PowerShell on Windows
143+
needs: build
144+
uses: ./.github/workflows/psresourceget-test.yml
145+
secrets: inherit
146+
with:
147+
imageName: windows-latest
148+
displayName: Windows PowerShell on Windows
149+
powershellExecutable: powershell
150+
useAzAuth: false
151+
152+
test-ubuntu:
153+
name: PowerShell Core on Ubuntu
154+
needs: build
155+
uses: ./.github/workflows/psresourceget-test.yml
156+
secrets: inherit
157+
with:
158+
imageName: ubuntu-latest
159+
displayName: PowerShell Core on Ubuntu
160+
powershellExecutable: pwsh
161+
useAzAuth: false
162+
163+
test-macos:
164+
name: PowerShell Core on macOS
165+
needs: build
166+
uses: ./.github/workflows/psresourceget-test.yml
167+
secrets: inherit
168+
with:
169+
imageName: macos-latest
170+
displayName: PowerShell Core on macOS
171+
powershellExecutable: pwsh
172+
useAzAuth: false
173+
174+
test-windows-azauth:
175+
name: AzAuth PowerShell Core on Windows
176+
needs: build
177+
uses: ./.github/workflows/psresourceget-test.yml
178+
secrets: inherit
179+
with:
180+
imageName: windows-latest
181+
displayName: AzAuth PowerShell Core on Windows
182+
powershellExecutable: pwsh
183+
useAzAuth: true

0 commit comments

Comments
 (0)