Tag, Release, and Publish to PSGallery and Chocolatey Community Repo #10
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: Tag, Release, and Publish to Gallery | |
on: | |
workflow_dispatch: | |
jobs: | |
run-build-test: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run the build test workflow | |
run: gh workflow run build-test.yml | |
env: | |
GH_TOKEN: ${{ github.token }} | |
confirm-build-test: | |
needs: run-build-test | |
runs-on: windows-latest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Wait for the runs to start | |
run: start-sleep 60 | |
- name: Get run IDs | |
run: | | |
$runid=((& gh run list --workflow build-test.yml --json databaseId --limit 1) | convertfrom-json).databaseId | |
echo "RUNID=$runid" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | |
- name: confirm build succeeded | |
run: | | |
$runstatus="" | |
while (($runstatus -ne "success") -AND ($runstatus -ne "failure")) { | |
start-sleep 15 | |
$runstatus=((& gh run view $env:RUNID --exit-status --json conclusion) | Convertfrom-json).conclusion | |
} | |
if ($runstatus -eq "failure") { | |
exit 1 | |
} else { | |
exit 0 | |
} | |
publish-built-module: | |
needs: confirm-build-test | |
runs-on: windows-latest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GalKey: ${{ secrets.PSGALLERY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: fregante/[email protected] | |
- name: Build and publish module | |
run: | | |
"Building and publishing module and committing changes" | out-host; | |
Install-PSResource -Name PlatyPS -TrustRepository -Version 0.14.2 -Scope CurrentUser -AcceptLicense | |
$releaseNote = (git log -1 --pretty=%B) | |
"Setting release note to last commit message:`n$releaseNote" | out-host; | |
"Building docs, module, and incrementing version..." | out-host; | |
.\build.ps1 -releasenote "$($releaseNote | out-string)" | |
$version = (Test-ModuleManifest .\FogApi\FogApi.psd1).version | |
"Pushing Changes from publish" | out-host; | |
git add -A | |
git commit -m "$($releaseNote | out-string) - publish build for $version" | |
git push | |
"Publishing module to gallery..." | out-host; | |
Publish-PSResource -apikey $env:GalKey -Path .\_module_build\FogApi -Repository PSGallery; | |
"Creating Github Release..." | out-host; | |
gh release create $version --latest --generate-notes --target master | |