Skip to content

Commit 7cf6d8b

Browse files
committed
ci: auto-commit version bumps and publish directly to npm
Replace changesets/action PR workflow with direct version bump commits to master and npm publish. Skips CI on version bump commits to avoid redundant workflow runs.
1 parent e51fca5 commit 7cf6d8b

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,40 @@ jobs:
8686
echo "Generated $CHANGESET_FILE for:$CHANGED_PACKAGES"
8787
cat "$CHANGESET_FILE"
8888
89+
- name: Version packages
90+
run: |
91+
CHANGESETS=$(find .changeset -name '*.md' ! -name 'README.md' | head -1)
92+
if [ -z "$CHANGESETS" ]; then
93+
echo "No changesets found, skipping"
94+
echo "HAS_CHANGES=false" >> "$GITHUB_ENV"
95+
exit 0
96+
fi
97+
98+
pnpm changeset version
99+
echo "HAS_CHANGES=true" >> "$GITHUB_ENV"
100+
101+
- name: Commit version bump
102+
if: env.HAS_CHANGES == 'true'
103+
run: |
104+
git config user.name "github-actions[bot]"
105+
git config user.email "github-actions[bot]@users.noreply.github.com"
106+
git add -A
107+
git commit -m "chore: version packages [skip ci]"
108+
git push
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
89112
- name: Creating .npmrc
113+
if: env.HAS_CHANGES == 'true'
90114
run: |
91115
cat << EOF > "$HOME/.npmrc"
92116
//registry.npmjs.org/:_authToken=$NPM_TOKEN
93117
EOF
94118
env:
95119
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
96120

97-
- name: Create Release Pull Request or Publish
98-
id: changesets
99-
uses: changesets/action@v1
100-
with:
101-
version: pnpm changeset version
102-
publish: pnpm release
103-
title: 'chore: version packages'
104-
commit: 'chore: version packages'
121+
- name: Publish to npm
122+
if: env.HAS_CHANGES == 'true'
123+
run: pnpm release
105124
env:
106-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107125
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)