|
| 1 | +name: Publish VSCode Extension |
| 2 | +# Publishes platform-specific VSIXs to the VS Code Marketplace on tag push. |
| 3 | +# Runs in parallel with release.yml (GoReleaser). |
| 4 | +# |
| 5 | +# Required secret: |
| 6 | +# VSCE_PAT - Azure DevOps Personal Access Token with "Marketplace (Manage)" scope. |
| 7 | +# Create at: https://dev.azure.com → User Settings → Personal Access Tokens |
| 8 | +# Scope: "Marketplace (Manage)", Organization: "All accessible organizations" |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + tags: |
| 13 | + - 'v*' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + name: Build VSIX (${{ matrix.target }}) |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 15 |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - target: linux-x64 |
| 27 | + goos: linux |
| 28 | + goarch: amd64 |
| 29 | + binary: gosqlx |
| 30 | + - target: linux-arm64 |
| 31 | + goos: linux |
| 32 | + goarch: arm64 |
| 33 | + binary: gosqlx |
| 34 | + - target: darwin-x64 |
| 35 | + goos: darwin |
| 36 | + goarch: amd64 |
| 37 | + binary: gosqlx |
| 38 | + - target: darwin-arm64 |
| 39 | + goos: darwin |
| 40 | + goarch: arm64 |
| 41 | + binary: gosqlx |
| 42 | + - target: win32-x64 |
| 43 | + goos: windows |
| 44 | + goarch: amd64 |
| 45 | + binary: gosqlx.exe |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Setup Go |
| 50 | + uses: actions/setup-go@v5 |
| 51 | + with: |
| 52 | + go-version: '1.24' |
| 53 | + |
| 54 | + - name: Cross-compile binary |
| 55 | + env: |
| 56 | + GOOS: ${{ matrix.goos }} |
| 57 | + GOARCH: ${{ matrix.goarch }} |
| 58 | + run: | |
| 59 | + mkdir -p vscode-extension/bin |
| 60 | + go build -ldflags="-s -w" -o "vscode-extension/bin/${{ matrix.binary }}" ./cmd/gosqlx |
| 61 | +
|
| 62 | + - name: Generate binary checksum |
| 63 | + run: | |
| 64 | + sha256sum "vscode-extension/bin/${{ matrix.binary }}" | awk '{print $1}' > "vscode-extension/bin/${{ matrix.binary }}.sha256" |
| 65 | +
|
| 66 | + - name: Smoke test binary |
| 67 | + if: matrix.target == 'linux-x64' |
| 68 | + run: | |
| 69 | + chmod +x vscode-extension/bin/${{ matrix.binary }} |
| 70 | + ./vscode-extension/bin/${{ matrix.binary }} version |
| 71 | +
|
| 72 | + - name: Setup Node |
| 73 | + uses: actions/setup-node@v4 |
| 74 | + with: |
| 75 | + node-version: '20' |
| 76 | + |
| 77 | + - name: Install dependencies |
| 78 | + working-directory: vscode-extension |
| 79 | + run: npm ci |
| 80 | + |
| 81 | + - name: Patch version from tag |
| 82 | + working-directory: vscode-extension |
| 83 | + run: | |
| 84 | + VERSION="${GITHUB_REF_NAME#v}" |
| 85 | + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 86 | + echo "Tag '$GITHUB_REF_NAME' does not produce a valid semver: '$VERSION'" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + npm version "$VERSION" --no-git-tag-version |
| 90 | +
|
| 91 | + - name: Package VSIX |
| 92 | + working-directory: vscode-extension |
| 93 | + run: npx vsce package --target ${{ matrix.target }} |
| 94 | + |
| 95 | + - name: Upload VSIX artifact |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: vsix-${{ matrix.target }} |
| 99 | + path: vscode-extension/*.vsix |
| 100 | + |
| 101 | + publish: |
| 102 | + name: Publish to Marketplace |
| 103 | + needs: build |
| 104 | + runs-on: ubuntu-latest |
| 105 | + timeout-minutes: 10 |
| 106 | + steps: |
| 107 | + - name: Setup Node |
| 108 | + uses: actions/setup-node@v4 |
| 109 | + with: |
| 110 | + node-version: '20' |
| 111 | + |
| 112 | + - name: Install vsce |
| 113 | + run: npm install -g @vscode/vsce |
| 114 | + |
| 115 | + - name: Download all VSIX artifacts |
| 116 | + uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + pattern: vsix-* |
| 119 | + merge-multiple: true |
| 120 | + path: vsix |
| 121 | + |
| 122 | + - name: Verify VSCE_PAT is set |
| 123 | + run: | |
| 124 | + if [ -z "$VSCE_PAT" ]; then |
| 125 | + echo "Error: VSCE_PAT secret is not configured" |
| 126 | + exit 1 |
| 127 | + fi |
| 128 | + env: |
| 129 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 130 | + |
| 131 | + - name: Publish all platforms |
| 132 | + env: |
| 133 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 134 | + run: | |
| 135 | + for vsix in vsix/*.vsix; do |
| 136 | + echo "Publishing $vsix..." |
| 137 | + vsce publish --packagePath "$vsix" |
| 138 | + done |
0 commit comments