Skip to content

Commit 956f6da

Browse files
🩹[Patch]: Workflow improvements (#60)
This release makes several improvements to the release workflow and supporting scripts, focusing on standardization, clarity, and modernization. The most significant changes include renaming and updating the release workflow, consolidating and improving PowerShell scripts, and cleaning up configuration files related to linters and release notes. Additionally, the scripts now use `Write-Host` for output and include more structured and readable logging. **Release Workflow Improvements** - Renamed the workflow file from `.github/workflows/Auto-Release.yml` to `.github/workflows/Release.yml`, updated the workflow name and job names, and switched from the `Auto-Release` action to the newer `Release-GHRepository` action for publishing releases. Also, restricted the workflow to trigger only on changes to `action.yml` and `src/**`. **PowerShell Script Modernization and Consolidation** - Moved PowerShell scripts from the `scripts/` directory to `src/`, updated references in `action.yml`, and improved script output by replacing `Write-Output` with `Write-Host` for better compatibility with GitHub Actions. Added more structured and visually separated log output using `Write-Host '-------------------------------------------------'`. **Configuration and Linting Cleanup** - Removed the `.github/linters/.jscpd.json` configuration file and disabled JSCPD validation in the linter workflow. - Added an exclusion for the `PSAvoidUsingWriteHost` rule in `.github/linters/.powershell-psscriptanalyzer.psd1` to allow using `Write-Host` in scripts running on GitHub Actions. **Release Notes and Input Documentation** - Removed the custom changelog configuration from `.github/release.yml` to rely on default GitHub release note generation. - Fixed a typo in the `IncrementalPrerelease` input description in `action.yml`.
1 parent e1b338d commit 956f6da

File tree

9 files changed

+166
-136
lines changed

9 files changed

+166
-136
lines changed

.github/linters/.jscpd.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/linters/.powershell-psscriptanalyzer.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
}
5151
}
5252
ExcludeRules = @(
53+
'PSAvoidUsingWriteHost', # This action runs on GitHub Actions which supports Write-Host.
5354
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
5455
'PSUseToExportFieldsInManifest'
5556
)

.github/release.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/Linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
env:
3030
GITHUB_TOKEN: ${{ github.token }}
3131
VALIDATE_BIOME_FORMAT: false
32+
VALIDATE_JSCPD: false
3233
VALIDATE_JSON_PRETTIER: false
3334
VALIDATE_MARKDOWN_PRETTIER: false
3435
VALIDATE_YAML_PRETTIER: false
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: Auto-Release
1+
name: Release
22

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

55
on:
66
pull_request:
@@ -12,6 +12,9 @@ on:
1212
- reopened
1313
- synchronize
1414
- labeled
15+
paths:
16+
- 'action.yml'
17+
- 'src/**'
1518

1619
concurrency:
1720
group: ${{ github.workflow }}-${{ github.ref }}
@@ -22,15 +25,15 @@ permissions:
2225
pull-requests: write
2326

2427
jobs:
25-
Auto-Release:
28+
Release:
2629
runs-on: ubuntu-latest
2730
steps:
2831
- name: Checkout Code
2932
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3033
with:
3134
persist-credentials: false
3235

33-
- name: Auto-Release
34-
uses: PSModule/Auto-Release@eabd533035e2cb9822160f26f2eda584bd012356 # v1.9.5
36+
- name: Release
37+
uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2.0.1
3538
with:
3639
IncrementalPrerelease: false

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ inputs:
2222
required: false
2323
default: 'true'
2424
IncrementalPrerelease:
25-
description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
25+
description: Control whether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
2626
required: false
2727
default: 'true'
2828
DatePrereleaseFormat:
@@ -102,7 +102,7 @@ runs:
102102
PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
103103
PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
104104
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
105-
run: ${{ github.action_path }}/scripts/init.ps1
105+
run: ${{ github.action_path }}/src/init.ps1
106106

107107
- name: Download module artifact
108108
if: env.PUBLISH_CONTEXT_ShouldPublish == 'true' || inputs.WhatIf == 'true'
@@ -123,12 +123,12 @@ runs:
123123
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }}
124124
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }}
125125
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }}
126-
run: ${{ github.action_path }}/scripts/publish.ps1
126+
run: ${{ github.action_path }}/src/publish.ps1
127127

128128
- name: Cleanup Prereleases
129129
if: env.PUBLISH_CONTEXT_ShouldCleanup == 'true' || inputs.WhatIf == 'true'
130130
shell: pwsh
131131
working-directory: ${{ inputs.WorkingDirectory }}
132132
env:
133133
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
134-
run: ${{ github.action_path }}/scripts/cleanup.ps1
134+
run: ${{ github.action_path }}/src/cleanup.ps1
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[CmdletBinding()]
22
param()
33

4+
$PSStyle.OutputRendering = 'Ansi'
5+
46
Import-Module -Name 'Helpers' -Force
57

68
$prereleaseName = $env:PUBLISH_CONTEXT_PrereleaseName
@@ -14,32 +16,32 @@ if ([string]::IsNullOrWhiteSpace($prereleaseName)) {
1416

1517
LogGroup "Cleanup prereleases for [$prereleaseName]" {
1618
if ([string]::IsNullOrWhiteSpace($prereleaseTagsToCleanup)) {
17-
Write-Output "No prereleases found to cleanup for [$prereleaseName]."
19+
Write-Host "No prereleases found to cleanup for [$prereleaseName]."
1820
return
1921
}
2022

2123
$tagsToDelete = $prereleaseTagsToCleanup -split ',' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
2224

2325
if ($tagsToDelete.Count -eq 0) {
24-
Write-Output "No prereleases found to cleanup for [$prereleaseName]."
26+
Write-Host "No prereleases found to cleanup for [$prereleaseName]."
2527
return
2628
}
2729

28-
Write-Output "Found $($tagsToDelete.Count) prereleases to cleanup:"
29-
$tagsToDelete | ForEach-Object { Write-Output " - $_" }
30-
Write-Output ''
30+
Write-Host "Found $($tagsToDelete.Count) prereleases to cleanup:"
31+
$tagsToDelete | ForEach-Object { Write-Host " - $_" }
32+
Write-Host ''
3133

3234
foreach ($tag in $tagsToDelete) {
33-
Write-Output "Deleting prerelease: [$tag]"
35+
Write-Host "Deleting prerelease: [$tag]"
3436
if ($whatIf) {
35-
Write-Output "WhatIf: gh release delete $tag --cleanup-tag --yes"
37+
Write-Host "WhatIf: gh release delete $tag --cleanup-tag --yes"
3638
} else {
3739
gh release delete $tag --cleanup-tag --yes
3840
if ($LASTEXITCODE -ne 0) {
3941
Write-Error "Failed to delete release [$tag]."
4042
exit $LASTEXITCODE
4143
}
42-
Write-Output "Successfully deleted release [$tag]."
44+
Write-Host "Successfully deleted release [$tag]."
4345
}
4446
}
4547

0 commit comments

Comments
 (0)