Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish to PowerShell Gallery

# This workflow publishes the module to PowerShell Gallery when a release is created
# To use this workflow:
# 1. Get a PowerShell Gallery API key (see README.md)
# 2. Add the API key as a repository secret named PSGALLERY_API_KEY
# 3. Create a GitHub release to trigger this workflow

on:
release:
types: [published]

jobs:
publish:
name: Publish to PowerShell Gallery
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate module manifest
run: |
Test-ModuleManifest .\src\Build-MarksTemple.psd1
Write-Host "Module manifest is valid"
shell: powershell

- name: Run tests before publishing
run: |
Install-Module -Name Pester -Force -Scope CurrentUser
Import-Module Pester
$moduleFile = Resolve-Path './src/Build-MarksTemple.psm1'
Import-Module $moduleFile -Force
Invoke-Pester -Path tests -Output Detailed
shell: powershell

- name: Publish to PowerShell Gallery
run: |
Write-Host "Publishing Build-MarksTemple module to PowerShell Gallery..."
Publish-Module -Path .\src -NuGetApiKey $env:PSGALLERY_API_KEY -Repository PSGallery -Verbose
Write-Host "Module published successfully!"
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
shell: powershell
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ This was promised to Mark Russinovich after hours burning my eyes staring at Pro

## Installation

Clone the repository and import the script:
### From PowerShell Gallery (Recommended)
Once published, install directly from PowerShell Gallery:

```powershell
Install-Module -Name Build-MarksTemple
Import-Module Build-MarksTemple
```

### From Source
Clone the repository and import the module:

```powershell
# Clone the repository
git clone https://github.com/PowerShellYoungTeam/Marks-Temple.git
cd Marks-Temple

# Import the module
Import-Module .\src\Build-MarksTemple.psd1
# Or alternatively import the .psm1 directly
Import-Module .\src\Build-MarksTemple.psm1
```

Expand All @@ -38,6 +54,84 @@ Invoke-Pester -Path tests

![CI](https://github.com/PowerShellYoungTeam/Marks-Temple/actions/workflows/ci.yml/badge.svg)

## Publishing to PowerShell Gallery

This module can be published to the PowerShell Gallery for easy installation by users worldwide.

### Getting a PowerShell Gallery API Key

To publish modules to the PowerShell Gallery, you need an API key. Here's how to get one:

1. **Create a PowerShell Gallery Account**
- Go to [PowerShell Gallery](https://www.powershellgallery.com/)
- Click "Sign in" and create an account using your Microsoft account

2. **Generate an API Key**
- Once signed in, click on your username in the top-right corner
- Select "API Keys" from the dropdown menu
- Click "Create" to generate a new API key
- Give your key a descriptive name (e.g., "Marks-Temple Publishing Key")
- Set the appropriate expiration time (recommended: 1 year or less for security)
- Choose the scope:
- **Push new packages and package versions**: For publishing new modules and updates
- **Push only new package versions**: If the package already exists
- **Unlist packages**: For removing packages from search results

3. **Secure Your API Key**
- **Never commit API keys to source control**
- Store the key securely (password manager, environment variables, or GitHub Secrets)
- Regenerate keys regularly for security

### Publishing Process

#### Manual Publishing
```powershell
# Test the module manifest first
Test-ModuleManifest .\src\Build-MarksTemple.psd1

# Publish to PowerShell Gallery (replace YOUR_API_KEY with your actual key)
Publish-Module -Path .\src -NuGetApiKey YOUR_API_KEY -Repository PSGallery
```

#### Automated Publishing with GitHub Actions
To set up automated publishing, add your API key as a GitHub Secret:

1. Go to your repository settings
2. Navigate to "Secrets and variables" > "Actions"
3. Click "New repository secret"
4. Name: `PSGALLERY_API_KEY`
5. Value: Your PowerShell Gallery API key

Then create a publishing workflow (`.github/workflows/publish.yml`):

```yaml
name: Publish to PowerShell Gallery
on:
release:
types: [published]

jobs:
publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Publish to PowerShell Gallery
run: |
Test-ModuleManifest .\src\Build-MarksTemple.psd1
Publish-Module -Path .\src -NuGetApiKey $env:PSGALLERY_API_KEY -Repository PSGallery
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
shell: powershell
```

### Installation After Publishing

Once published, users can install the module with:

```powershell
Install-Module -Name Build-MarksTemple
```

## Contributing

Pull requests are welcome. Please add tests for new features.
Expand Down
84 changes: 84 additions & 0 deletions src/Build-MarksTemple.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@{
# Module manifest for Build-MarksTemple
RootModule = 'Build-MarksTemple.psm1'

# Version number of this module.
ModuleVersion = '1.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'

# Author of this module
Author = 'PowerShellYoungTeam'

# Company or vendor of this module
CompanyName = 'PowerShellYoungTeam'

# Copyright statement for this module
Copyright = '(c) PowerShellYoungTeam. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A PowerShell module that builds a Temple in honour of Dark mode in Procmon. Renders ASCII art temple with custom colours.'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Build-MarksTemple')

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
FileList = @('Build-MarksTemple.psm1', 'Temple.txt', 'Build-MarksTemple.psd1')

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('ASCII', 'Art', 'Temple', 'Console', 'Procmon', 'SysInternals', 'Fun', 'PowerShell')

# A URL to the license for this module.
LicenseUri = 'https://github.com/PowerShellYoungTeam/Marks-Temple/blob/main/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/PowerShellYoungTeam/Marks-Temple'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = 'Initial release of the Temple builder in honour of Dark mode in Procmon.'

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()
} # End of PSData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}
13 changes: 13 additions & 0 deletions tests/Build-MarksTemple.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ Import-Module $moduleFile -Force -Verbose
Write-Host "Functions loaded:"
Get-Command -Type Function | Where-Object Name -like '*MarksTemple*' | Format-Table Name, Source
Describe "Build-MarksTemple" {
Context "Module Manifest" {
It "Module manifest should be valid" {
$manifestPath = Join-Path (Split-Path $PSScriptRoot) "src/Build-MarksTemple.psd1"
{ Test-ModuleManifest $manifestPath } | Should -Not -Throw
}

It "Module can be imported via manifest" {
$manifestPath = Join-Path (Split-Path $PSScriptRoot) "src/Build-MarksTemple.psd1"
Import-Module $manifestPath -Force
(Get-Command Build-MarksTemple -ErrorAction SilentlyContinue) | Should -Not -BeNullOrEmpty
}
}

Context "Load" {
It "Function should be loaded" {
(Get-Command Build-MarksTemple -ErrorAction SilentlyContinue) | Should -Not -BeNullOrEmpty
Expand Down
Loading