|
| 1 | +name: Multi-version Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # run manually |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*.*.*" # publish when you tag a release |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + vscode_version: |
| 15 | + [ |
| 16 | + "1.0.0", |
| 17 | + "1.14.0", |
| 18 | + "1.20.0", |
| 19 | + "1.30.0", |
| 20 | + "1.40.0", |
| 21 | + "1.50.0", |
| 22 | + "1.60.0", |
| 23 | + "1.70.0", |
| 24 | + "1.80.0", |
| 25 | + "1.90.0", |
| 26 | + "1.100.0", |
| 27 | + "1.104.0", |
| 28 | + ] |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Setup Node |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: 24 |
| 36 | + |
| 37 | + - name: Install deps |
| 38 | + run: npm ci |
| 39 | + |
| 40 | + - name: Adjust engines.vscode |
| 41 | + run: | |
| 42 | + node <<'EOF' |
| 43 | + const fs = require('fs'); |
| 44 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 45 | + const current = "1.104.0"; // your real minimum requirement |
| 46 | + const target = process.env.VSCODE_VERSION; |
| 47 | + pkg.engines.vscode = `^${target}`; |
| 48 | + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); |
| 49 | +
|
| 50 | + if (target < current) { |
| 51 | + let readme = fs.readFileSync('README.md', 'utf8'); |
| 52 | + const warning = `\n> ⚠️ **Compatibility Notice:** This build targets VS Code < ${current}. It is not tested and may break. Provided only for backward compatibility.\n`; |
| 53 | + if (!readme.includes("⚠️ **Compatibility Notice:**")) { |
| 54 | + readme = warning + readme; |
| 55 | + fs.writeFileSync('README.md', readme); |
| 56 | + } |
| 57 | + } |
| 58 | + EOF |
| 59 | + env: |
| 60 | + VSCODE_VERSION: ${{ matrix.vscode_version }} |
| 61 | + |
| 62 | + - name: Build extension |
| 63 | + run: npm run compile --if-present |
| 64 | + |
| 65 | + - name: Installing required package managers |
| 66 | + run: npm install -g vsce ovsx |
| 67 | + |
| 68 | + - name: Package extension |
| 69 | + run: npx vsce package |
| 70 | + |
| 71 | + - name: Publish to Marketplace |
| 72 | + run: npx vsce publish -p ${{ secrets.VSCE_TOKEN }} |
| 73 | + env: |
| 74 | + VSCE_PAT: ${{ secrets.VSCE_TOKEN }} |
| 75 | + |
| 76 | + - name: Publish to Open VSX |
| 77 | + run: npx ovsx publish -p ${{ secrets.OVSX_TOKEN }} |
| 78 | + env: |
| 79 | + OVSX_PAT: ${{ secrets.OVSX_TOKEN }} |
0 commit comments