-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ci(release): auto-sync core/wren lock after wren-core-py publish #2431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ttw225
wants to merge
5
commits into
Canner:main
Choose a base branch
from
ttw225:chore/auto-sync-wren-core-py-lock
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6686034
ci(release): auto-sync core/wren lock after wren-core-py publish
ttw225 862a285
ci(release): add manual trigger to the wren-core-py lock sync
ttw225 1a96eda
ci(release): harden the wren-core-py lock sync workflow
ttw225 df887b9
ci(release): add a stable concurrency group
ttw225 e6aa148
ci(release): drop persisted credentials in the lock sync
ttw225 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| name: Sync core/wren lock after wren-core-py release | ||
|
|
||
| # After wren-core-py publishes to PyPI, core/wren still pins the old engine in | ||
| # its pyproject floor and uv.lock (release-please extra-files only touch a | ||
| # component's own dir). Relock core/wren against the release and open a PR. | ||
| # Called after publish-wren-core-py succeeds, so a failed publish is never bumped. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| description: "Released wren-core-py version (e.g. 0.7.1)" | ||
| required: true | ||
| type: string | ||
| # Manual fallback: re-run the sync if the automatic run after publish failed | ||
| # or was skipped. Leave version blank to use the release tracked in the repo. | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "wren-core-py version to sync to; blank = .release-please-manifest.json" | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| # Serialize sync runs so two can't push the same branch at once. Constant key | ||
| # (not per-version) because a blank-dispatch version is only known at run time. | ||
| concurrency: | ||
| group: sync-wren-core-py-lock | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| sync-lock: | ||
| if: ${{ github.repository == 'Canner/WrenAI' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout main | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # publish takes minutes; main may have moved. Base the PR on main tip. | ||
| ref: main | ||
| # Keep the write token out of .git/config so dependency code uv may | ||
| # build during resolution can't read it (supply-chain); push re-auths. | ||
| persist-credentials: false | ||
|
|
||
| - name: Resolve and validate version | ||
| env: | ||
| INPUT_VERSION: ${{ inputs.version }} | ||
| run: | | ||
| # workflow_call always passes the released version; manual runs may | ||
| # omit it and fall back to the release tracked in the repo. | ||
| version="${INPUT_VERSION:-$(jq -r '."core/wren-core-py"' .release-please-manifest.json)}" | ||
| # Guard a malformed version out of the dep edit, branch name, and PR. | ||
| if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$ ]]; then | ||
| echo "::error::Unsupported version: ${version}. Expected X.Y.Z or X.Y.ZrcN." | ||
| exit 1 | ||
| fi | ||
| echo "Syncing core/wren to wren-core-py ${version}" | ||
| echo "VERSION=${version}" >> "$GITHUB_ENV" | ||
|
|
||
| - uses: astral-sh/setup-uv@v4 | ||
|
|
||
| - name: Bump floor and relock core/wren against published wren-core-py | ||
| working-directory: core/wren | ||
| run: | | ||
| # uv add rewrites the pyproject floor in place and relocks in one step; | ||
| # --no-sync skips the heavy env. Retry for PyPI index lag after publish. | ||
| for attempt in 1 2 3 4 5; do | ||
| if uv add --no-sync "wren-core-py>=${VERSION}"; then | ||
| exit 0 | ||
| fi | ||
| if [ "${attempt}" -lt 5 ]; then | ||
| echo "uv add attempt ${attempt} failed; retrying after PyPI propagation delay" | ||
| sleep 20 | ||
| fi | ||
| done | ||
| echo "::error::uv add did not succeed after retries" | ||
| exit 1 | ||
|
|
||
| - name: Validate lockfile is consistent | ||
| working-directory: core/wren | ||
| run: uv lock --check | ||
|
|
||
| - name: Detect changes | ||
| id: diff | ||
| run: | | ||
| if git diff --quiet -- core/wren/pyproject.toml core/wren/uv.lock; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Open sync PR | ||
| if: steps.diff.outputs.changed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| BRANCH="chore/sync-wren-core-py-${VERSION}" | ||
| # If a PR is already open for this bump, leave it untouched. | ||
| if [ "$(gh pr list --repo "${GITHUB_REPOSITORY}" --state open --head "${BRANCH}" --json number --jq 'length')" != "0" ]; then | ||
| echo "Open PR for ${BRANCH} already exists; leaving it untouched." | ||
| exit 0 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "${BRANCH}" | ||
| git add core/wren/pyproject.toml core/wren/uv.lock | ||
| git commit -m "chore(wren): bump wren-core-py to ${VERSION}" | ||
| # No open PR: --force only overwrites a leftover branch from a closed PR. | ||
| # Auth the push explicitly since credentials aren't persisted (masked in logs). | ||
| git push --force \ | ||
| "https://x-access-token:${GH_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" \ | ||
| "${BRANCH}" | ||
| gh pr create \ | ||
| --repo "${GITHUB_REPOSITORY}" \ | ||
| --base main \ | ||
| --head "${BRANCH}" \ | ||
| --title "chore(wren): bump wren-core-py to ${VERSION}" \ | ||
| --body "Automated follow-up after \`wren-core-py\` ${VERSION} was published to PyPI. Relocks \`core/wren\` against the new engine binding. Please review and merge." | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.