Add readonly key support (#17) #33
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: Publish Module | |
on: | |
push: | |
paths: | |
- 'cosmos-db/cosmos-db.psd1' | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
publish-module: | |
runs-on: ubuntu-latest | |
env: | |
module_name: cosmos-db | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get module versions | |
id: check_versions | |
shell: pwsh | |
run: | | |
Install-Module GitHubActions -Force | Out-Null | |
Import-Module GitHubActions | Out-Null | |
Install-Module $env:module_name -Force | Out-Null | |
$marketplaceVersion = import-module $env:module_name -PassThru | % Version | |
$repoVersion = import-module ".\$env:module_name" -PassThru | % Version | |
Write-ActionInfo ("MarketPlace Version = {0}" -f $marketplaceVersion.ToString()) | |
Write-ActionInfo ("Latest Version = {0}" -f $repoVersion.ToString()) | |
Set-ActionOutput -Name repository_version -Value $repoVersion.ToString() | |
Set-ActionOutput -Name should_publish -Value ($repoVersion -gt $marketplaceVersion).ToString().ToLower() | |
- if: ${{ steps.check_versions.outputs.should_publish == 'true' }} | |
name: Publish Module to PowerShell Gallery | |
shell: pwsh | |
run: | | |
Publish-Module -Path $env:module_name -NuGetApiKey "${{ secrets.PS_GALLERY_KEY }}" | |
- if: ${{ steps.check_versions.outputs.should_publish == 'true' }} | |
name: Update Release Tag | |
shell: pwsh | |
run: | | |
$version = ${{ steps.check_versions.outputs.repository_version }} | |
git tag "v$version" | |
git push origin --tags |