Skip to content

Commit 0aeaa82

Browse files
committed
Update Build and Release Pipeline
1 parent cef74b5 commit 0aeaa82

2 files changed

Lines changed: 101 additions & 41 deletions

File tree

.github/workflows/build.yml

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2-
name: Build
2+
name: 👷 Build
33

44
on:
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+
1114
permissions:
1215
contents: read
1316
packages: read
@@ -30,7 +33,13 @@ jobs:
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

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# All releases are done from published GitHub releases to support immutable releases
2+
name: 🚀 Release
3+
on:
4+
release:
5+
types: [published]
6+
permissions:
7+
contents: read
8+
packages: write
9+
jobs:
10+
publish:
11+
name: 🚀 Publish to VS Code Marketplace
12+
environment: VS Code Marketplace
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: 🤖 Azure Login - Federated Token
16+
if: github.event_name != 'pull_request'
17+
shell: pwsh
18+
run: |
19+
$token = $env:ACTIONS_ID_TOKEN_REQUEST_TOKEN
20+
$uri = $env:ACTIONS_ID_TOKEN_REQUEST_URL
21+
$irmParams = @{
22+
Uri = $uri
23+
Authentication = 'Bearer'
24+
Token = (ConvertTo-SecureString -AsPlainText $token)
25+
Body = @{audience = 'api://AzureADTokenExchange' }
26+
}
27+
$jwtResponse = Invoke-Restmethod @irmParams
28+
$fedToken = $jwtResponse.value
29+
if (-not $fedToken) {
30+
throw "Federated token not found in response: $($jwtResponse | ConvertTo-Json -Depth 10)"
31+
}
32+
33+
$azLoginParams = @(
34+
'--service-principal',
35+
'-u', '${{ secrets.AZURE_CLIENT_ID }}',
36+
'-t', '${{ secrets.AZURE_TENANT_ID }}',
37+
'--federated-token', $fedToken
38+
)
39+
& az login @azLoginParams
40+
- name: 📥 Get VSIX Release Asset
41+
uses: dsaltares/[email protected]
42+
with:
43+
version: ${{ github.event.release.tag_name }}
44+
file: ^github-actions-enhanced-.*\.vsix$
45+
regex: true
46+
- name: 🚀 Publish to VS Code Marketplace
47+
run: npx vsce publish --azure-identity github-actions-enhanced-*.vsix

0 commit comments

Comments
 (0)