CD #140
This file contains hidden or 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: CD | |
| on: workflow_dispatch | |
| jobs: | |
| deployment: | |
| runs-on: ubuntu-latest | |
| env: | |
| module_name: VenafiPS | |
| steps: | |
| - uses: actions/checkout@main | |
| with: | |
| token: ${{ secrets.CD_TOKEN }} | |
| - name: Update psd and psm version | |
| shell: pwsh | |
| run: | | |
| $manifestPath = '${{ github.workspace }}/${{ env.module_name }}/${{ env.module_name }}.psd1' | |
| $modulePath = $manifestPath.Replace('.psd1', '.psm1') | |
| $manifest = Import-PowerShellDataFile '${{ github.workspace }}/${{ env.module_name }}/${{ env.module_name }}.psd1' | |
| [version]$version = $manifest.ModuleVersion | |
| [version]$newVersion = "{0}.{1}.{2}" -f $Version.Major, $Version.Minor, ($Version.Build + 1) | |
| Update-ModuleManifest -Path $manifestPath -ModuleVersion $newVersion | |
| # update-modulemanifest introduces whitepsace so get rid of it | |
| (Get-Content $manifestPath).TrimEnd() | Set-Content $manifestPath | |
| # ((Get-Content -Path $modulePath -Raw).Replace('((NEW_VERSION))', $newVersion)) | Set-Content -Path $modulePath | |
| "New version: $newVersion" | |
| # set version to be used in later steps | |
| "venafips_new_version=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Update changelog | |
| shell: pwsh | |
| run: | | |
| $newVersionString = '## ${{ env.venafips_new_version }}' | |
| $releaseNotes = Get-Content -Path '${{ github.workspace }}/RELEASE.md' -Raw | |
| $changelog = Get-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Raw | |
| Set-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Value ($newVersionString + "`r`n" + $releaseNotes + "`r`n`r`n" + $changelog) | |
| - name: Install platyPS module | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| Install-Module platyPS -ErrorAction Stop | |
| - name: Update docs | |
| shell: pwsh | |
| run: | | |
| Remove-Module '${{ env.module_name }}' -Force -ea SilentlyContinue -Verbose | |
| Import-Module '${{ github.workspace }}/${{ env.module_name }}/${{ env.module_name }}.psd1' -Force -Verbose | |
| Get-Content -Path "${{ github.workspace }}/README.md" | Set-Content -Path "${{ github.workspace }}/docs/index.md" -Force | |
| Get-Content -Path "${{ github.workspace }}/CHANGELOG.md" | Set-Content -Path "${{ github.workspace }}/docs/changelog.md" -Force | |
| $null = Remove-Item -Path "${{ github.workspace }}/docs/functions" -Recurse -Force | |
| $null = New-Item -Path "${{ github.workspace }}/docs/functions" -Type 'Directory' | |
| $md = New-MarkdownHelp -Module '${{ env.module_name }}' -OutputFolder '${{ github.workspace }}/docs/functions' -Force -NoMetadata | |
| $YMLtext = Get-Content "${{ github.workspace }}/header-mkdocs.yml" | |
| $YMLText += " - Functions:" | |
| $vdcFunctions = $vcFunctions = @() | |
| $md | foreach-object { | |
| $functionName = $_.Name -replace '\.md', '' | |
| $newEntry = " - {0}: functions/{1}" -f $functionName, $_.Name | |
| $newEntry | |
| if ( $functionName -match '-Venafi' ) { | |
| $YMLText += $newEntry | |
| } | |
| elseif ( $functionName -match '-Vdc' ) { | |
| $vdcFunctions += " $newEntry" | |
| } | |
| else { | |
| $vcFunctions += " $newEntry" | |
| } | |
| } | |
| $YMLText += " - Self-Hosted:" | |
| $vdcFunctions | ForEach { $YMLText += $_ } | |
| $YMLText += " - SaaS:" | |
| $vcFunctions | ForEach { $YMLText += $_ } | |
| $YMLtext | Set-Content -Path '${{ github.workspace }}/mkdocs.yml' | |
| - name: Update repo | |
| run: | | |
| git config --global user.name 'Greg Brownstein' | |
| git config --global user.email '[email protected]' | |
| git add . | |
| git status | |
| git commit -m "Update manifest and docs to ${{ env.venafips_new_version }}" | |
| git push | |
| - name: Deploy docs | |
| uses: mhausenblas/mkdocs-deploy-gh-pages@master | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |