Skip to content

Commit 2da4e21

Browse files
🌟 [Major]: Using settings from Process-PSModule + common dependencies (#49)
## Description This update elevates `Publish-PSModule` to `v2`, refactoring its inputs, scripts, and workflows for improved modularity, clarity, and security, and syncs its usage within the `Process‑PSModule` workflow to consume the new version and centralized settings. PSModule/Process-PSModule/pulls/150 ### Key Updates - Explicit Inputs & Defaults Removed the legacy `ConfigurationFile` input in favor of clearly defined action inputs (including a new `WorkingDirectory` defaulting to `'.'`), with reordered parameters for consistency, changing its usage to be via the settings file introduced in Process-PSModule. - Bug Fix & Logging Enhancements Fixed the extra “v” prefix in the Gallery comment by sanitizing the version string, and added comprehensive logging of all inputs at script start to aid diagnostics. - Fixes PSModule/Process-PSModule/issues/82 - Moved helper scripts Extracted `Convert-VersionSpec` and `Resolve-PSModuleDependency` into standalone helpers in `Install-PSModuleHelpers`, replaced verbose calls with `Write-Host`, and strengthened retry/null‑check logic when querying the PowerShell Gallery. - Workflow Security & Consistency Updated test workflows to use the repository workspace path uniformly and removed the hardcoded `GITHUB_TOKEN` from the Auto‑Release workflow in favor of `${{ github.token }}`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [x] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 2fa2eb6 commit 2da4e21

18 files changed

Lines changed: 102 additions & 205 deletions

.github/workflows/Action-Test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ jobs:
3535
Verbose: true
3636
Debug: true
3737
Name: PSModuleTest
38-
ModulePath: tests/outputs/modules
38+
WorkingDirectory: tests
3939
APIKey: ${{ secrets.APIKEY }}
4040
WhatIf: true

.github/workflows/Auto-Release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,5 @@ jobs:
3030

3131
- name: Auto-Release
3232
uses: PSModule/Auto-Release@v1
33-
env:
34-
GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication
3533
with:
3634
IncrementalPrerelease: false

README.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ prerelease with the branch name (in normalized form) as the prerelease name. By
3636
- `fix`
3737

3838
The types of labels used for the types of prereleases can be configured using the `MajorLabels`, `MinorLabels` and `PatchLabels`
39-
parameters/settings in the configuration file. See the [Usage](#usage) section for more information.
39+
parameters/settings. See the [Usage](#usage) section for more information.
4040

4141
When a pull request is merged into the default branch, the action will create a release based on the labels and clean up any previous
4242
prereleases that was created.
@@ -47,38 +47,24 @@ The action can be configured using the following settings:
4747

4848
| Name | Description | Required | Default |
4949
| --- | --- | --- | --- |
50+
| `Name` | Name of the module to publish. Defaults to the repository name. | `false` | |
51+
| `ModulePath` | Path to the folder where the module to publish is located. | `false` | `outputs/modules` |
5052
| `APIKey` | PowerShell Gallery API Key. | `true` | |
5153
| `AutoCleanup`| Control wether to automatically cleanup prereleases. If disabled, the action will not remove any prereleases. | `false` | `true` |
5254
| `AutoPatching` | Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. | `false` | `true` |
53-
| `ConfigurationFile` | The path to the configuration file. Settings in the configuration file take precedence over the action inputs. | `false` | `.github\auto-release.yml` |
5455
| `DatePrereleaseFormat` | The format to use for the prerelease number using [.NET DateTime format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings). | `false` | `''` |
55-
| `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `false` | `NoRelease` |
5656
| `IncrementalPrerelease` | Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. | `false` | `true` |
57+
| `VersionPrefix` | The prefix to use for the version number. | `false` | `v` |
5758
| `MajorLabels` | A comma separated list of labels that trigger a major release. | `false` | `major, breaking` |
5859
| `MinorLabels` | A comma separated list of labels that trigger a minor release. | `false` | `minor, feature` |
59-
| `ModulePath` | Path to the folder where the module to publish is located. | `false` | `outputs/modules` |
60-
| `Name` | Name of the module to publish. Defaults to the repository name. | `false` | |
6160
| `PatchLabels` | A comma separated list of labels that trigger a patch release. | `false` | `patch, fix` |
62-
| `VersionPrefix` | The prefix to use for the version number. | `false` | `v` |
61+
| `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `false` | `NoRelease` |
6362
| `WhatIf` | Control wether to simulate the action. If enabled, the action will not create any releases. Used for testing. | `false` | `false` |
6463
| `Debug` | Enable debug output. | `'false'` | `false` |
6564
| `Verbose` | Enable verbose output. | `'false'` | `false` |
6665
| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | | `false` |
6766
| `Prerelease` | Allow prerelease versions if available. | `'false'` | `false` |
68-
69-
### Configuration file
70-
71-
The configuration file is a YAML file that can be used to configure the action.
72-
By default, the configuration file is expected at `.github\auto-release.yml`, which can be changed using the `ConfigurationFile` setting.
73-
The actions configuration can be change by altering the settings in the configuration file.
74-
75-
```yaml
76-
DatePrereleaseFormat: 'yyyyMMddHHmm'
77-
IncrementalPrerelease: false
78-
VersionPrefix: ''
79-
```
80-
81-
This example uses the date format for the prerelease, disables the incremental prerelease and removes the version prefix.
67+
| `WorkingDirectory` | The working directory where the script runs. | `'false'` | `'.'` |
8268

8369
## Example
8470

action.yml

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
ModulePath:
1313
description: Path to the module to publish.
1414
required: false
15-
default: outputs/modules
15+
default: outputs/module
1616
APIKey:
1717
description: PowerShell Gallery API Key.
1818
required: true
@@ -24,22 +24,18 @@ inputs:
2424
description: Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label.
2525
required: false
2626
default: 'true'
27-
ConfigurationFile:
28-
description: The path to the configuration file. Settings in the configuration file take precedence over the action inputs.
27+
IncrementalPrerelease:
28+
description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
2929
required: false
30-
default: .github\auto-release.yml
30+
default: 'true'
3131
DatePrereleaseFormat:
3232
description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'.
3333
required: false
3434
default: ''
35-
IgnoreLabels:
36-
description: A comma separated list of labels that do not trigger a release.
37-
required: false
38-
default: NoRelease
39-
IncrementalPrerelease:
40-
description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
35+
VersionPrefix:
36+
description: The prefix to use for the version number.
4137
required: false
42-
default: 'true'
38+
default: v
4339
MajorLabels:
4440
description: A comma separated list of labels that trigger a major release.
4541
required: false
@@ -52,10 +48,10 @@ inputs:
5248
description: A comma separated list of labels that trigger a patch release.
5349
required: false
5450
default: patch, fix
55-
VersionPrefix:
56-
description: The prefix to use for the version number.
51+
IgnoreLabels:
52+
description: A comma separated list of labels that do not trigger a release.
5753
required: false
58-
default: v
54+
default: NoRelease
5955
WhatIf:
6056
description: If specified, the action will only log the changes it would make, but will not actually create or delete any releases or tags.
6157
required: false
@@ -75,32 +71,39 @@ inputs:
7571
description: Allow prerelease versions if available.
7672
required: false
7773
default: 'false'
74+
WorkingDirectory:
75+
description: The working directory where the script will run from.
76+
required: false
77+
default: '.'
7878

7979
runs:
8080
using: composite
8181
steps:
82+
- name: Install-PSModuleHelpers
83+
uses: PSModule/Install-PSModuleHelpers@v1
84+
8285
- name: Run Publish-PSModule
8386
uses: PSModule/GitHub-Script@v1
8487
env:
85-
GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }}
86-
GITHUB_ACTION_INPUT_ModulePath: ${{ inputs.ModulePath }}
87-
GITHUB_ACTION_INPUT_APIKey: ${{ inputs.APIKey }}
88-
GITHUB_ACTION_INPUT_AutoCleanup: ${{ inputs.AutoCleanup }}
89-
GITHUB_ACTION_INPUT_AutoPatching: ${{ inputs.AutoPatching }}
90-
GITHUB_ACTION_INPUT_ConfigurationFile: ${{ inputs.ConfigurationFile }}
91-
GITHUB_ACTION_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }}
92-
GITHUB_ACTION_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }}
93-
GITHUB_ACTION_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }}
94-
GITHUB_ACTION_INPUT_MajorLabels: ${{ inputs.MajorLabels }}
95-
GITHUB_ACTION_INPUT_MinorLabels: ${{ inputs.MinorLabels }}
96-
GITHUB_ACTION_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
97-
GITHUB_ACTION_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
98-
GITHUB_ACTION_INPUT_WhatIf: ${{ inputs.WhatIf }}
88+
PSMODULE_PUBLISH_PSMODULE_INPUT_Name: ${{ inputs.Name }}
89+
PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath: ${{ inputs.ModulePath }}
90+
PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey: ${{ inputs.APIKey }}
91+
PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup: ${{ inputs.AutoCleanup }}
92+
PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching: ${{ inputs.AutoPatching }}
93+
PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }}
94+
PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }}
95+
PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }}
96+
PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels: ${{ inputs.MajorLabels }}
97+
PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels: ${{ inputs.MinorLabels }}
98+
PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
99+
PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
100+
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
101+
PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }}
99102
with:
103+
Name: Publish-PSModule
100104
Debug: ${{ inputs.Debug }}
101105
Prerelease: ${{ inputs.Prerelease }}
102106
Verbose: ${{ inputs.Verbose }}
103107
Version: ${{ inputs.Version }}
104-
Script: |
105-
# Publish-PSModule
106-
${{ github.action_path }}\scripts\main.ps1
108+
WorkingDirectory: ${{ inputs.WorkingDirectory }}
109+
Script: ${{ github.action_path }}/scripts/main.ps1

0 commit comments

Comments
 (0)