11# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2- name : Build
2+ name : 👷 Build
33
44on :
55 push :
6+ branches :
7+ - main
8+ tags :
9+ - ' v*.*.*' # Match tags like v2024.06.0
610 pull_request :
711 branches :
812 - main
9- tags :
10- - ' v*'
13+
1114permissions :
1215 contents : read
1316 packages : read
3033 cache : pnpm
3134 - name : 🕒 Version
3235 shell : pwsh
33- run : pnpm version --no-git-tag-version $(Get-Date -Format 'yyyy.M.0-ci.${{ github.run_number }}')
36+ run : |
37+ if ('${{ github.ref_type }}' -eq 'tag') {
38+ $version = '${{ github.ref_name }}'.TrimStart('v')
39+ } else {
40+ $version = $(Get-Date -Format 'yyyy.M.0-ci.${{ github.run_number }}')
41+ }
42+ pnpm version --no-git-tag-version $version
3443 - name : 🚚 Restore Packages (CI)
3544 run : pnpm install --frozen-lockfile
3645 - name : 💄 Prettier Formatting Check
@@ -43,45 +52,49 @@ jobs:
4352 run : pnpm test
4453 - name : 📦 Package
4554 run : pnpm package
46- - name : ⬆️ Upload Artifact
55+ - name : 🚚 Upload VSIX Build Artifact
4756 uses : actions/upload-artifact@v6
4857 with :
4958 name : github-actions-enhanced-vsix
5059 path : github-actions-enhanced-*.vsix
51- # publish:
52- # name: 🚀 Publish to VSCode Marketplace
53- # needs: build
54- # runs-on: ubuntu-latest
55- # if: startsWith(github.ref, 'refs/tags/v')
56- # steps:
57- # - name: 🤖 Azure Login - Federated Token
58- # if: github.event_name != 'pull_request'
59- # shell: pwsh
60- # run: |
61- # $token = $env:ACTIONS_ID_TOKEN_REQUEST_TOKEN
62- # $uri = $env:ACTIONS_ID_TOKEN_REQUEST_URL
63- # $irmParams = @{
64- # Uri = $uri
65- # Authentication = 'Bearer'
66- # Token = (ConvertTo-SecureString -AsPlainText $token)
67- # Body = @{audience = 'api://AzureADTokenExchange' }
68- # }
69- # $jwtResponse = Invoke-Restmethod @irmParams
70- # $fedToken = $jwtResponse.value
71- # if (-not $fedToken) {
72- # throw "Federated token not found in response: $($jwtResponse | ConvertTo-Json -Depth 10)"
73- # }
7460
75- # $azLoginParams = @(
76- # '--service-principal',
77- # '-u', '${{ secrets.AZURE_CLIENT_ID }}',
78- # '-t', '${{ secrets.AZURE_TENANT_ID }}',
79- # '--federated-token', $fedToken
80- # )
81- # & az login @azLoginParams
82- # - name: ⬇️ Download Build Artifact
83- # uses: actions/download-artifact@v6
84- # with:
85- # name: github-actions-enhanced-vsix
86- # - name: 🚀 Publish to VSCode Marketplace
87- # run: npx vsce publish --azure-credential --packagePath github-actions-enhanced-*.vsix
61+ draft_release :
62+ name : 📝 Create Draft Release on Tag
63+ if : github.ref_type == 'tag'
64+ needs : build
65+ runs-on : ubuntu-latest
66+ steps :
67+ - name : ✔️ Verify Tag is in CalVer Format and Current
68+ shell : pwsh
69+ run : |
70+ $tag = "${{ github.ref_name }}"
71+ if ($tag -notmatch '^v\d{4}\.\d{2}\.') {
72+ throw "Tag '$tag' does not match CalVer format (e.g. v2026.02.1)"
73+ }
74+
75+ $tagYear = [int]$tag.Substring(1, 4)
76+ $tagMonth = [int]$tag.Substring(6, 2)
77+ $now = Get-Date
78+ $currentYear = $now.Year
79+ $currentMonth = $now.Month
80+
81+ if ($tagYear -gt $currentYear -or ($tagYear -eq $currentYear -and $tagMonth -gt $currentMonth)) {
82+ throw "Tag year/month ($tagYear.$tagMonth) exceeds current year/month ($currentYear.$currentMonth)"
83+ }
84+
85+ Write-Host "✔️ Tag '$tag' is valid CalVer format with valid year/month"
86+
87+ - name : 📥 Download all Build Artifacts
88+ uses : actions/download-artifact@v6
89+ with :
90+ path : release-artifacts
91+ pattern : github-actions-enhanced-*
92+
93+ - name : 📝 Generate Draft Release
94+ uses : softprops/action-gh-release@v2
95+ with :
96+ draft : true
97+ generate_release_notes : true
98+ tag_name : ${{ github.ref_name }}
99+ files : release-artifacts/**
100+ fail_on_unmatched_files : true
0 commit comments