Update module version #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Update module version' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
on: | |
workflow_dispatch: | |
# push: | |
# branches: [ "main" ] | |
# paths: | |
# - 'Evergreen/**.ps1' | |
# - 'Evergreen/**.psm1' | |
# - 'Evergreen/**.json' | |
jobs: | |
update-module: | |
name: Update module version | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install and cache PowerShell modules | |
id: psmodulecache | |
uses: potatoqualitee/[email protected] | |
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 }}\Evergreen" | |
$ManifestPath = "${{ github.workspace }}\Evergreen\Evergreen.psd1" | |
# Importing the manifest to determine the version | |
$Manifest = Test-ModuleManifest -Path $ManifestPath | |
Write-Host "Old version is: $($Manifest.Version)" | |
[System.String]$NewVersion = New-Object -TypeName "System.Version" -ArgumentList ((Get-Date -Format "yyMM"), ($Manifest.Version.Minor + [System.Int32]$env:GITHUB_RUN_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 list of supported apps in APPS.md | |
- name: Update APPS.md | |
id: update-apps | |
shell: powershell | |
run: | | |
Import-Module -Name "$env:GITHUB_WORKSPACE\Evergreen" -Force | |
Import-Module -Name MarkdownPS | |
$OutFile = [System.IO.Path]::Combine($env:GITHUB_WORKSPACE, "docs", "apps.md") | |
$markdown = New-MDHeader -Text "$((Find-EvergreenApp).Count) Supported applications" -Level 1 | |
$markdown += "`n" | |
$line = "Evergreen " + '`' + ${{steps.update-version.outputs.newversion}} + '`' + " supports the following applications:" | |
$markdown += $line | |
$markdown += "`n`n" | |
$markdown += Find-EvergreenApp | New-MDTable | |
$markdown | Out-File -FilePath $OutFile -NoNewline -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: "Changes have been detected" | |
if: steps.commit.outputs.changes_detected == 'true' | |
run: echo "Changes committed." | |
- name: "No changes have been detected" | |
if: steps.commit.outputs.changes_detected == 'false' | |
run: echo "No changes detected." |