diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fb50f530636..e041e2e84d1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -57,9 +57,10 @@ updates: cooldown: default-days: 7 - # Dependabot edits rs/workspace-hack/Cargo.toml's pins by hand, so its PRs - # (security fixes included) can fail `cargo hakari generate --diff` in the - # merge queue. The land fixer then regenerates the hack and re-enqueues them. + # Dependabot edits rs/workspace-hack/Cargo.toml's pins by hand and leaves + # nix/Cargo.nix stale, so its PRs (security fixes included) can fail + # `cargo hakari generate --diff` and `just rs cargo-nix --check` in the merge + # queue. The land fixer then regenerates both and re-enqueues them. - package-ecosystem: "cargo" directory: "/" schedule: diff --git a/.github/workflows/release-rs.yml b/.github/workflows/release-rs.yml index 2b394e1b682..462fb742460 100644 --- a/.github/workflows/release-rs.yml +++ b/.github/workflows/release-rs.yml @@ -88,3 +88,31 @@ jobs: env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + # release-plz bumps Cargo.lock and the manifests without regenerating + # nix/Cargo.nix, which Check then fails as stale, so commit it on top. + # The app token's push, unlike GITHUB_TOKEN's, triggers Check. Authoring + # as moq-bot, as release-plz does, keeps its next run force-pushing this + # PR instead of closing it to preserve a contributor's commit. + - name: Regenerate the release PR's nix/Cargo.nix + env: + GH_TOKEN: ${{ steps.generate-token.outputs.token }} + GIT_AUTHOR_NAME: moq-bot[bot] + GIT_AUTHOR_EMAIL: 186640430+moq-bot[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: moq-bot[bot] + GIT_COMMITTER_EMAIL: 186640430+moq-bot[bot]@users.noreply.github.com + run: | + branch=$(gh pr list --base release --state open --json headRefName --jq '.[].headRefName | select(startswith("release-plz-"))') + if [ -z "$branch" ]; then + echo "No open release PR." + exit 0 + fi + git fetch --no-tags origin "refs/heads/$branch" + git checkout --detach FETCH_HEAD + nix develop --command just rs cargo-nix + if git diff --quiet -- nix; then + echo "nix/Cargo.nix is current." + exit 0 + fi + git commit --message "chore: regenerate nix/Cargo.nix" -- nix + git push origin "HEAD:refs/heads/$branch"