File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 66 tags :
77 - ' v*'
88
9+ permissions :
10+ contents : write
11+
912jobs :
1013 publish :
1114 runs-on : windows-latest
4144 }
4245
4346 - name : Validate and Stage Release Notes
47+ id : module_meta
4448 shell : pwsh
4549 run : |
4650 $manifestPath = Resolve-Path -LiteralPath .\git-aliases-extra.psd1 |
5458 }
5559
5660 Update-ModuleManifest -Path $manifestPath -ReleaseNotes $releaseNotes
61+ $releaseNotesPath = Join-Path $env:RUNNER_TEMP ("release-notes-{0}.md" -f $moduleVersion)
62+ Set-Content -LiteralPath $releaseNotesPath -Value $releaseNotes -Encoding utf8
63+ "module_version=$moduleVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
64+ "release_notes_path=$releaseNotesPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
5765 Write-Host "Release notes for version '$moduleVersion' loaded from CHANGELOG.md."
5866
5967 - name : Prepare Publish Layout
9098 }
9199
92100 Publish-Module -Path $publishPath -Repository PSGallery -NuGetApiKey $env:PSGALLERY_API_KEY -ErrorAction Stop
101+
102+ - name : Create or Update GitHub Release
103+ if : startsWith(github.ref, 'refs/tags/v')
104+ uses : softprops/action-gh-release@v2
105+ with :
106+ tag_name : ${{ github.ref_name }}
107+ name : ${{ github.ref_name }}
108+ body_path : ${{ steps.module_meta.outputs.release_notes_path }}
109+ generate_release_notes : false
Original file line number Diff line number Diff line change @@ -282,14 +282,18 @@ Checks are skipped when:
282282This repository includes:
283283
284284- ` .github/workflows/ci.yml ` for lint + tests
285- - ` .github/workflows/publish.yml ` for PSGallery publishing
285+ - ` .github/workflows/publish.yml ` for PSGallery publish + GitHub Release creation
286286
287287To publish from CI:
288288
2892891 . Add repository secret ` PSGALLERY_API_KEY ` .
2902902 . Add release notes to ` CHANGELOG.md ` under ` ## [<ModuleVersion>] - YYYY-MM-DD ` .
2912913 . Bump ` ModuleVersion ` in ` git-aliases-extra.psd1 ` .
292- 4 . Push a tag ` v<ModuleVersion> ` (for example, ` v0.1.0 ` ) or run the publish workflow manually.
292+ 4 . Push a tag ` v<ModuleVersion> ` (for example, ` v0.1.1 ` ) or run the publish workflow manually.
293+
294+ On tag push, the publish workflow does both:
295+ - publishes the module to PSGallery;
296+ - creates/updates GitHub Release for the same tag using notes from ` CHANGELOG.md ` .
293297
294298## What CI checks
295299
Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ Describe 'git-aliases-extra tooling' {
7272 (Test-Path - LiteralPath (Join-Path $script :RepoRoot ' tools\prepare-publish.ps1' )) | Should - BeTrue
7373 }
7474
75+ It ' publishes GitHub release from publish workflow' {
76+ $workflowPath = Join-Path $script :RepoRoot ' .github\workflows\publish.yml'
77+ $workflowText = Get-Content - LiteralPath $workflowPath - Raw
78+ $workflowText | Should -Match ' Create or Update GitHub Release'
79+ $workflowText | Should -Match ' softprops/action-gh-release@v2'
80+ }
81+
7582 It ' resolves release notes from changelog for manifest version' {
7683 $manifest = Test-ModuleManifest - Path $script :ModuleManifest - ErrorAction Stop
7784 $version = $manifest.Version.ToString ()
You can’t perform that action at this time.
0 commit comments