Merge pull request #4 from gioxx/1.0.4 #11
Workflow file for this run
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 to PowerShell Gallery | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write # Needed to push version bump back to the repo | |
| jobs: | |
| publish: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout default branch | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Update version in psd1 and UI.xaml | |
| shell: pwsh | |
| run: | | |
| $tagVersion = '${{ github.ref_name }}' -replace '^v', '' # e.g. "v1.0.0" -> "1.0.0" | |
| Set-Content -Path version.txt -Value $tagVersion | |
| # Update version in PSD1 | |
| $psd1Path = Join-Path $PWD 'IntuneWinAppUtilGUI.psd1' | |
| (Get-Content $psd1Path) -replace '(?<=ModuleVersion\s*=\s*'')[^'']+', $tagVersion | Set-Content $psd1Path | |
| # Update version in XAML title | |
| $xamlPath = Join-Path $PWD 'UI/UI.xaml' | |
| if (Test-Path $xamlPath) { | |
| (Get-Content $xamlPath) -replace '(?<=Title\s*=\s*"IntuneWinAppUtil GUI · )[^"]+', $tagVersion | Set-Content $xamlPath | |
| } | |
| - name: Commit and push updated version files | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| DEFAULT_BRANCH="${{ github.event.repository.default_branch }}" | |
| tagVersion="$(cat version.txt)" | |
| git add IntuneWinAppUtilGUI.psd1 UI/UI.xaml || true | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update version to ${tagVersion} [ci skip]" | |
| git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:${DEFAULT_BRANCH}" | |
| else | |
| echo "No changes to commit." | |
| fi | |
| - name: Validate module manifest | |
| shell: pwsh | |
| run: | | |
| $psd1Path = Join-Path $PWD 'IntuneWinAppUtilGUI.psd1' | |
| Test-ModuleManifest -Path $psd1Path -Verbose | |
| - name: Prepare module package | |
| shell: pwsh | |
| run: | | |
| $outDir = Join-Path $PWD 'build' | |
| $moduleName = 'IntuneWinAppUtilGUI' | |
| $moduleDir = Join-Path $outDir $moduleName | |
| if (Test-Path $outDir) { Remove-Item -Recurse -Force $outDir } | |
| New-Item -ItemType Directory -Path $moduleDir -Force | Out-Null | |
| $includeFiles = @( | |
| "$moduleName.psd1", | |
| "$moduleName.psm1", | |
| "README.md" | |
| ) | |
| foreach ($file in $includeFiles) { | |
| if (Test-Path $file) { Copy-Item -Path $file -Destination $moduleDir -Force } | |
| } | |
| $foldersToInclude = @("Private", "Public", "Assets", "UI") | |
| foreach ($folder in $foldersToInclude) { | |
| if (Test-Path $folder) { Copy-Item -Path $folder -Destination $moduleDir -Recurse -Force } | |
| } | |
| - name: Publish module to PowerShell Gallery | |
| shell: pwsh | |
| run: | | |
| $modulePath = Join-Path $PWD 'build' | Join-Path -ChildPath 'IntuneWinAppUtilGUI' | |
| if (-not (Get-PSRepository -Name 'PSGallery' -ErrorAction SilentlyContinue)) { | |
| Register-PSRepository -Name 'PSGallery' -SourceLocation 'https://www.powershellgallery.com/api/v2' -InstallationPolicy Trusted | |
| } | |
| Publish-Module -Path $modulePath ` | |
| -NuGetApiKey "${{ secrets.NUGET_API_KEY }}" ` | |
| -Verbose |