Publish to VSCode and OpenVSX Marketplaces #5
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 to VSCode and OpenVSX Marketplaces | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| skip_tests: | |
| description: 'Skip tests (use for hotfixes only)' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate tag format | |
| id: validate | |
| run: | | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" | |
| echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT | |
| if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then | |
| echo "Error: Tag must follow format v{major}.{minor}.{patch} or v{major}.{minor}.{patch}-{prerelease}" | |
| echo "Examples: v1.0.0, v1.0.0-beta.1" | |
| echo "Got: $TAG_NAME" | |
| exit 1 | |
| fi | |
| VERSION=${TAG_NAME#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "✓ Valid tag format: $TAG_NAME (version: $VERSION)" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Verify tests pass | |
| if: github.event.inputs.skip_tests != 'true' | |
| run: | | |
| echo "Running tests before publishing..." | |
| npm run compile-tests | |
| xvfb-run -a npm test | |
| env: | |
| VSCODE_TEST_TIMEOUT: 120000 | |
| - name: Update package.json version | |
| run: | | |
| VERSION=${{ steps.validate.outputs.version }} | |
| echo "Updating package.json to version $VERSION" | |
| npm version $VERSION --no-git-tag-version --allow-same-version | |
| - name: Build extension | |
| run: npm run vscode:prepublish | |
| - name: Package extension | |
| run: npm run vsce:package | |
| - name: Verify VSIX was created | |
| run: | | |
| VSIX_FILE="qiskit-vscode-${{ steps.validate.outputs.version }}.vsix" | |
| if [ ! -f "$VSIX_FILE" ]; then | |
| echo "Error: VSIX file not found: $VSIX_FILE" | |
| ls -la *.vsix || echo "No VSIX files found" | |
| exit 1 | |
| fi | |
| echo "✓ VSIX created: $VSIX_FILE ($(du -h "$VSIX_FILE" | cut -f1))" | |
| - name: Publish to VSCode Marketplace | |
| id: publish_vscode | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: | | |
| echo "Publishing extension to VSCode Marketplace..." | |
| npx vsce publish -p "$VSCE_PAT" | |
| echo "✓ Successfully published to marketplace" | |
| - name: Report VSCode Marketplace failure | |
| if: steps.publish_vscode.outcome == 'failure' | |
| run: | | |
| echo "::error::VSCode Marketplace publishing failed" | |
| echo "❌ **VSCode Marketplace publishing failed** - The release process has stopped." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Next steps:**" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Check the error logs above" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Verify VSCE_PAT secret is valid and not expired" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Fix the issue and re-run the workflow or publish manually" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| - name: Publish to Open VSX | |
| id: publish_ovsx | |
| env: | |
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | |
| run: | | |
| echo "Publishing extension to Open VSX Marketplace..." | |
| npx ovsx publish qiskit-vscode-${{ steps.validate.outputs.version }}.vsix -p "$OVSX_PAT" | |
| echo "✓ Successfully published to Open VSX" | |
| - name: Report Open VSX failure | |
| if: steps.publish_ovsx.outcome == 'failure' | |
| run: | | |
| echo "::error::Open VSX publishing failed" | |
| echo "❌ **Open VSX publishing failed** - The release process has stopped." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Next steps:**" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Check the error logs above" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Verify OVSX_PAT secret is valid and not expired" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Fix the issue and re-run the workflow or publish manually" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| - name: Upload VSIX as release asset | |
| uses: shogo82148/actions-upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: ./qiskit-vscode-${{ steps.validate.outputs.version }}.vsix | |
| asset_name: qiskit-vscode-${{ steps.validate.outputs.version }}.vsix | |
| asset_content_type: application/zip | |
| - name: Create release summary | |
| if: success() | |
| run: | | |
| cat <<EOF >> $GITHUB_STEP_SUMMARY | |
| ## ✅ Release Published Successfully | |
| - **Version**: ${{ steps.validate.outputs.version }} | |
| - **Tag**: ${{ steps.validate.outputs.tag }} | |
| - **VSIX File**: qiskit-vscode-${{ steps.validate.outputs.version }}.vsix | |
| - **VSCode Marketplace**: Published ✓ | |
| - **Open VSX**: Published ✓ | |
| - **Release Asset**: Uploaded ✓ | |
| The extension is now available on: | |
| - [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=Qiskit.qiskit-vscode) | |
| - [Open VSX](https://open-vsx.org/extension/Qiskit/qiskit-vscode) | |
| EOF | |
| - name: Report failure | |
| if: failure() | |
| run: | | |
| cat << EOF >> $GITHUB_STEP_SUMMARY | |
| ## ❌ Release Publishing Failed | |
| - **Version**: ${{ steps.validate.outputs.version }} | |
| - **Tag**: ${{ steps.validate.outputs.tag }} | |
| Please check the workflow logs for details and try again. | |
| You can manually publish using: | |
| **VSCode Marketplace:** | |
| \`\`\`bash | |
| npm run vsce:package | |
| npx vsce publish -p YOUR_VSCE_PAT | |
| \`\`\` | |
| **Open VSX:** | |
| \`\`\`bash | |
| npx ovsx publish qiskit-vscode-${{ steps.validate.outputs.version }}.vsix -p YOUR_OVSX_PAT | |
| \`\`\` | |
| See [MARKETPLACE_PUBLISHING.md](docs/MARKETPLACE_PUBLISHING.md) and [OPEN_VSX_SETUP.md](docs/OPEN_VSX_SETUP.md) for details. | |
| EOF |