microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-hardcoded-paths-in-artifacts

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/extension-publish-prerelease.yml

148lines · modecode

1name: Publish Pre-Release Extension
2
3on:
4 workflow_dispatch:
5 inputs:
6 version:
7 description: 'ODD minor version (e.g., 1.1.0). Leave empty to auto-detect from latest release.'
8 required: false
9 type: string
10 default: ''
11 dry-run:
12 description: 'Dry run (package only, do not publish)'
13 required: false
14 type: boolean
15 default: false
16
17permissions:
18 contents: read
19
20jobs:
21 validate-version:
22 name: Validate Pre-Release Version
23 runs-on: ubuntu-latest
24 permissions: {}
25 outputs:
26 version: ${{ steps.validate.outputs.version }}
27 steps:
28 - name: Validate ODD minor version
29 id: validate
30 env:
31 GH_TOKEN: ${{ github.token }}
32 run: |
33 VERSION="${{ inputs.version }}"
34 # Strip leading 'v' if present
35 VERSION="${VERSION#v}"
36
37 # Auto-detect from latest release tag when no version specified
38 if [ -z "$VERSION" ]; then
39 TAG=$(gh release view --json tagName -q '.tagName' -R "${{ github.repository }}")
40 VERSION="${TAG#hve-core-v}"
41
42 MAJOR=$(echo "$VERSION" | cut -d. -f1)
43 MINOR=$(echo "$VERSION" | cut -d. -f2)
44 PATCH=$(echo "$VERSION" | cut -d. -f3)
45
46 # Derive ODD minor: if even, bump minor by 1 and reset patch
47 if (( MINOR % 2 == 0 )); then
48 MINOR=$((MINOR + 1))
49 PATCH=0
50 fi
51 VERSION="${MAJOR}.${MINOR}.${PATCH}"
52 echo "📦 Auto-derived pre-release version from latest release: $VERSION"
53 fi
54
55 # Validate format
56 if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
57 echo "::error::Invalid version format: $VERSION. Expected semantic version (e.g., 1.1.0)"
58 exit 1
59 fi
60
61 # Extract minor version
62 MINOR=$(echo "$VERSION" | cut -d. -f2)
63
64 # Check if ODD (pre-release channel uses ODD minor versions)
65 if (( MINOR % 2 == 0 )); then
66 echo "::error::Pre-release requires ODD minor version. Got: $VERSION (minor=$MINOR is EVEN)"
67 echo "::error::Use version like 1.1.0, 1.3.0, 2.1.0 for pre-release channel"
68 exit 1
69 fi
70
71 echo "✅ Valid pre-release version: $VERSION (minor=$MINOR is ODD)"
72 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
73
74 package:
75 name: Package Pre-Release Extensions
76 needs: validate-version
77 uses: ./.github/workflows/extension-package.yml
78 with:
79 version: ${{ needs.validate-version.outputs.version }}
80 channel: PreRelease
81 permissions:
82 contents: read
83
84 publish:
85 name: Publish ${{ matrix.id }}
86 needs: [package]
87 if: ${{ !inputs.dry-run }}
88 runs-on: ubuntu-latest
89 environment: marketplace
90 strategy:
91 fail-fast: false
92 matrix: ${{ fromJson(needs.package.outputs.collections-matrix) }}
93 permissions:
94 contents: read
95 id-token: write
96 steps:
97 - name: Checkout code
98 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
99 with:
100 persist-credentials: false
101
102 - name: Azure Login (OIDC)
103 uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
104 with:
105 client-id: ${{ secrets.AZURE_CLIENT_ID }}
106 tenant-id: ${{ secrets.AZURE_TENANT_ID }}
107 subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
108
109 - name: Setup Node.js
110 uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4.1.0
111 with:
112 node-version: '20'
113
114 - name: Install VSCE
115 run: npm install -g @vscode/vsce@3.7.1
116
117 - name: Download VSIX artifact
118 uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
119 with:
120 name: extension-vsix-${{ matrix.id }}
121 path: ./dist
122
123 - name: Publish pre-release to VS Code Marketplace
124 id: publish
125 run: |
126 VSIX_FILE=$(find dist -name '*.vsix' -printf '%T@ %p\n' | sort -rn | head -1 | cut -d' ' -f2)
127 if [ -z "$VSIX_FILE" ]; then
128 echo "::error::No VSIX file found for collection ${{ matrix.id }}"
129 exit 1
130 fi
131 VSIX_VERSION=$(basename "$VSIX_FILE" .vsix | grep -oE '[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$')
132 echo "version=$VSIX_VERSION" >> "$GITHUB_OUTPUT"
133 echo "📦 Publishing pre-release ${{ matrix.id }}: $VSIX_FILE (v$VSIX_VERSION)"
134 vsce publish --packagePath "$VSIX_FILE" --pre-release --azure-credential
135
136 - name: Summary
137 run: |
138 {
139 echo "## 🚀 Pre-Release Extension Published: ${{ matrix.name }}"
140 echo ""
141 echo "**Collection:** ${{ matrix.id }}"
142 echo "**Version:** ${{ steps.publish.outputs.version }}"
143 echo "**Channel:** Pre-Release (ODD minor)"
144 echo ""
145 echo "Users can install via **Switch to Pre-Release Version** in VS Code."
146 echo ""
147 echo "View on [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=ise-hve-essentials.${{ matrix.name }})"
148 } >> "$GITHUB_STEP_SUMMARY"
149