Skip to content

build(deps): Bump googleapis/release-please-action from 4.2.0 to 4.4.0 #30

build(deps): Bump googleapis/release-please-action from 4.2.0 to 4.4.0

build(deps): Bump googleapis/release-please-action from 4.2.0 to 4.4.0 #30

name: ReleasePlease
on:
repository_dispatch:
types: [create-pull-request]
pull_request:
push:
branches: [ "main" ]
permissions:
pull-requests: write
contents: write
jobs:
update-readme:
if: github.event_name == 'pull_request'
name: Update psd1 and documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 2
ref: ${{ github.event.pull_request.head.ref }}
- name: Update readme.md and psd1 version
shell: pwsh
run: |
$Path = ".\README.md"
# Load platyPS module for generating markdown documentation
Install-Module platyPS -Scope CurrentUser -Confirm:$false -Force
Import-Module platyPS
# Locate the module manifest file
$psd1 = Get-ChildItem -Recurse -Include *.psd1
$count = ($psd1 | Measure-Object).Count
if($count -ne 1) {
Write-Error "Wrong number of psd1 files found ($count)"
exit 1
}
$publicFunctions = Get-ChildItem (Join-Path $psd1.Directory "Public") | Sort-object BaseName
# Update the psd1 file with the release-please version
if((Test-Path ".release-please-manifest.json")) {
$releasePleaseVersion = (Get-Content ".release-please-manifest.json" | ConvertFrom-Json -AsHashTable)."."
if($releasePleaseVersion -notlike "*.*.*") {
Write-Error "Invalid release-please version '($releasePleaseVersion)' found"
exit 1
}
# Replace the ModuleVersion line in the psd1 file
(Get-Content $psd1.FullName |
ForEach-Object {if($_ -like "*ModuleVersion*=*"){" ModuleVersion = '$releasePleaseVersion'"} else {$_}} |
ForEach-Object {if($_ -like "*FunctionsToExport*=*"){" FunctionsToExport = @('$($publicFunctions.BaseName -join "','")')"} else {$_}} |
Out-String).Trim() |
Set-Content $psd1.FullName
}
# Import the module
$ModulePath = $psd1.FullName | Split-Path -Parent
$Module = Import-Module $ModulePath -Verbose -Force -PassThru
# Generate README.md
{
"# Documentation for module $($Module.Name)"
""
$Module.Description
""
"| Metadata | Information |"
"| --- | --- |"
"| Version | $($Module.Version) |"
if($Module.RequiredModules) {"| Required modules | $($Module.RequiredModules) |"}
if($Module.Author) {"| Author | $($Module.Author) |"}
if($Module.CompanyName) {"| Company name | $($Module.CompanyName) |"}
if($Module.PowerShellVersion) {"| PowerShell version | $($Module.PowerShellVersion) |"}
""
New-MarkdownHelp -Module $Module.Name -OutputFolder "$($ENV:RUNNER_TEMP)/generateddocs" -Force -NoMetadata |
Get-Content |
ForEach-Object {$_ -replace "^#","##"} |
ForEach-Object {$_ -replace "{{ Fill [\w\s]+ Description }}"}
}.Invoke() | Out-File -FilePath $Path -Encoding utf8 -Force
- name: Push back to PR
shell: pwsh
run: |
# Commit and push the changes back to the PR
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add --all
git commit -m "chore: Update generated content"
git push origin ${{ github.event.pull_request.head.ref }}
release-please:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
with:
token: ${{ secrets.PAT }}
release-type: simple