v1.4.1 #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Extension | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Package without publishing' | |
| type: boolean | |
| default: false | |
| concurrency: | |
| group: publish-extension | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify Release Commit Is on Main | |
| if: github.event_name == 'release' | |
| shell: bash | |
| run: | | |
| if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then | |
| echo "::error::Release tag must point to a commit on main." | |
| exit 1 | |
| fi | |
| - name: Setup Node | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check types and lint | |
| run: npm run check-types && npm run lint | |
| - name: Package VSIX for Verification | |
| id: package-vsix | |
| uses: HaaLeo/publish-vscode-extension@v2 | |
| with: | |
| pat: dry-run | |
| registryUrl: https://marketplace.visualstudio.com | |
| dryRun: true | |
| - name: Verify VSIX Package and Extension Host | |
| shell: bash | |
| env: | |
| VSIX_PATH: ${{ steps.package-vsix.outputs.vsixPath }} | |
| run: xvfb-run -a node scripts/verify-vsix-package.mjs "$VSIX_PATH" | |
| - name: Publish Verified VSIX to VS Code Marketplace | |
| uses: HaaLeo/publish-vscode-extension@v2 | |
| with: | |
| pat: ${{ secrets.VSCE_PAT }} | |
| registryUrl: https://marketplace.visualstudio.com | |
| extensionFile: ${{ steps.package-vsix.outputs.vsixPath }} | |
| skipDuplicate: true | |
| dryRun: ${{ inputs.dry_run }} | |
| - name: Publish Verified VSIX to Open VSX | |
| uses: HaaLeo/publish-vscode-extension@v2 | |
| with: | |
| pat: ${{ secrets.OPEN_VSX_TOKEN }} | |
| registryUrl: https://open-vsx.org | |
| extensionFile: ${{ steps.package-vsix.outputs.vsixPath }} | |
| skipDuplicate: true | |
| dryRun: ${{ inputs.dry_run }} | |
| - name: Upload VSIX to Release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| files: ${{ steps.package-vsix.outputs.vsixPath }} | |
| publish-npm: | |
| name: Verify and Publish npm Package | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify Release Commit Is on Main | |
| if: github.event_name == 'release' | |
| shell: bash | |
| run: | | |
| if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then | |
| echo "::error::Release tag must point to a commit on main." | |
| exit 1 | |
| fi | |
| - name: Setup Node for Trusted Publishing | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: '22.x' | |
| registry-url: https://registry.npmjs.org | |
| package-manager-cache: false | |
| - name: Install Trusted-Publishing npm CLI | |
| run: npm install --global "npm@^11.5.1" | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Verify Trusted-Publishing Toolchain | |
| run: | | |
| node -e "const semver = require('semver'); const npm = require('child_process').execFileSync('npm', ['--version'], { encoding: 'utf8' }).trim(); if (!semver.satisfies(process.version, '>=22.14.0') || !semver.satisfies(npm, '>=11.5.1')) { throw new Error('Trusted publishing requires Node >=22.14.0 and npm >=11.5.1'); } console.log('Node', process.version, 'npm', npm);" | |
| - name: Run Unit Tests | |
| run: npm test | |
| - name: Build and Verify npm Artifact | |
| id: npm-package | |
| shell: bash | |
| run: | | |
| output_dir="$RUNNER_TEMP/npm-package" | |
| npm run verify:npm-package -- --output-dir "$output_dir" | |
| echo "metadata=$output_dir/package-metadata.json" >> "$GITHUB_OUTPUT" | |
| - name: Upload Verified npm Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: npm-package-${{ github.run_attempt }} | |
| path: ${{ runner.temp }}/npm-package/ | |
| if-no-files-found: error | |
| retention-days: 7 | |
| - name: Publish Verified Artifact to npm | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| run: >- | |
| node scripts/publish-npm-package.mjs | |
| --metadata "${{ steps.npm-package.outputs.metadata }}" | |
| --tag "${{ github.event.release.tag_name }}" | |
| --ref "${{ github.ref }}" |