Skip to content

Commit 9955d57

Browse files
committed
Merge branch '42-integrate-changeset' into chore-changesets-dryrun
2 parents ecc88d8 + 85b50a0 commit 9955d57

File tree

1 file changed

+59
-12
lines changed

1 file changed

+59
-12
lines changed

.github/workflows/changesets-release-pr.yml

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
name: Changesets – Create/Update Release PR and Cut Tags
33

44
on:
5+
pull_request:
6+
branches: ["main"]
7+
types: [opened, synchronize, reopened, ready_for_review]
58
push:
69
branches: ["main"]
710
workflow_dispatch: {}
@@ -15,36 +18,80 @@ concurrency:
1518
cancel-in-progress: false
1619

1720
jobs:
18-
changesets:
19-
name: Create/Update Release PR (and create tags/releases after merge)
21+
# PR PATH: Preview only (no PR creation)
22+
preview:
23+
if: github.event_name == 'pull_request'
24+
name: 🔎 Changesets Preview (PR)
25+
runs-on: ubuntu-24.04
26+
27+
steps:
28+
- name: ⏬ Checkout PR head (not merge ref)
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
ref: ${{ github.event.pull_request.head.sha }}
33+
34+
- name: 🔄 Init Node & NPM cache
35+
uses: ./.github/actions/npm-cache
36+
37+
- name: 📋 Show changeset status
38+
id: status
39+
run: |
40+
npx changeset status --verbose > .changeset-status.txt || true
41+
echo "STATUS<<EOF" >> $GITHUB_OUTPUT
42+
cat .changeset-status.txt >> $GITHUB_OUTPUT
43+
echo "EOF" >> $GITHUB_OUTPUT
44+
45+
- name: 💬 Upsert PR comment with preview
46+
uses: actions/github-script@v7
47+
env:
48+
BODY: ${{ steps.status.outputs.STATUS }}
49+
with:
50+
script: |
51+
const { owner, repo, number } = context.issue;
52+
const marker = '<!-- changesets-preview-marker -->';
53+
const header = '### Changesets Preview\n\n';
54+
const bodyRaw = process.env.BODY || '';
55+
const body = `${header}\n\`\`\`\n${bodyRaw}\n\`\`\`\n\n${marker}`;
56+
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: number, per_page: 100 });
57+
const existing = comments.find(c => c.user?.type === 'Bot' && c.body?.includes(marker));
58+
if (existing) {
59+
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
60+
} else {
61+
await github.rest.issues.createComment({ owner, repo, issue_number: number, body });
62+
}
63+
64+
# MAIN PATH: Create/Update Release PR & cut tags/releases
65+
release_pr:
66+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main')
67+
name: 🧩 Create/Update Release PR (and cut tags/releases)
2068
runs-on: ubuntu-24.04
2169

2270
steps:
23-
- name: ⏬ Checkout repo
71+
- name: ⏬ Checkout main
2472
uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
2575

2676
- name: 🔄 Init Node & NPM cache
2777
uses: ./.github/actions/npm-cache
2878

29-
# This step will:
30-
# - On PRs to main: open or update the "Version Packages" release PR
31-
# - On push to main (after that PR is merged): run changeset publish flow
32-
# AND create Git tags + GitHub Releases (we let your existing release.yml do the actual build & npm publish)
3379
- name: 🧩 Changesets Action
3480
id: changesets
3581
uses: changesets/action@v1
3682
with:
37-
# Commit message + PR Title
3883
commit: "chore(release): version packages"
3984
title: "chore(release): version packages"
40-
# Very important: let the action create GitHub Releases for new tags.
41-
# That will trigger the existing .github/workflows/release.yml (on: release: published)
4285
createGithubReleases: true
43-
# We DO NOT publish here. Build+Publish are already in release.yml
4486
publish: "echo 'Publishing handled by release.yml'"
4587
env:
4688
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
HUSKY: "0" # Disable Husky to avoid error due to branch name (with slashes) generated by Changesets
89+
HUSKY: "0" # disable Husky hooks in CI
90+
CI: "true"
91+
GIT_AUTHOR_NAME: "github-actions[bot]"
92+
GIT_AUTHOR_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
93+
GIT_COMMITTER_NAME: "github-actions[bot]"
94+
GIT_COMMITTER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
4895

4996
- name: 🖨️ Summary
5097
if: always()

0 commit comments

Comments
 (0)