|
| 1 | +# Publishes vscode/sqlbi-whiteboard to the Visual Studio Marketplace. |
| 2 | +# |
| 3 | +# Not the Whiteboard installer: that is signed in Azure Pipelines (decision 3). |
| 4 | +# This job needs only a Marketplace token, stored as the repository secret VSCE_PAT. |
| 5 | +# |
| 6 | +# Automatic runs fire when package.json lands on main. The job still no-ops unless |
| 7 | +# that file's version is higher than anything already on the Marketplace, so a |
| 8 | +# description-only edit of package.json does not republish 0.1.0. workflow_dispatch |
| 9 | +# is the retry path and uses the same version check. |
| 10 | +name: Publish VS Code extension |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: [main] |
| 15 | + paths: |
| 16 | + - 'vscode/sqlbi-whiteboard/package.json' |
| 17 | + - '.github/workflows/publish-vscode-extension.yml' |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: publish-vscode-extension |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + publish: |
| 29 | + name: Publish to Marketplace |
| 30 | + runs-on: ubuntu-latest |
| 31 | + defaults: |
| 32 | + run: |
| 33 | + working-directory: vscode/sqlbi-whiteboard |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v5 |
| 36 | + |
| 37 | + - uses: actions/setup-node@v5 |
| 38 | + with: |
| 39 | + node-version: '22' |
| 40 | + cache: npm |
| 41 | + cache-dependency-path: vscode/sqlbi-whiteboard/package-lock.json |
| 42 | + |
| 43 | + - name: Install, test, and package |
| 44 | + run: | |
| 45 | + npm ci |
| 46 | + npm test |
| 47 | + npx --yes @vscode/vsce package --no-update-package-json |
| 48 | +
|
| 49 | + - name: Decide whether this version is new |
| 50 | + id: decide |
| 51 | + run: | |
| 52 | + version=$(node -p "require('./package.json').version") |
| 53 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 54 | + echo "vsix=sqlbi-whiteboard-${version}.vsix" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + if npx --yes @vscode/vsce show sqlbi.sqlbi-whiteboard --json > "$RUNNER_TEMP/published.json"; then |
| 57 | + already=$(VERSION="$version" node -e " |
| 58 | + const data = require(process.env.RUNNER_TEMP + '/published.json'); |
| 59 | + const versions = (data.versions || []).map((item) => item.version); |
| 60 | + process.stdout.write(versions.includes(process.env.VERSION) ? 'yes' : 'no'); |
| 61 | + ") |
| 62 | + else |
| 63 | + echo "Extension is not on the Marketplace yet." |
| 64 | + already=no |
| 65 | + fi |
| 66 | +
|
| 67 | + if [ "$already" = "yes" ]; then |
| 68 | + echo "publish=false" >> "$GITHUB_OUTPUT" |
| 69 | + echo "sqlbi.sqlbi-whiteboard $version is already published." |
| 70 | + else |
| 71 | + echo "publish=true" >> "$GITHUB_OUTPUT" |
| 72 | + echo "Will publish sqlbi.sqlbi-whiteboard $version." |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Publish |
| 76 | + if: steps.decide.outputs.publish == 'true' |
| 77 | + env: |
| 78 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 79 | + run: | |
| 80 | + if [ -z "$VSCE_PAT" ]; then |
| 81 | + echo "Repository secret VSCE_PAT is missing. Create a Marketplace Manage PAT and add it as VSCE_PAT." |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + npx --yes @vscode/vsce publish --packagePath "${{ steps.decide.outputs.vsix }}" --no-update-package-json --pat "$VSCE_PAT" |
0 commit comments