Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ updates:
- github-actions
schedule:
interval: weekly
groups:
github-actions:
patterns:
- '*'
2 changes: 2 additions & 0 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Action-Test
uses: ./
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/Auto-Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Auto-Release

run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"

# zizmor: ignore[dangerous-triggers] intentional - Auto-Release needs write access to create releases on PR merge
on:
pull_request_target:
branches:
Expand All @@ -27,8 +28,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Auto-Release
# zizmor: ignore[unpinned-uses] not our action
uses: PSModule/Auto-Release@v1
with:
IncrementalPrerelease: false
3 changes: 3 additions & 0 deletions .github/workflows/Linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Lint code base
# zizmor: ignore[unpinned-uses] not our action
uses: super-linter/super-linter@latest
env:
GITHUB_TOKEN: ${{ github.token }}
VALIDATE_BIOME_FORMAT: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML_PRETTIER: false
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,24 @@ inputs:
description: The working directory where the script will run from.
required: false
default: '.'
UsePRTitleAsReleaseName:
description: When enabled, uses the pull request title as the name for the GitHub release. If not set, the version string is used.
Comment thread
MariusStorhaug marked this conversation as resolved.
required: false
default: 'false'
UsePRBodyAsReleaseNotes:
description: When enabled, uses the pull request body as the release notes for the GitHub release. If not set, the release notes are auto-generated.
Comment thread
MariusStorhaug marked this conversation as resolved.
required: false
default: 'true'
UsePRTitleAsNotesHeading:
description: When enabled, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will reference the pull request number.
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
required: false
default: 'true'

runs:
using: composite
steps:
- name: Install-PSModuleHelpers
# zizmor: ignore[unpinned-uses] not our action
uses: PSModule/Install-PSModuleHelpers@v1

- name: Run Publish-PSModule
Expand All @@ -81,4 +94,7 @@ runs:
PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }}
run: ${{ github.action_path }}/scripts/main.ps1
80 changes: 53 additions & 27 deletions scripts/helpers/Publish-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@
$majorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels -split ',' | ForEach-Object { $_.Trim() }
$minorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels -split ',' | ForEach-Object { $_.Trim() }
$patchLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels -split ',' | ForEach-Object { $_.Trim() }
$usePRBodyAsReleaseNotes = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes -eq 'true'
$usePRTitleAsReleaseName = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName -eq 'true'
$usePRTitleAsNotesHeading = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading -eq 'true'
Comment thread
MariusStorhaug marked this conversation as resolved.

[pscustomobject]@{
AutoCleanup = $autoCleanup
AutoPatching = $autoPatching
IncrementalPrerelease = $incrementalPrerelease
DatePrereleaseFormat = $datePrereleaseFormat
VersionPrefix = $versionPrefix
WhatIf = $whatIf
IgnoreLabels = $ignoreLabels
MajorLabels = $majorLabels
MinorLabels = $minorLabels
PatchLabels = $patchLabels
AutoCleanup = $autoCleanup
AutoPatching = $autoPatching
IncrementalPrerelease = $incrementalPrerelease
DatePrereleaseFormat = $datePrereleaseFormat
VersionPrefix = $versionPrefix
WhatIf = $whatIf
IgnoreLabels = $ignoreLabels
MajorLabels = $majorLabels
MinorLabels = $minorLabels
PatchLabels = $patchLabels
UsePRBodyAsReleaseNotes = $usePRBodyAsReleaseNotes
UsePRTitleAsReleaseName = $usePRTitleAsReleaseName
UsePRTitleAsNotesHeading = $usePRTitleAsNotesHeading
} | Format-List | Out-String
}

Expand Down Expand Up @@ -358,25 +364,45 @@

Set-GitHubLogGroup 'New-GitHubRelease' {
Write-Output 'Create new GitHub release'
$releaseCreateCommand = @('release', 'create', $newVersion.ToString())

# Add title parameter
if ($usePRTitleAsReleaseName -and $pull_request.title) {
$prTitle = $pull_request.title
$releaseCreateCommand += @('--title', $prTitle)
Write-Output "Using PR title as release name: [$prTitle]"
} else {
$releaseCreateCommand += @('--title', $newVersion.ToString())
}

# Add notes parameter
if ($usePRTitleAsNotesHeading -and $pull_request.title -and $pull_request.body) {
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$prTitle = $pull_request.title
$prNumber = $pull_request.number
$prBody = $pull_request.body
$notes = "# $prTitle (#$prNumber)`n`n$prBody"
$releaseCreateCommand += @('--notes', $notes)
Write-Output 'Using PR title as H1 heading with link and body as release notes'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Comment thread
MariusStorhaug marked this conversation as resolved.
} elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) {
$prBody = $pull_request.body
$releaseCreateCommand += @('--notes', $prBody)
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Write-Output 'Using PR body as release notes'
} else {
$releaseCreateCommand += '--generate-notes'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
}
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated

# Add remaining parameters
if ($createPrerelease) {
if ($whatIf) {
Write-Output "WhatIf: gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease"
} else {
$releaseURL = gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create the release [$newVersion]."
exit $LASTEXITCODE
}
}
$releaseCreateCommand += @('--target', $prHeadRef, '--prerelease')
}

if ($whatIf) {
Write-Output "WhatIf: gh $($releaseCreateCommand -join ' ')"
Comment thread
MariusStorhaug marked this conversation as resolved.
} else {
if ($whatIf) {
Write-Output "WhatIf: gh release create $newVersion --title $newVersion --generate-notes"
} else {
$releaseURL = gh release create $newVersion --title $newVersion --generate-notes
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create the release [$newVersion]."
exit $LASTEXITCODE
}
$releaseURL = gh @releaseCreateCommand
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create the release [$newVersion]."
exit $LASTEXITCODE
}
}
if ($whatIf) {
Expand Down
Loading