Skip to content

Commit ff45fc3

Browse files
authored
chore: gate marketplace publish behind PR approval check (Zoo-Code-Org#516)
* feat(zoo): gating marketplace publish behind PR approvals * docs(release): updating process to match ci
1 parent 8ea0779 commit ff45fc3

2 files changed

Lines changed: 63 additions & 20 deletions

File tree

.github/workflows/marketplace-publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,51 @@ on:
77
workflow_dispatch:
88

99
jobs:
10+
check-pr-approval:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: read
14+
steps:
15+
- name: Check PR approval status
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
REPO: ${{ github.repository }}
19+
SHA: ${{ github.sha }}
20+
run: |
21+
pr_number=$(gh api "repos/${REPO}/commits/${SHA}/pulls" \
22+
--header "Accept: application/vnd.github+json" \
23+
--jq '.[0].number // empty')
24+
25+
if [ -z "$pr_number" ]; then
26+
echo "No PR found for commit ${SHA}. Deployment requires an approved PR."
27+
exit 1
28+
fi
29+
30+
review_decision=$(gh api graphql \
31+
-f owner="${REPO%%/*}" \
32+
-f name="${REPO#*/}" \
33+
-F number="$pr_number" \
34+
-f query='
35+
query($owner: String!, $name: String!, $number: Int!) {
36+
repository(owner: $owner, name: $name) {
37+
pullRequest(number: $number) {
38+
reviewDecision
39+
}
40+
}
41+
}' \
42+
--jq '.data.repository.pullRequest.reviewDecision // "NONE"')
43+
44+
echo "PR #${pr_number} review_decision: ${review_decision}"
45+
46+
if [ "$review_decision" != "APPROVED" ]; then
47+
echo "PR #${pr_number} is not approved (state: ${review_decision}). Deployment blocked."
48+
exit 1
49+
fi
50+
51+
echo "PR #${pr_number} is approved. Proceeding."
52+
1053
publish-stable:
54+
needs: [check-pr-approval]
1155
runs-on: ubuntu-latest
1256
environment: marketplace-production
1357
permissions:

.roo/commands/release.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,31 @@ mode: code
8282
- If the release includes translated README or package-localization updates, include those files in the same PR.
8383
- Let the release validation workflow and normal PR checks run before merge.
8484
85-
11. After the release PR is merged, stop for a release review on the resulting `main` commit.
85+
11. Once the release PR is open and passing checks, get it approved by a reviewer before proceeding.
8686
87-
```bash
88-
git switch main
89-
git pull origin main
90-
REVIEWED_SHA=$(git rev-parse HEAD)
91-
git rev-parse --short "$REVIEWED_SHA"
92-
```
93-
94-
- Review the merged release state before any publish step.
95-
- Confirm that `src/package.json`, `CHANGELOG.md`, `src/CHANGELOG.md`, and the Marketplace-facing `README.md` all reflect the intended release.
96-
- Check that the release PR checks passed and that the merged commit is the one you want to ship.
97-
- Share that review summary, including `REVIEWED_SHA`, with the user and wait for explicit confirmation before creating the tag.
98-
- Do not create the tag or trigger publishing until the user says to proceed.
87+
- Do not create the tag until the PR has at least one approval — the publish workflow enforces this automatically and will fail if no approved PR is found for the tagged commit.
9988
100-
12. Only after explicit confirmation, create the release tag on that reviewed `main` commit:
89+
12. After the PR is approved, create the release tag on the release branch tip and push it:
10190
10291
```bash
103-
git tag v[version] "$REVIEWED_SHA"
92+
git tag v[version]
10493
git push origin v[version]
10594
```
10695
107-
- If `main` advances after the review pause, keep using the pinned `REVIEWED_SHA` for the tag instead of silently tagging a newer commit.
96+
- Tag the branch tip as-is. Do not rebase or merge additional commits into the release branch before tagging — doing so changes the commit SHA and may pull in unreviewed changes that weren't part of the approval.
97+
- The publish workflow validates that the tag version matches `src/package.json`.
10898
109-
13. The stable publish workflow runs from the `v[version]` tag.
99+
13. The tag push triggers the stable publish workflow.
110100
111-
- Do not create the tag before the release PR is merged.
112-
- The publish workflow validates that the tag version matches `src/package.json`.
113-
- Marketplace and Open VSX publishing use the configured CI secrets.
101+
- The workflow first checks that the tagged commit belongs to an approved PR. If the PR is not yet approved this step fails — approve the PR first, then retrigger by recreating and pushing the tag: `git tag -d v[version] && git push origin :refs/tags/v[version] && git tag v[version] && git push origin v[version]`.
102+
- Once the approval check passes, the `marketplace-production` environment gate fires and notifies the configured approvers.
103+
- A human approver must then approve the deployment before the extension is published to VS Code Marketplace and Open VSX.
104+
105+
14. After a successful deployment, add the release PR to the merge queue.
106+
107+
```bash
108+
gh pr merge [pr-number] --auto --squash
109+
```
110+
111+
- Do not merge before the deployment succeeds — merging first and then discovering a publish failure leaves `main` ahead of what was actually shipped.
112+
- The merge queue runs all required checks against the release branch before merging to `main`.

0 commit comments

Comments
 (0)