From 91446fc2baf1207842c971ae4f9a349a0e16053e Mon Sep 17 00:00:00 2001 From: Yves Fridelance Date: Thu, 26 Feb 2026 18:43:40 +0100 Subject: [PATCH] feat: create git version tags on publish Add automatic git tagging after PSGallery publish: - PreRelease (develop): v0.2.0-preview27 - Release (main): v0.2.0 Adds contents: write permission to build-and-publish job. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c44ab7f..600dfef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,6 +129,8 @@ jobs: needs: [test-pwsh, test-ps51] runs-on: ubuntu-latest if: github.event_name == 'push' + permissions: + contents: write steps: - name: Checkout repository @@ -217,3 +219,22 @@ jobs: throw } } + + - name: Create git version tag + shell: pwsh + run: | + $ManifestPath = './dist/YFridelance.PS.ModuleFactory/YFridelance.PS.ModuleFactory.psd1' + $Manifest = Test-ModuleManifest -Path $ManifestPath + $Version = $Manifest.Version.ToString() + $Prerelease = $Manifest.PrivateData.PSData.Prerelease + if ($Prerelease) { + $Tag = "v$Version-$Prerelease" + } + else { + $Tag = "v$Version" + } + Write-Host "Creating tag: $Tag" -ForegroundColor Green + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a $Tag -m "Release $Tag" + git push origin $Tag