diff --git a/.github/workflows/build-test-publish-prerelease.yml b/.github/workflows/build-test-publish-prerelease.yml deleted file mode 100644 index b7049d1d..00000000 --- a/.github/workflows/build-test-publish-prerelease.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish to PSGallery -env: - PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} -on: - push: - branches: - - prerelease - -permissions: - contents: write - -jobs: - publish-to-psgallery: - name: Publish - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Version Bump - shell: pwsh - run: | - $ErrorActionPreference = "Stop" - $env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":" - $version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version - if($null -eq $version) { throw "Failed to load version" } - $newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1) - Write-Host "Bumping version from $version to $newVersion" - Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion - git config --global user.name 'Shaun Lawrie (via GitHub Actions)' - git config --global user.email 'shaun.r.lawrie@gmail.com' - git add PwshSpectreConsole/PwshSpectreConsole.psd1 - git commit -m "[skip ci] Bump version to $newVersion" - git push - - # Publish pre-release version - & ./PwshSpectreConsole/Build.ps1 - Publish-Module -Path "./PwshSpectreConsole/" -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY -RequiredVersion "$newVersion-prerelease" -AllowPrerelease diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 667a780e..d4b4cbc4 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -5,6 +5,7 @@ on: push: branches: - main + - prerelease permissions: contents: write @@ -13,6 +14,7 @@ jobs: publish-to-psgallery: name: Publish runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' steps: - name: Check out repository code uses: actions/checkout@v3 @@ -37,3 +39,30 @@ jobs: $ErrorActionPreference = "Stop" & ./PwshSpectreConsole/Build.ps1 Publish-Module -Path "./PwshSpectreConsole/" -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY + + publish-prerelease-to-psgallery: + name: Publish Prerelease + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/prerelease' + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Version Bump + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + $env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":" + $version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version + if($null -eq $version) { throw "Failed to load version" } + $newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1) + Write-Host "Bumping version from $version to $newVersion" + Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion + git config --global user.name 'Shaun Lawrie (via GitHub Actions)' + git config --global user.email 'shaun.r.lawrie@gmail.com' + git add PwshSpectreConsole/PwshSpectreConsole.psd1 + git commit -m "[skip ci] Bump version to $newVersion" + git push + + # Publish pre-release version + & ./PwshSpectreConsole/Build.ps1 + Publish-Module -Path "./PwshSpectreConsole/" -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY -RequiredVersion "$newVersion-prerelease" -AllowPrerelease