| 1 | name: Publish |
| 2 | |
| 3 | # Publishes the extension to the VS Code Marketplace and Open VSX. |
| 4 | # |
| 5 | # Real publish: create a GitHub Release whose tag is `v<version>` (e.g. |
| 6 | # v1.0.1) matching package.json. Dry run: trigger manually from the Actions |
| 7 | # tab with "publish" unchecked to build and package without publishing. |
| 8 | # |
| 9 | # Required repository secrets: |
| 10 | # VSCE_PAT Azure DevOps PAT for the `getsigit` Marketplace publisher. |
| 11 | # OVSX_PAT Access token for the Open VSX `getsigit` namespace. |
| 12 | |
| 13 | on: |
| 14 | release: |
| 15 | types: [published] |
| 16 | workflow_dispatch: |
| 17 | inputs: |
| 18 | publish: |
| 19 | description: "Publish to the registries (leave off for a dry run)" |
| 20 | type: boolean |
| 21 | default: false |
| 22 | |
| 23 | permissions: |
| 24 | contents: write # upload the .vsix asset to the release |
| 25 | |
| 26 | jobs: |
| 27 | publish: |
| 28 | runs-on: ubuntu-latest |
| 29 | steps: |
| 30 | - uses: actions/checkout@v4 |
| 31 | |
| 32 | - name: Setup pnpm |
| 33 | uses: pnpm/action-setup@v4 |
| 34 | |
| 35 | - name: Setup Node.js |
| 36 | uses: actions/setup-node@v4 |
| 37 | with: |
| 38 | node-version: "20" |
| 39 | cache: pnpm |
| 40 | |
| 41 | - name: Install dependencies |
| 42 | run: pnpm install --frozen-lockfile |
| 43 | |
| 44 | - name: Lint |
| 45 | run: pnpm run lint |
| 46 | |
| 47 | - name: Type check |
| 48 | run: pnpm run compile |
| 49 | |
| 50 | - name: Build |
| 51 | run: pnpm run build |
| 52 | |
| 53 | - name: Test |
| 54 | run: pnpm run test |
| 55 | |
| 56 | - name: Resolve version |
| 57 | id: meta |
| 58 | run: | |
| 59 | VERSION=$(node -p "require('./package.json').version") |
| 60 | echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 61 | echo "vsix=sigit-code-$VERSION.vsix" >> "$GITHUB_OUTPUT" |
| 62 | |
| 63 | - name: Verify tag matches package.json version |
| 64 | if: github.event_name == 'release' |
| 65 | run: | |
| 66 | TAG="${GITHUB_REF_NAME#v}" |
| 67 | PKG="${{ steps.meta.outputs.version }}" |
| 68 | if [ "$TAG" != "$PKG" ]; then |
| 69 | echo "::error::Release tag $GITHUB_REF_NAME ($TAG) does not match package.json version $PKG" |
| 70 | exit 1 |
| 71 | fi |
| 72 | |
| 73 | - name: Package VSIX |
| 74 | run: pnpm exec vsce package --no-dependencies -o "${{ steps.meta.outputs.vsix }}" |
| 75 | |
| 76 | - name: Publish to VS Code Marketplace |
| 77 | if: github.event_name == 'release' || inputs.publish |
| 78 | env: |
| 79 | VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 80 | run: pnpm exec vsce publish --no-dependencies --packagePath "${{ steps.meta.outputs.vsix }}" |
| 81 | |
| 82 | - name: Ensure Open VSX namespace |
| 83 | if: github.event_name == 'release' || inputs.publish |
| 84 | continue-on-error: true # already-exists is not an error |
| 85 | env: |
| 86 | OVSX_PAT: ${{ secrets.OVSX_PAT }} |
| 87 | run: pnpm exec ovsx create-namespace getsigit |
| 88 | |
| 89 | - name: Publish to Open VSX |
| 90 | if: github.event_name == 'release' || inputs.publish |
| 91 | env: |
| 92 | OVSX_PAT: ${{ secrets.OVSX_PAT }} |
| 93 | run: pnpm exec ovsx publish "${{ steps.meta.outputs.vsix }}" --no-dependencies |
| 94 | |
| 95 | - name: Attach VSIX to the release |
| 96 | if: github.event_name == 'release' |
| 97 | env: |
| 98 | GH_TOKEN: ${{ github.token }} |
| 99 | run: gh release upload "$GITHUB_REF_NAME" "${{ steps.meta.outputs.vsix }}" --clobber |
| 100 | |
| 101 | - name: Upload VSIX artifact (dry run) |
| 102 | if: github.event_name == 'workflow_dispatch' |
| 103 | uses: actions/upload-artifact@v4 |
| 104 | with: |
| 105 | name: ${{ steps.meta.outputs.vsix }} |
| 106 | path: ${{ steps.meta.outputs.vsix }} |