Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/release-please-cargo-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Sync Cargo.lock for release-please PRs

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]

permissions:
contents: write

jobs:
lockfile:
# release-please PRs typically have branch names like "release-please--branches--main"
if: startsWith(github.head_ref, 'release-please--')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: Swatinem/rust-cache@v2

- name: Regenerate lockfile
run: cargo generate-lockfile

- name: Commit and push Cargo.lock if changed
run: |
if ! git diff --quiet -- Cargo.lock; then
git config user.name "crosspack-bot[bot]"
git config user.email "crosspack-bot[bot]@users.noreply.github.com"
git add Cargo.lock
git commit -m "chore: sync Cargo.lock"
git push
fi
48 changes: 2 additions & 46 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ concurrency:
jobs:
release-please:
name: release-please
if: "${{ !contains(github.event.head_commit.message, 'chore(lockfile): refresh Cargo.lock for release') }}"
runs-on: ubuntu-latest
steps:
- name: Create GitHub App token
Expand All @@ -32,51 +31,8 @@ jobs:
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Refresh Cargo.lock
run: |
set -euo pipefail
cargo update --workspace

- name: Validate Cargo.lock
run: |
set -euo pipefail
cargo check --workspace --locked

- name: Detect lockfile changes
id: lockfile
run: |
set -euo pipefail
if git diff --quiet -- Cargo.lock; then
echo "lock_changed=false" >> "$GITHUB_OUTPUT"
else
echo "lock_changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Commit refreshed Cargo.lock
if: ${{ steps.lockfile.outputs.lock_changed == 'true' }}
run: |
set -euo pipefail
git config user.name "crosspack-bot"
git config user.email "crosspack-bot@users.noreply.github.com"
git add Cargo.lock
git commit -m "chore(lockfile): refresh Cargo.lock for release"
for attempt in 1 2 3; do
if git push origin HEAD:main; then
exit 0
fi

if [ "$attempt" -eq 3 ]; then
echo "failed to push lockfile refresh commit after retries" >&2
exit 1
fi

git fetch origin main
if ! git rebase origin/main; then
git rebase --abort || true
echo "failed to rebase lockfile refresh commit onto latest main" >&2
exit 1
fi
done
- name: Cache cargo
uses: Swatinem/rust-cache@v2

- name: Run release-please
id: release
Expand Down