|
| 1 | +# This script builds the extension and publishes it to the VS Code Marketplace. |
| 2 | + |
| 3 | +# Ensure the script stops on errors |
| 4 | +$ErrorActionPreference = "Stop" |
| 5 | + |
| 6 | +# 1. Run the build script to create the VSIX package |
| 7 | +Write-Host "Building extension..." -ForegroundColor Cyan |
| 8 | +& .\build.ps1 |
| 9 | +if ($LASTEXITCODE -ne 0) { |
| 10 | + Write-Host "Build failed. Please fix the errors and try again." -ForegroundColor Red |
| 11 | + exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +# 2. Check if we're already logged in to vsce |
| 15 | +Write-Host "`nChecking marketplace login status..." -ForegroundColor Cyan |
| 16 | +$publisherName = "RobBos" # From package.json |
| 17 | + |
| 18 | +# Try to get the list of publishers (this will fail if not logged in) |
| 19 | +$vsceListOutput = npx vsce ls-publishers 2>&1 |
| 20 | +$isLoggedIn = $LASTEXITCODE -eq 0 |
| 21 | + |
| 22 | +if (-not $isLoggedIn) { |
| 23 | + Write-Host "You are not logged in to the VS Code Marketplace." -ForegroundColor Yellow |
| 24 | + Write-Host "" |
| 25 | + Write-Host "To publish extensions, you need a Personal Access Token from Azure DevOps:" -ForegroundColor Yellow |
| 26 | + Write-Host "1. Go to https://dev.azure.com" -ForegroundColor Gray |
| 27 | + Write-Host "2. Click User Settings -> Personal Access Tokens" -ForegroundColor Gray |
| 28 | + Write-Host "3. Create new token with 'Marketplace (Publish)' scope" -ForegroundColor Gray |
| 29 | + Write-Host "4. Set organization to 'All accessible organizations'" -ForegroundColor Gray |
| 30 | + Write-Host "" |
| 31 | + |
| 32 | + $publisher = Read-Host "Enter your publisher name (default: $publisherName from package.json)" |
| 33 | + if ([string]::IsNullOrWhiteSpace($publisher)) { |
| 34 | + $publisher = $publisherName |
| 35 | + } |
| 36 | + |
| 37 | + Write-Host "`nLogging in as '$publisher'..." -ForegroundColor Cyan |
| 38 | + Write-Host "You will be prompted for your Personal Access Token." -ForegroundColor Gray |
| 39 | + npx vsce login $publisher |
| 40 | + |
| 41 | + if ($LASTEXITCODE -ne 0) { |
| 42 | + Write-Host "`nLogin failed. Cannot publish without authentication." -ForegroundColor Red |
| 43 | + exit 1 |
| 44 | + } |
| 45 | + Write-Host "Login successful!" -ForegroundColor Green |
| 46 | +} else { |
| 47 | + Write-Host "Already logged in to the marketplace." -ForegroundColor Green |
| 48 | +} |
| 49 | + |
| 50 | +# 3. Publish the extension |
| 51 | +Write-Host "`nPublishing extension to the VS Code Marketplace..." -ForegroundColor Cyan |
| 52 | +npx vsce publish |
| 53 | + |
| 54 | +if ($LASTEXITCODE -eq 0) { |
| 55 | + Write-Host "`n✅ Extension published successfully!" -ForegroundColor Green |
| 56 | + Write-Host "It may take a few minutes to appear in the marketplace." -ForegroundColor Gray |
| 57 | +} else { |
| 58 | + Write-Host "`n❌ Publishing failed. Please check the error messages above." -ForegroundColor Red |
| 59 | + exit 1 |
| 60 | +} |
0 commit comments