Skip to content

Commit b73de61

Browse files
🌟 [Major]: Introducing Install-PSModuleHelpers (#2)
## Description ​This pull request introduces the `Install-PSModuleHelpers` GitHub Action, a foundational component within the PSModule framework. Its primary role is to install and configure the shared helper modules that underpin the PSModule ecosystem, ensuring a consistent and reliable environment for subsequent actions and workflows. ### PowerShell Module Enhancements: * Added a new `Helpers` module (`scripts/Helpers/Helpers.psm1`) with functions for version specification conversion (`Convert-VersionSpec`), module dependency resolution (`Resolve-PSModuleDependency`), and module installation (`Install-PSModule`). These functions streamline module management and dependency handling. * Introduced a module manifest for the `Helpers` module (`scripts/Helpers/Helpers.psd1`) with versioning and root module configuration. * Added a configuration file for PSScriptAnalyzer rules (`scripts/Helpers/PSScriptAnalyzer.Tests.psd1`) to enforce consistent PowerShell coding standards. ### Workflow and Configuration Updates: * Updated the `action.yml` file to rename the action to `Install-PSModuleHelpers` and removed outdated inputs and steps, simplifying the action's functionality. * Modified `.github/workflows/Action-Test.yml` to remove unused inputs, aligning the workflow with the updated action. * Updated the `.jscpd.json` file to exclude `linters` from code duplication checks. ### Script Improvements: * Refactored `scripts/main.ps1` to remove legacy code and integrate the new `Helpers` module, ensuring proper module import and cleanup. These changes collectively enhance the modularity, maintainability, and consistency of the PowerShell scripts and workflows. ## 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 dfd3688 commit b73de61

File tree

8 files changed

+469
-73
lines changed

8 files changed

+469
-73
lines changed

.github/linters/.jscpd.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"consoleFull"
55
],
66
"ignore": [
7-
"**/tests/**"
7+
"**/tests/**",
8+
"**/linters/**"
89
],
910
"absolute": true
1011
}

.github/workflows/Action-Test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727

2828
- name: Action-Test
2929
uses: ./
30-
with:
31-
working-directory: ./tests
32-
subject: PSModule
30+
31+
- name: Verify Helpers Module Installation
32+
shell: pwsh
33+
run: |
34+
if (Get-Module -Name Helpers -ListAvailable) {
35+
Write-Host "Helpers module successfully installed."
36+
} else {
37+
throw "Helpers module not found!"
38+
}

README.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,63 @@
1-
# Template-Action
1+
# Install-PSModuleHelpers
22

3-
A template repository for GitHub Actions
3+
A GitHub Action to install and configure the PSModule helper modules for use in continuous integration and delivery (CI/CD) workflows. This action is
4+
a critical component for setting up a standardized PowerShell environment across repositories using the PSModule framework.
5+
6+
This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule). It is recommended to use the
7+
[Process-PSModule workflow](https://github.com/PSModule/Process-PSModule) to automate the whole process of managing the PowerShell module.
8+
9+
## What this action does
10+
11+
- Removes any existing instances of the `Helpers` module from the PowerShell session.
12+
- Copies the latest version of the `Helpers` module into the PowerShell module directory.
13+
- Imports the `Helpers` module, ensuring it is available for subsequent steps.
14+
15+
This action helps maintain consistency and reliability across workflows that depend on the PSModule framework.
416

517
## Usage
618

7-
### Inputs
19+
```yaml
20+
- name: Install PSModule Helpers
21+
uses: PSModule/Install-PSModuleHelpers@v1
22+
```
23+
24+
## Inputs
25+
26+
_No inputs required._
827
9-
### Secrets
28+
## Secrets
1029
11-
### Outputs
30+
_No secrets required._
1231
13-
### Example
32+
## Outputs
33+
34+
This action does not provide any outputs.
35+
36+
## Example
37+
38+
Here's a complete workflow example demonstrating how to use the Install-PSModuleHelpers action:
1439
1540
```yaml
16-
Example here
41+
name: CI
42+
43+
on:
44+
push:
45+
branches:
46+
- main
47+
48+
jobs:
49+
build:
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install PSModule Helpers
56+
uses: PSModule/Install-PSModuleHelpers@v1
57+
58+
- name: Run additional steps
59+
shell: pwsh
60+
run: |
61+
# Example usage of imported Helpers module
62+
Get-Command -Module Helpers
1763
```

action.yml

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,15 @@
1-
name: {{ NAME }}
2-
description: {{ DESCRIPTION }}
1+
name: Install-PSModuleHelpers
2+
description: Installs the PSModule helpers.
33
author: PSModule
44
branding:
55
icon: upload-cloud
66
color: white
77

8-
inputs:
9-
subject:
10-
description: The subject to greet
11-
required: false
12-
default: World
13-
Debug:
14-
description: Enable debug output.
15-
required: false
16-
default: 'false'
17-
Verbose:
18-
description: Enable verbose output.
19-
required: false
20-
default: 'false'
21-
Version:
22-
description: Specifies the version of the GitHub module to be installed. The value must be an exact version.
23-
required: false
24-
Prerelease:
25-
description: Allow prerelease versions if available.
26-
required: false
27-
default: 'false'
28-
WorkingDirectory:
29-
description: The working directory where the script will run from.
30-
required: false
31-
default: ${{ github.workspace }}
32-
338
runs:
349
using: composite
3510
steps:
36-
- name: {{ NAME }}
37-
uses: PSModule/GitHub-Script@v1
38-
env:
39-
{{ ORG }}_{{ NAME }}_INPUT_subject: ${{ inputs.subject }}
40-
with:
41-
Debug: ${{ inputs.Debug }}
42-
Prerelease: ${{ inputs.Prerelease }}
43-
Verbose: ${{ inputs.Verbose }}
44-
Version: ${{ inputs.Version }}
45-
WorkingDirectory: ${{ inputs.WorkingDirectory }}
46-
Script: |
47-
# {{ NAME }}
48-
${{ github.action_path }}/scripts/main.ps1
11+
- name: Install-PSModuleHelpers
12+
shell: pwsh
13+
run: |
14+
# Install-PSModuleHelpers
15+
${{ github.action_path }}/scripts/main.ps1

scripts/Helpers/Helpers.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@{
2+
RootModule = 'Helpers.psm1'
3+
ModuleVersion = '999.0.0'
4+
}

0 commit comments

Comments
 (0)