Skip to content

Commit 1da7991

Browse files
authored
fix: Update release.yml (#202)
Now trying a previous version that explicitly handled the detection/creation/deletion of dist branch. The subtlety here is very difficult to comprehend.
1 parent f81c3ca commit 1da7991

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,32 @@ jobs:
5151
with:
5252
node-version: '22.x'
5353

54-
- name: Fetch Main
55-
run: git fetch origin main:main # Fetch main branch
56-
57-
- name: Copy main to dist (excluding dist directory)
58-
run: |
59-
git checkout main -- . # Checkout all files from main
60-
rm -rf dist # Remove existing dist directory (if any)
61-
6254
- run: npm i
6355
- run: npm run build-all
64-
65-
- name: Commit and Push Changes (to dist)
56+
57+
- name: Check if the dist branch exists remotely
58+
run: |
59+
if git ls-remote --exit-code --heads origin dist; then
60+
# Delete the dist branch locally if it exists
61+
if git show-ref --verify --quiet refs/heads/dist; then
62+
git branch -D dist
63+
fi
64+
# Delete the dist branch remotely
65+
git push origin --delete dist
66+
fi
67+
68+
- name: Checkout and create dist branch from main
69+
run: git checkout -b dist main
70+
71+
- name: Add and commit changes to the dist folder
6672
run: |
6773
git add dist
68-
git commit -m "Update dist folder"
69-
git push --force origin dist
74+
if [[ -n $(git status --porcelain) ]]; then
75+
git commit -m "Update dist folder"
76+
git push origin dist
77+
else
78+
echo "No changes to commit"
79+
fi
7080
7181
- uses: google-github-actions/auth@v1
7282
with:

0 commit comments

Comments
 (0)