Skip to content

Commit c88b223

Browse files
committed
ci(release-please): sync uv.lock after version bump
release-please bumps `version` in `pyproject.toml` but doesn't touch `uv.lock`. Since `uv.lock` records the project version, `uv sync --locked` then fails on every CI job for the release PR with: The lockfile at uv.lock needs to be updated, but --locked was provided. To update the lockfile, run uv lock. Reproduced locally: bumping pyproject from 1.13.0 to 2.0.0 makes uv sync --locked fail; uv lock alone re-sync's the descope entry and CI passes again. Add a sync-uv-lock job that runs after release-please-action when a release PR was opened/updated. It checks out the PR branch using the same GitHub App token, runs uv lock, and pushes the resulting uv.lock change back to the PR branch (only if changed). The push uses the App token so PR CI is re-triggered with the fixed lock. If release-please regenerates the PR later (new commits on main), the workflow re-runs and re-applies the lock fix on top.
1 parent f539bb9 commit c88b223

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
outputs:
1616
release_created: ${{ steps.release.outputs.release_created }}
1717
tag_name: ${{ steps.release.outputs.tag_name }}
18+
pr_branch: ${{ steps.pr_info.outputs.branch }}
1819
steps:
1920
- name: Generate GitHub App Token
2021
id: app-token
@@ -30,6 +31,61 @@ jobs:
3031
config-file: release-please-config.json
3132
manifest-file: .release-please-manifest.json
3233

34+
- name: Extract release-please PR branch
35+
id: pr_info
36+
if: ${{ steps.release.outputs.pr }}
37+
env:
38+
PR_JSON: ${{ steps.release.outputs.pr }}
39+
run: |
40+
branch="$(echo "$PR_JSON" | jq -r '.headBranchName')"
41+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
42+
43+
sync-uv-lock:
44+
needs: release-please
45+
if: ${{ needs.release-please.outputs.pr_branch != '' }}
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
steps:
50+
- name: Generate GitHub App Token
51+
id: app-token
52+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
53+
with:
54+
app-id: ${{ secrets.RELEASE_APP_ID }}
55+
private-key: ${{ secrets.RELEASE_APP_PEM }}
56+
57+
- name: Checkout release-please PR branch
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
with:
60+
ref: ${{ needs.release-please.outputs.pr_branch }}
61+
token: ${{ steps.app-token.outputs.token }}
62+
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
65+
with:
66+
enable-cache: true
67+
python-version: "3.13"
68+
69+
- name: Sync uv.lock with bumped version
70+
run: uv lock
71+
72+
- name: Commit and push if changed
73+
env:
74+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
75+
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
76+
PR_BRANCH: ${{ needs.release-please.outputs.pr_branch }}
77+
run: |
78+
if git diff --quiet uv.lock; then
79+
echo "uv.lock already in sync; nothing to do."
80+
exit 0
81+
fi
82+
APP_USER_ID="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
83+
git config user.name "${APP_SLUG}[bot]"
84+
git config user.email "${APP_USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
85+
git add uv.lock
86+
git commit -m "chore: sync uv.lock with release version"
87+
git push origin "HEAD:${PR_BRANCH}"
88+
3389
publish:
3490
needs: release-please
3591
if: ${{ needs.release-please.outputs.release_created == 'true' }}

0 commit comments

Comments
 (0)