microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/extension-publish-prerelease.yml
155lines · modecode
| 1 | name: Publish Pre-Release Extension |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | version: |
| 7 | description: 'ODD minor version (e.g., 1.1.0, 1.3.0). Must use ODD minor number.' |
| 8 | required: true |
| 9 | type: string |
| 10 | dry-run: |
| 11 | description: 'Dry run (package only, do not publish)' |
| 12 | required: false |
| 13 | type: boolean |
| 14 | default: false |
| 15 | |
| 16 | permissions: |
| 17 | contents: read |
| 18 | |
| 19 | jobs: |
| 20 | validate-version: |
| 21 | name: Validate Pre-Release Version |
| 22 | runs-on: ubuntu-latest |
| 23 | outputs: |
| 24 | version: ${{ steps.validate.outputs.version }} |
| 25 | steps: |
| 26 | - name: Validate ODD minor version |
| 27 | id: validate |
| 28 | run: | |
| 29 | VERSION="${{ inputs.version }}" |
| 30 | # Strip leading 'v' if present |
| 31 | VERSION="${VERSION#v}" |
| 32 | |
| 33 | # Validate format |
| 34 | if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 35 | echo "::error::Invalid version format: $VERSION. Expected semantic version (e.g., 1.1.0)" |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | # Extract minor version |
| 40 | MINOR=$(echo "$VERSION" | cut -d. -f2) |
| 41 | |
| 42 | # Check if ODD (pre-release channel uses ODD minor versions) |
| 43 | if (( MINOR % 2 == 0 )); then |
| 44 | echo "::error::Pre-release requires ODD minor version. Got: $VERSION (minor=$MINOR is EVEN)" |
| 45 | echo "::error::Use version like 1.1.0, 1.3.0, 2.1.0 for pre-release channel" |
| 46 | exit 1 |
| 47 | fi |
| 48 | |
| 49 | echo "✅ Valid pre-release version: $VERSION (minor=$MINOR is ODD)" |
| 50 | echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 51 | |
| 52 | package: |
| 53 | name: Package Pre-Release Extension |
| 54 | needs: validate-version |
| 55 | runs-on: ubuntu-latest |
| 56 | outputs: |
| 57 | version: ${{ steps.package.outputs.version }} |
| 58 | vsix-file: ${{ steps.package.outputs.vsix-file }} |
| 59 | steps: |
| 60 | - name: Checkout code |
| 61 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2 |
| 62 | with: |
| 63 | persist-credentials: false |
| 64 | |
| 65 | - name: Setup Node.js |
| 66 | uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4.1.0 |
| 67 | with: |
| 68 | node-version: '20' |
| 69 | |
| 70 | - name: Install VSCE |
| 71 | run: npm install -g @vscode/vsce@3.7.1 |
| 72 | |
| 73 | - name: Setup PowerShell |
| 74 | shell: pwsh |
| 75 | run: | |
| 76 | Write-Host "PowerShell version: $($PSVersionTable.PSVersion)" |
| 77 | Install-Module -Name PowerShell-Yaml -Force -Scope CurrentUser |
| 78 | |
| 79 | - name: Prepare extension resources |
| 80 | id: prepare |
| 81 | shell: pwsh |
| 82 | run: | |
| 83 | Write-Host "🔧 Preparing extension for PreRelease channel..." |
| 84 | ./scripts/extension/Prepare-Extension.ps1 -Channel PreRelease |
| 85 | |
| 86 | - name: Package pre-release extension |
| 87 | id: package |
| 88 | shell: pwsh |
| 89 | run: | |
| 90 | $version = "${{ needs.validate-version.outputs.version }}" |
| 91 | Write-Host "📦 Packaging pre-release extension v$version..." |
| 92 | ./scripts/extension/Package-Extension.ps1 -Version $version -PreRelease |
| 93 | |
| 94 | - name: Upload VSIX artifact |
| 95 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4.4.3 |
| 96 | with: |
| 97 | name: extension-vsix-prerelease |
| 98 | path: extension/*.vsix |
| 99 | retention-days: 30 |
| 100 | |
| 101 | publish: |
| 102 | name: Publish Pre-Release to Marketplace |
| 103 | needs: [validate-version, package] |
| 104 | if: ${{ !inputs.dry-run }} |
| 105 | runs-on: ubuntu-latest |
| 106 | environment: marketplace |
| 107 | permissions: |
| 108 | contents: read |
| 109 | id-token: write |
| 110 | steps: |
| 111 | - name: Checkout code |
| 112 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2 |
| 113 | with: |
| 114 | persist-credentials: false |
| 115 | |
| 116 | - name: Azure Login (OIDC) |
| 117 | uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0 |
| 118 | with: |
| 119 | client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 120 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 121 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 122 | |
| 123 | - name: Setup Node.js |
| 124 | uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4.1.0 |
| 125 | with: |
| 126 | node-version: '20' |
| 127 | |
| 128 | - name: Install VSCE |
| 129 | run: npm install -g @vscode/vsce@3.7.1 |
| 130 | |
| 131 | - name: Download VSIX artifact |
| 132 | uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 133 | with: |
| 134 | name: extension-vsix-prerelease |
| 135 | path: ./extension |
| 136 | |
| 137 | - name: Publish pre-release to VS Code Marketplace |
| 138 | run: | |
| 139 | VSIX_FILE=$(find extension -name 'hve-core-*.vsix' -printf '%T@ %p\n' | sort -rn | head -1 | cut -d' ' -f2) |
| 140 | echo "📦 Publishing pre-release: $VSIX_FILE" |
| 141 | vsce publish --packagePath "$VSIX_FILE" --pre-release --azure-credential |
| 142 | |
| 143 | - name: Summary |
| 144 | run: | |
| 145 | { |
| 146 | echo "## 🚀 Pre-Release Extension Published" |
| 147 | echo "" |
| 148 | echo "**Version:** ${{ needs.validate-version.outputs.version }}" |
| 149 | echo "**Channel:** Pre-Release (ODD minor)" |
| 150 | echo "**VSIX File:** ${{ needs.package.outputs.vsix-file }}" |
| 151 | echo "" |
| 152 | echo "Users can install via **Switch to Pre-Release Version** in VS Code." |
| 153 | echo "" |
| 154 | echo "View on [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=ise-hve-essentials.hve-core)" |
| 155 | } >> "$GITHUB_STEP_SUMMARY" |