|
| 1 | +name: Release IDE Extensions |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "ide-v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry-run: |
| 10 | + description: "Dry run (don't actually publish)" |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + name: Build and Publish IDE Extensions |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Extract version from tag |
| 27 | + id: version |
| 28 | + run: | |
| 29 | + if [[ "${{ github.event_name }}" == "push" ]]; then |
| 30 | + # Extract version from tag (ide-v1.2.3 -> 1.2.3) |
| 31 | + VERSION="${GITHUB_REF#refs/tags/ide-v}" |
| 32 | + else |
| 33 | + # For manual trigger, read from package.json |
| 34 | + VERSION=$(jq -r .version packages/vscode/package.json) |
| 35 | + fi |
| 36 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 37 | + echo "Extracted version: $VERSION" |
| 38 | +
|
| 39 | + - name: Verify tag version matches package.json |
| 40 | + if: ${{ github.event_name == 'push' }} |
| 41 | + run: | |
| 42 | + PKG_VERSION=$(jq -r .version packages/vscode/package.json) |
| 43 | + TAG_VERSION="${{ steps.version.outputs.version }}" |
| 44 | + if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then |
| 45 | + echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" |
| 46 | + echo "The tag must match the committed version. Ensure you've merged the Version Packages PR first." |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + echo "Version verified: $PKG_VERSION" |
| 50 | +
|
| 51 | + - name: Log manual run version source |
| 52 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 53 | + run: | |
| 54 | + VERSION=$(jq -r .version packages/vscode/package.json) |
| 55 | + echo "Manual run uses package.json version: $VERSION" |
| 56 | +
|
| 57 | + - name: Setup Bun |
| 58 | + uses: oven-sh/setup-bun@v2 |
| 59 | + with: |
| 60 | + bun-version-file: package.json |
| 61 | + |
| 62 | + - name: Setup Node.js |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: "20" |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: bun install --frozen-lockfile |
| 69 | + |
| 70 | + - name: Build VS Code extension |
| 71 | + run: bunx turbo run build --filter=t-req-vscode... |
| 72 | + |
| 73 | + - name: Run VS Code unit tests |
| 74 | + run: bun run --cwd packages/vscode test:unit |
| 75 | + |
| 76 | + - name: Run VS Code integration tests |
| 77 | + run: xvfb-run -a bun run --cwd packages/vscode test:integration |
| 78 | + |
| 79 | + - name: Package VSIX |
| 80 | + id: package |
| 81 | + working-directory: packages/vscode |
| 82 | + run: | |
| 83 | + VERSION="${{ steps.version.outputs.version }}" |
| 84 | + VSIX_NAME="t-req-vscode-${VERSION}.vsix" |
| 85 | + bunx @vscode/vsce package --no-dependencies --out "$VSIX_NAME" |
| 86 | + SHA256=$(sha256sum "$VSIX_NAME" | awk '{print $1}') |
| 87 | + echo "vsix_name=$VSIX_NAME" >> "$GITHUB_OUTPUT" |
| 88 | + echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" |
| 89 | + echo "Created $VSIX_NAME" |
| 90 | + echo "SHA256: $SHA256" |
| 91 | +
|
| 92 | + - name: Upload VSIX artifact |
| 93 | + uses: actions/upload-artifact@v4 |
| 94 | + with: |
| 95 | + name: t-req-ide-vsix |
| 96 | + path: packages/vscode/${{ steps.package.outputs.vsix_name }} |
| 97 | + |
| 98 | + - name: Publish to VS Code Marketplace |
| 99 | + if: ${{ github.event_name == 'push' || !inputs.dry-run }} |
| 100 | + working-directory: packages/vscode |
| 101 | + env: |
| 102 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 103 | + run: | |
| 104 | + if [[ -z "$VSCE_PAT" ]]; then |
| 105 | + echo "Missing VSCE_PAT secret" |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | + bunx @vscode/vsce publish --packagePath "${{ steps.package.outputs.vsix_name }}" --pat "$VSCE_PAT" |
| 109 | +
|
| 110 | + - name: Publish to Cursor (OpenVSX) |
| 111 | + if: ${{ github.event_name == 'push' || !inputs.dry-run }} |
| 112 | + working-directory: packages/vscode |
| 113 | + env: |
| 114 | + OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }} |
| 115 | + run: | |
| 116 | + if [[ -z "$OVSX_TOKEN" ]]; then |
| 117 | + echo "Missing OVSX_TOKEN secret" |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | + bunx ovsx publish "${{ steps.package.outputs.vsix_name }}" -p "$OVSX_TOKEN" |
| 121 | +
|
| 122 | + - name: Dry run summary |
| 123 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run }} |
| 124 | + run: | |
| 125 | + echo "=== DRY RUN SUMMARY ===" |
| 126 | + echo "Version: ${{ steps.version.outputs.version }}" |
| 127 | + echo "VSIX: packages/vscode/${{ steps.package.outputs.vsix_name }}" |
| 128 | + echo "SHA256: ${{ steps.package.outputs.sha256 }}" |
| 129 | + echo "" |
| 130 | + echo "[dry-run] Would publish to VS Code Marketplace" |
| 131 | + echo "[dry-run] Would publish to Cursor (OpenVSX)" |
0 commit comments