Publish Extension #55
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: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Get version from tag | |
| id: version | |
| run: | | |
| # Extract version from git tag (remove 'v' prefix) | |
| TAG_VERSION=${GITHUB_REF_NAME#v} | |
| echo "VERSION=$TAG_VERSION" >> $GITHUB_OUTPUT | |
| # Verify package.json version matches tag | |
| PKG_VERSION=$(node -p "require('./package.json').version") | |
| echo "Tag version: $TAG_VERSION" | |
| echo "Package.json version: $PKG_VERSION" | |
| if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then | |
| echo "::warning::Tag version ($TAG_VERSION) doesn't match package.json version ($PKG_VERSION)" | |
| fi | |
| # Set VSIX filename | |
| EXTENSION_NAME=$(node -p "require('./package.json').name") | |
| echo "VSIX_FILE=${EXTENSION_NAME}-${PKG_VERSION}.vsix" >> $GITHUB_OUTPUT | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run vscode:prepublish | |
| - name: Package Extension | |
| run: npx @vscode/vsce package | |
| - name: Upload VSIX as Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extension | |
| path: "*.vsix" | |
| retention-days: 90 | |
| - name: Publish to VS Code Marketplace | |
| run: | | |
| echo "Publishing ${{ steps.version.outputs.VSIX_FILE }} to VS Code Marketplace..." | |
| npx @vscode/vsce publish --packagePath ${{ steps.version.outputs.VSIX_FILE }} -p ${{ secrets.VSCE_PAT }} | |
| - name: Publish to Open VSX Registry | |
| run: | | |
| echo "Publishing ${{ steps.version.outputs.VSIX_FILE }} to Open VSX Registry..." | |
| npx ovsx publish ${{ steps.version.outputs.VSIX_FILE }} -p ${{ secrets.OVSX_PAT }} | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| files: "*.vsix" | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true |