Skip to content

Commit 27cb549

Browse files
Merge pull request #17 from WarehouseFinds/feat/gh_actions_update
Refactor GitHub Actions workflows to streamline build and release processes
2 parents e5d9f40 + d2e304b commit 27cb549

3 files changed

Lines changed: 52 additions & 76 deletions

File tree

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Build PowerShell Module
22
description: Build module, generate help, and upload artifacts
33
inputs:
4-
module-list:
5-
description: Comma-separated list of PowerShell modules to cache
6-
required: true
74
release-type:
85
description: Type of release (Release, Prerelease, Debug)
96
default: Debug
@@ -18,6 +15,12 @@ outputs:
1815
runs:
1916
using: composite
2017
steps:
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: '8.0.x'
23+
2124
- name: Install GitVersion tool
2225
uses: gittools/actions/gitversion/setup@d0139503a9321f76b4a417dfdc8aebcec24decdd #v4.2.0
2326
with:
@@ -30,23 +33,6 @@ runs:
3033
configFilePath: GitVersion.yml
3134
disableShallowCloneCheck: true
3235

33-
- name: Determine build version
34-
id: compute
35-
shell: pwsh
36-
run: |
37-
switch ('${{ inputs.release-type }}') {
38-
'Release' {
39-
$buildVersion = '${{ steps.gitversion.outputs.semVer }}'.Split('-', 2)[0]
40-
}
41-
'Prerelease' {
42-
$buildVersion = '${{ steps.gitversion.outputs.semVer }}'.Split('-', 2)[0] + '-Prerelease'
43-
}
44-
'Debug' {
45-
$buildVersion = '${{ steps.gitversion.outputs.semVer }}'
46-
}
47-
}
48-
echo "build-version=$buildVersion" >> $env:GITHUB_OUTPUT
49-
5036
- name: Setup PowerShell
5137
shell: pwsh
5238
run: |
@@ -55,5 +41,25 @@ runs:
5541
- name: Build Module
5642
shell: pwsh
5743
run: |
58-
Invoke-Build -Task Build -SemanticVersion ${{ steps.gitversion.outputs.majorMinorPatch }} -Configuration Release
44+
Invoke-Build -Task Build -SemanticVersion ${{ steps.gitversion.outputs.MajorMinorPatch }} -Configuration ${{ inputs.release-type }}
5945
46+
- name: Create NuGet package from build artifacts
47+
shell: pwsh
48+
run: |
49+
Set-StrictMode -Version Latest
50+
[void] (Import-Module InvokeBuild)
51+
Invoke-Build -Task Package
52+
53+
- name: Upload NuGet package
54+
id: upload_nuget
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{ github.event.repository.name }}.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg
58+
path: /build/package/${{ github.event.repository.name }}.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg
59+
60+
- name: Upload module bin artifacts
61+
id: upload_bin
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: PSBinaryModule
65+
path: build/out/PSBinaryModule

.github/actions/ps-release/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ runs:
7070
[void] (Import-Module InvokeBuild)
7171
Invoke-Build -NugetApiKey ${{ env.PSGALLERY_API_KEY }} -Task Publish
7272
73-
- name: Publish build package to Github Release
73+
- name: Create NuGet package from build artifacts
7474
shell: pwsh
7575
run: |
7676
Set-StrictMode -Version Latest

.github/workflows/ci.yml

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,30 @@ jobs:
3838
id: labeler
3939
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b #v6.0.1
4040

41+
build:
42+
name: Build
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
outputs:
47+
release-version: ${{ steps.build.outputs.release-version }}
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build Module
56+
id: build
57+
uses: ./.github/actions/ps-build
58+
with:
59+
release-type: Debug
60+
4161
unit-tests:
4262
name: Unit Tests
43-
runs-on: ${{ matrix.os }}
44-
strategy:
45-
matrix:
46-
os: [ubuntu-latest, windows-latest, macos-latest]
63+
needs: [build]
64+
runs-on: ubuntu-latest
4765
permissions:
4866
contents: read
4967
issues: write
@@ -87,54 +105,6 @@ jobs:
87105
files: test-results/**/*.trx
88106
check_name: Unit Test Results
89107

90-
build:
91-
name: Build
92-
needs: [unit-tests]
93-
runs-on: ubuntu-latest
94-
permissions:
95-
contents: write
96-
outputs:
97-
release-version: ${{ steps.gitversion.outputs.majorMinorPatch }}
98-
steps:
99-
- name: Checkout repository
100-
uses: actions/checkout@v6
101-
with:
102-
fetch-depth: 0
103-
token: ${{ secrets.GITHUB_TOKEN }}
104-
105-
- name: Install GitVersion tool
106-
uses: gittools/actions/gitversion/setup@2685caa112fc953a61603836655d04cbc57bc2aa
107-
with:
108-
versionSpec: '6.5.1'
109-
110-
- name: Get semantic build version
111-
id: gitversion
112-
uses: gittools/actions/gitversion/execute@2685caa112fc953a61603836655d04cbc57bc2aa
113-
with:
114-
configFilePath: GitVersion.yml
115-
disableShallowCloneCheck: true
116-
117-
- name: Setup .NET
118-
uses: actions/setup-dotnet@v5
119-
with:
120-
dotnet-version: '8.0.x'
121-
122-
- name: Setup PowerShell
123-
shell: pwsh
124-
run: |
125-
Install-PSResource -Name InvokeBuild -TrustRepository -AcceptLicense
126-
127-
- name: Build Module
128-
shell: pwsh
129-
run: |
130-
Invoke-Build -Task Build -SemanticVersion ${{ steps.gitversion.outputs.majorMinorPatch }}
131-
132-
- name: Upload build artifact
133-
uses: actions/upload-artifact@v6
134-
with:
135-
name: PSBinaryModule
136-
path: build/out/PSBinaryModule/
137-
138108
integration-tests:
139109
name: Integration Tests
140110
needs: [build]
@@ -156,8 +126,8 @@ jobs:
156126
with:
157127
dotnet-version: '8.0.x'
158128

159-
- name: Download build artifact
160-
uses: actions/download-artifact@v7
129+
- name: Download all build artifacts
130+
uses: actions/download-artifact@v5
161131
with:
162132
name: PSBinaryModule
163133
path: build/out/PSBinaryModule

0 commit comments

Comments
 (0)