From 198e6b2b117e4e1d9902ab2eea250070c9d84c78 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Tue, 27 Oct 2026 12:03:15 +0100 Subject: [PATCH 1/2] ci: Check out the release tag by its full ref The release build checked out the pushed tag by its short name, and actions/checkout resolves a short name to a branch before a tag, so a branch named like the tag would be built in its place. Check out refs/tags/, confirm that HEAD is the tagged commit before building, and test ancestry against refs/remotes/origin/main so that a tag named origin/main cannot stand in for the branch. --- .github/workflows/release.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 041284b80..f4a7b8651 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,9 +81,14 @@ jobs: echo "::error::$TAG is not a $CHAIN release tag; expected $CHAIN-release-" exit 1 fi - echo "chain=$CHAIN" >> "$GITHUB_OUTPUT" - echo "tag=$TAG" >> "$GITHUB_OUTPUT" - echo "ref=${TAG:-$GITHUB_REF}" >> "$GITHUB_OUTPUT" + # Fully qualified: checkout prefers a branch over a tag of the same name. + REF="$GITHUB_REF" + if [ -n "$TAG" ]; then REF="refs/tags/$TAG"; fi + { + echo "chain=$CHAIN" + echo "tag=$TAG" + echo "ref=$REF" + } >> "$GITHUB_OUTPUT" - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: @@ -100,8 +105,13 @@ jobs: run: | SHA="$(git rev-parse HEAD)" echo "sha=$SHA" >> "$GITHUB_OUTPUT" + if [ -n "$TAG" ] && [ "$SHA" != "$(git rev-parse "refs/tags/$TAG^{commit}")" ]; then + echo "::error::checked out $SHA, which is not the commit $TAG points at" + exit 1 + fi # Releases are published only for commits on main; a dry run may build any ref. - if [ -n "$TAG" ] && ! git merge-base --is-ancestor "$SHA" origin/main; then + # Fully qualified, so a tag named origin/main cannot stand in for the branch. + if [ -n "$TAG" ] && ! git merge-base --is-ancestor "$SHA" refs/remotes/origin/main; then echo "::error::$TAG points at $SHA, which is not on main; refusing to publish a release for it" exit 1 fi From bb559d9e532b3f6625153d9bcfb7bbb2a4bbc34a Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Tue, 27 Oct 2026 12:03:16 +0100 Subject: [PATCH 2/2] ci: Pin cargo-edit and keep the token out of the version-up checkout Install cargo-edit 0.13.13 with --locked before the checkout, so every run builds the same dependency tree and no repository credentials are on disk while it builds. The checkout no longer persists the token; the step that creates the release branch receives it and creates the branch through the API, like the steps that commit to it. --- .github/workflows/version-up.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index 1dbf76256..ed7c2f7ed 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -34,22 +34,26 @@ jobs: contents: write pull-requests: write steps: + # Install cargo-edit if specific version is NOT provided. Pinned and + # locked so every run builds the same dependency tree, and installed + # before the checkout so its build runs with no repository on disk. + - name: install cargo-edit + if: github.event.inputs.specific_version == '' + run: | + cargo install cargo-edit --locked --version 0.13.13 + - name: Checkout uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 + # The token goes only to the steps that write to the repository. + persist-credentials: false - name: Setup User run: | git config user.name github-actions git config user.email github-actions@github.com - # Install cargo-edit if specific version is NOT provided - - name: install cargo-edit - if: github.event.inputs.specific_version == '' - run: | - cargo install cargo-edit - - name: Check For Specific Version if: github.event.inputs.specific_version != '' env: @@ -107,6 +111,7 @@ jobs: - name: Create Release Branch id: new-branch env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PKG: ${{ steps.set-pkg.outputs.name }} DAY: ${{ steps.date-now.outputs.day }} MONTH: ${{ steps.date-now.outputs.month }} @@ -129,7 +134,7 @@ jobs: echo "name=${branch_name}" >> "$GITHUB_OUTPUT" git checkout -b "${branch_name}" - git push --set-upstream origin "${branch_name}" + gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/${branch_name}" -f sha="$(git rev-parse HEAD)" --silent # todo: make this simpler. - name: Commit New Changes to New Branch (all)