Skip to content

Commit dddb54c

Browse files
authored
Fix release commit step in template (#31)
Skip the version commit when pyproject.toml already has the release version, and authenticate the push since checkout doesn't persist credentials.
1 parent 65cb118 commit dddb54c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎template/.github/workflows/release.yml‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@ jobs:
4242
id: commit
4343
env:
4444
TAG: ${{ steps.drafter.outputs.tag_name }}
45+
GH_TOKEN: ${{ github.token }}
4546
run: |
46-
git config user.name "github-actions[bot]"
47-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
48-
git add pyproject.toml uv.lock
49-
git commit -m "Release $TAG"
50-
git push origin main
47+
# Skip the commit when pyproject.toml already has the release version
48+
if ! git diff --quiet -- pyproject.toml uv.lock; then
49+
git config user.name "github-actions[bot]"
50+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
51+
git add pyproject.toml uv.lock
52+
git commit -m "Release $TAG"
53+
# Checkout doesn't persist credentials, so authenticate the push explicitly
54+
git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:main
55+
fi
5156
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
5257
5358
- name: Publish release

0 commit comments

Comments
 (0)