name: Release on: push: branches: - main - '*.x.x' concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Don't cancel a publish partway through! cancel-in-progress: false permissions: {} jobs: release: environment: deploy name: Release runs-on: ubuntu-latest permissions: # To create a release, and to push branches: contents: write # To create/maintain the Changesets pull request pull-requests: write # PRs are backed by issues; this helps with stuff like reading labels/etc issues: read # To enable trusted publishing id-token: write outputs: vscode-published: ${{ steps.vscode.outputs.published }} published-packages: ${{ steps.changesets.outputs.published-packages }} steps: - name: Checkout Code uses: actions/checkout@v6 with: fetch-depth: 0 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v6 with: node-version-file: '.node-version' cache: pnpm - run: pnpm install --frozen-lockfile - name: Turbo cache uses: ./.github/actions/turbo-cache - name: Create Release Pull Request or Publish to npm id: changesets uses: changesets/action@v2 with: version-script: pnpm ci:version # This expects you to have a script called release which does a build for your packages and calls changeset publish publish-script: pnpm release - name: Note VSCode extension release id: vscode if: ${{ steps.changesets.outputs.published == 'true' && contains(steps.changesets.outputs.published-packages, '"name":"vscode-graphql') }} run: echo "published=true" >> "$GITHUB_OUTPUT" - name: Build VSCode extension .vsix files if: ${{ steps.vscode.outputs.published == 'true' }} env: PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.published-packages }} run: node scripts/release-vscode.mts build - name: Attach VSCode .vsix files to GitHub Releases if: ${{ steps.vscode.outputs.published == 'true' }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.published-packages }} run: node scripts/release-vscode.mts attach - name: Upload VSCode extension .vsix artifacts if: ${{ steps.vscode.outputs.published == 'true' }} uses: actions/upload-artifact@v4 with: name: vscode-extensions path: packages/vscode-graphql*/*.vsix if-no-files-found: error publish-vscode-extensions: name: Publish to ${{ matrix.registry }} needs: release if: ${{ github.ref_name == 'main' && needs.release.outputs.vscode-published == 'true' }} runs-on: ubuntu-latest permissions: {} strategy: fail-fast: false matrix: include: - registry: VSCode Marketplace command: publish-vsce - registry: Open VSX Registry command: publish-ovsx steps: - uses: actions/checkout@v5 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v6 with: node-version-file: '.node-version' cache: pnpm - run: pnpm install --frozen-lockfile - uses: actions/download-artifact@v4 with: name: vscode-extensions # `upload-artifact` strips the path prefix up to the first wildcard # segment, so the artifact contains `vscode-graphql*/*.vsix` rather # than `packages/vscode-graphql*/*.vsix`. Restore the `packages/` # prefix here so the layout lines up with `vsixPath('vsix', …)` in # the script. path: vsix/packages - name: Publish env: VSCE_PAT: ${{ secrets.VSCE_PAT }} OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }} PUBLISHED_PACKAGES: ${{ needs.release.outputs.published-packages }} run: node scripts/release-vscode.mts ${{ matrix.command }}