-
-
Notifications
You must be signed in to change notification settings - Fork 18
160 lines (141 loc) · 6.52 KB
/
update-module.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Update module version
on:
workflow_dispatch:
env:
BUILD_NUMBER: "483"
jobs:
update-module:
runs-on: windows-latest
outputs:
output1: ${{ steps.commit.outputs.changes_detected }}
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install and cache PowerShell modules
id: psmodulecache
uses: potatoqualitee/psmodulecache@v6.2
with:
modules-to-cache: MarkdownPS
shell: powershell
# Update the version number in the module manifest
- name: Update module version number
id: update-version
shell: powershell
run: |
$modulePath = "${{ github.workspace }}\VcRedist"
$manifestPath = "${{ github.workspace }}\VcRedist\VcRedist.psd1"
# Importing the manifest to determine the version
$manifest = Test-ModuleManifest -Path $manifestPath
[System.Version]$version = $manifest.Version
[System.String]$newVersion = New-Object -TypeName "System.Version" -ArgumentList ($version.Major, $version.Minor, ([System.Int32]$env:GITHUB_RUN_NUMBER + [System.Int32]${{ env.BUILD_NUMBER }} ))
Write-Host "New version is: $newVersion"
# Update the manifest with the new version value and fix the weird string replace bug
$functionList = ((Get-ChildItem -Path (Join-Path -Path $modulePath -ChildPath "Public")).BaseName)
Update-ModuleManifest -Path $manifestPath -ModuleVersion $newVersion -FunctionsToExport $functionList
(Get-Content -Path $manifestPath) -replace 'PSGet_$module', $module | Set-Content -Path $manifestPath
(Get-Content -Path $manifestPath) -replace 'NewManifest', $module | Set-Content -Path $manifestPath
(Get-Content -Path $manifestPath) -replace 'FunctionsToExport = ','FunctionsToExport = @(' | Set-Content -Path $manifestPath -Force
(Get-Content -Path $manifestPath) -replace "$($functionList[-1])'", "$($functionList[-1])')" | Set-Content -Path $manifestPath -Force
echo "::set-output name=newversion::$($newVersion)"
# Update the change log with the new version number
- name: Update CHANGELOG.md
id: update-changelog
shell: powershell
run: |
$changeLog = "${{ github.workspace }}\docs\changelog.md"
$replaceString = "^## VERSION$"
$content = Get-Content -Path $changeLog
if ($content -match $replaceString) {
$content -replace $replaceString, "## ${{steps.update-version.outputs.newversion}}" | Set-Content -Path $changeLog
}
else {
Write-Host "No match in $changeLog for '## VERSION'. Manual update of CHANGELOG required." -ForegroundColor Cyan
}
# Update the docs with the new version number and supported VcRedists
- name: Update VERSIONS.md
id: update-versions
shell: powershell
run: |
Import-Module "${{ github.workspace }}\VcRedist" -Force
$VcRedists = Get-Vclist -Export All | `
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } | `
Select-Object Version, Architecture, Name
$OutFile = "${{ github.workspace }}\docs\versions.md"
$markdown = New-MDHeader -Text "Included Redistributables" -Level 1
$markdown += "`n"
$line = "VcRedist " + '`' + "${{steps.update-version.outputs.newversion}}" + '`' + " includes the following Redistributables (supported and unsupported):"
$markdown += $line
$markdown += "`n`n"
$markdown += $VcRedists | New-MDTable
($markdown.TrimEnd("`n")) | Out-File -FilePath $OutFile -Force -Encoding "Utf8"
# Import GPG key so that we can sign the commit
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPGKEY }}
passphrase: ${{ secrets.GPGPASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_config_global: true
git_tag_gpgsign: true
git_push_gpgsign: false
git_committer_name: ${{ secrets.COMMIT_NAME }}
git_committer_email: ${{ secrets.COMMIT_EMAIL }}
- name: Commit changes
id: commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update module ${{steps.update-version.outputs.newversion}}"
commit_user_name: ${{ secrets.COMMIT_NAME }}
commit_user_email: ${{ secrets.COMMIT_EMAIL }}
- name: "Run if changes have been detected"
if: steps.commit.outputs.changes_detected == 'true'
run: echo "Changes committed."
- name: "Run if no changes have been detected"
if: steps.commit.outputs.changes_detected == 'false'
run: echo "No changes detected."
# tag-repo:
# needs: update-module
# if: needs.update-module.outputs.output1 == 'true'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# token: ${{ secrets.PAT }}
# repository: aaronparker/vcredist
# - name: Git pull
# id: pull
# shell: pwsh
# run: |
# git pull origin main
# - name: Get module version number
# id: get-version
# shell: pwsh
# run: |
# $manifestPath = "${{ github.workspace }}/VcRedist/VcRedist.psd1"
# $manifest = Test-ModuleManifest -Path $manifestPath
# Write-Host "Found version: $($manifest.Version)"
# echo "::set-output name=version::$($manifest.Version)"
# # Import GPG key so that we can sign the commit
# - name: Import GPG key
# id: import_gpg
# uses: crazy-max/ghaction-import-gpg@v6
# with:
# gpg_private_key: ${{ secrets.GPGKEY }}
# passphrase: ${{ secrets.GPGPASSPHRASE }}
# git_user_signingkey: true
# git_commit_gpgsign: true
# git_config_global: true
# git_tag_gpgsign: true
# git_push_gpgsign: false
# git_committer_name: ${{ secrets.COMMIT_NAME }}
# git_committer_email: ${{ secrets.COMMIT_EMAIL }}
# # Push tag
# - name: Push tag
# shell: bash
# run: |
# git tag -a "v${{steps.get-version.outputs.version}}" -m "v${{steps.get-version.outputs.version}}"
# git push origin "v${{steps.get-version.outputs.version}}"