diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f4a02d8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publish to PS Gallery + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v6 + + - name: Publish module to PowerShell Gallery + shell: pwsh + env: + PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} + run: | + $isPreview = '${{ github.ref_name }}' -ne 'master' + Write-Host "Branch: ${{ github.ref_name }} | Preview: $isPreview" + ./tools/Publish-ToGallery.ps1 -IsPreview:$isPreview -NuGetApiKey $env:PSGALLERY_API_KEY diff --git a/tools/Publish-ToGallery.ps1 b/tools/Publish-ToGallery.ps1 new file mode 100644 index 0000000..b8b22ef --- /dev/null +++ b/tools/Publish-ToGallery.ps1 @@ -0,0 +1,18 @@ +[CmdletBinding()] +param ( + [switch]$IsPreview, + + [Parameter(Mandatory)] + [string]$NuGetApiKey +) + +$modulePath = Resolve-Path (Join-Path $PSScriptRoot '..') +$manifestPath = Join-Path $modulePath 'azure.datafactory.tools.psd1' + +if ($IsPreview) { + Write-Host "Tagging module as prerelease (preview)..." + Update-ModuleManifest -Path $manifestPath -Prerelease 'preview' +} + +Write-Host "Publishing module from: $modulePath" +Publish-Module -Path $modulePath -NuGetApiKey $NuGetApiKey -Verbose