microsoft/hve-core

Public

mirrored fromhttps://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
hve-core-v2.3.5

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

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