Skip to content

Commit 03ece7a

Browse files
committed
ci(release): fix Changesets reset by using head_sha and naga tip
1 parent 578515c commit 03ece7a

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
if: >-
2626
${{ github.event.workflow_run.conclusion == 'success' &&
2727
github.event.workflow_run.event == 'push' &&
28-
github.repository == 'LIT-Protocol/js-sdk' &&
2928
(github.event.workflow_run.head_branch == 'naga' ||
3029
github.event.workflow_run.head_branch == 'canary-naga') }}
3130
# Enable this when we want to implement docker image release
@@ -46,7 +45,7 @@ jobs:
4645
uses: actions/checkout@v4
4746
with:
4847
fetch-depth: 0
49-
ref: ${{ github.event.workflow_run.head_branch }}
48+
ref: ${{ github.event.workflow_run.head_sha }}
5049

5150
- name: Setup PNPM
5251
uses: pnpm/action-setup@v4
@@ -73,18 +72,6 @@ jobs:
7372
cache: 'pnpm'
7473
cache-dependency-path: pnpm-lock.yaml
7574

76-
- name: Print repo and branch context
77-
run: |
78-
echo "Repo: $GITHUB_REPOSITORY"
79-
echo "Head branch: ${{ github.event.workflow_run.head_branch }}"
80-
echo "Workflow head_sha: ${{ github.event.workflow_run.head_sha }}"
81-
echo "Checked out ref: $(git rev-parse --abbrev-ref HEAD)"
82-
echo "Current commit: $(git rev-parse HEAD)"
83-
echo "Node: $(node -v)"
84-
echo "PNPM: $(pnpm --version)"
85-
[ -f pnpm-lock.yaml ] && echo "pnpm-lock.yaml present" || echo "pnpm-lock.yaml missing"
86-
[ -d .changeset ] && echo ".changeset present" || echo ".changeset missing"
87-
8875
- name: Install project dependencies
8976
run: pnpm install --frozen-lockfile
9077

@@ -100,6 +87,26 @@ jobs:
10087
- name: Build packages
10188
run: pnpm run build
10289

90+
- name: Preflight diagnostics
91+
run: |
92+
echo "Repo: $GITHUB_REPOSITORY"
93+
echo "Head branch: ${{ github.event.workflow_run.head_branch }}"
94+
echo "Workflow head_sha: ${{ github.event.workflow_run.head_sha }}"
95+
echo "Checked out ref: $(git rev-parse --abbrev-ref HEAD)"
96+
echo "Current commit: $(git rev-parse HEAD)"
97+
echo "Node: $(node -v)"
98+
echo "PNPM: $(pnpm --version)"
99+
[ -f pnpm-lock.yaml ] && echo "pnpm-lock.yaml present" || echo "pnpm-lock.yaml missing"
100+
if [ -d .changeset ]; then
101+
echo ".changeset present" && ls -la .changeset
102+
if [ -f .changeset/config.json ]; then
103+
echo "changeset config (baseBranch + mode if pre):"
104+
jq '{ baseBranch: .baseBranch, pre: .pre }' .changeset/config.json || cat .changeset/config.json
105+
fi
106+
else
107+
echo ".changeset missing"
108+
fi
109+
103110
- name: Compute branch tip SHA
104111
id: branch_tip
105112
run: |
@@ -109,6 +116,11 @@ jobs:
109116
echo "Resolved branch tip SHA: $TIP_SHA"
110117
echo "sha=$TIP_SHA" >> "$GITHUB_OUTPUT"
111118
119+
- name: Reset release branch base
120+
run: |
121+
git fetch --no-tags --prune origin
122+
git push origin :changeset-release/${{ github.event.workflow_run.head_branch }} || true
123+
112124
- name: Create Release Pull Request or Publish to npm
113125
id: changesets
114126
uses: changesets/action@v1
@@ -118,11 +130,30 @@ jobs:
118130
publish: pnpm changeset publish --access public
119131
commit: 'chore(release): version packages'
120132
title: 'chore(release): version packages'
133+
commitMode: github
121134
env:
122135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123136
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
124137
GITHUB_SHA: ${{ steps.branch_tip.outputs.sha }}
125138

139+
- name: Post-mortem diagnostics (on failure)
140+
if: failure()
141+
run: |
142+
echo "After changesets/action failure:"
143+
echo "Branch refs:"
144+
git branch -vv || true
145+
echo "HEAD now: $(git rev-parse HEAD)"
146+
git show -s --date=iso --format='%h %ad %s' || true
147+
echo "Workspace root listing:"
148+
ls -la || true
149+
if [ -d .changeset ]; then
150+
echo ".changeset dir exists after failure:" && ls -la .changeset || true
151+
else
152+
echo ".changeset dir missing after failure"
153+
fi
154+
echo "Last 10 reflog entries:"
155+
git reflog --date=iso -n 10 --decorate || true
156+
126157
# - Was lit-auth-server part of the most recent release?
127158
# - Capture published packages
128159
# - Fallback to empty array if nothing was published

0 commit comments

Comments
 (0)