-
Notifications
You must be signed in to change notification settings - Fork 4
105 lines (104 loc) · 4.3 KB
/
Release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Release
on:
workflow_dispatch:
inputs:
ReleaseHeader:
description: The header to be added to the release.
required: false
jobs:
Release:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Variables
run: |
"BARE_REPOSITORY=$($env:GITHUB_REPOSITORY.split("/")[1])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$ModuleManifest = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Include *.psm1 -Recurse
"MODULE_PATH=$($ModuleManifest.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Update Changelog
id: changelog
uses: natescherer/changelog-management-action@v1
with:
mode: release
releaseVersion: ${{ steps.gitversion.outputs.SemVer }}
- name: Update PowerShell Metadata
uses: natescherer/update-powershell-metadata-action@v2
with:
path: src
version: ${{ steps.gitversion.outputs.SemVer }}
copyright: (c) YYYY Nate Scherer. All rights reserved.
releaseNotes: ${{ steps.changelog.outputs.releasenotes }}
functionsToExportPath: src\public
description: ${{ steps.metadata.outputs.description }}
- name: Generate Markdown Help Files
run: |
$DocsPath = Join-Path $env:GITHUB_WORKSPACE docs
if (Test-Path -Path $DocsPath) {
$CleanPath = Join-Path $DocsPath "*"
Remove-Item -Path $CleanPath
} else {
New-Item -Path $DocsPath -ItemType Directory | Out-Null
}
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name platyPS
Get-Module -Name $env:BARE_REPOSITORY -All | Remove-Module -Force -ErrorAction Ignore
Import-Module -Name $env:MODULE_PATH -Force -ErrorAction Stop
New-MarkdownHelp -Module $env:BARE_REPOSITORY -OutputFolder $DocsPath | Out-Null
- name: Create Documentation for Release
uses: natescherer/[email protected]
with:
path: README.md,CHANGELOG.md,docs
outputpath: out
matchpathstructure: true
- name: Compress module for GitHub release
id: compress
run: |
$CopySourcePath = Join-Path $env:GITHUB_WORKSPACE "src" "*"
$CopyDestPath = Join-Path $env:GITHUB_WORKSPACE "out"
Copy-Item -Path $CopySourcePath -Destination $CopyDestPath -Recurse
$ZipSourcePath = Join-Path $CopyDestPath "*"
$ZipDestPath = Join-Path $env:GITHUB_WORKSPACE "out" "$env:BARE_REPOSITORY-v$env:GITVERSION_SEMVER.zip"
Compress-Archive -Path $ZipSourcePath -DestinationPath $ZipDestPath
"ZipPath=$ZipDestPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Push SemVer Tag
uses: rickstaa/action-create-tag@v1
with:
tag: v${{ steps.gitversion.outputs.SemVer }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
base: main
commit-message: Release v${{ steps.gitversion.outputs.SemVer }}
branch: release/v${{ steps.gitversion.outputs.SemVer }}
delete-branch: true
title: Release v${{ steps.gitversion.outputs.SemVer }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.gitversion.outputs.SemVer }}
tag_name: v${{ steps.gitversion.outputs.SemVer }}
files: ${{ steps.compress.outputs.ZipPath }}
body: |
# Release v${{ steps.gitversion.outputs.SemVer }}
${{ github.event.inputs.ReleaseHeader}}
## Changes
${{ steps.changelog.outputs.releasenotes }}
- name: Publish Module to Gallery
uses: natescherer/publish-powershell-action@v1
with:
token: ${{ secrets.POWERSHELLGALLERY_KEY }}
target: gallery
path: out