From 3d4a1fc314cb94c542e48ad00dbbe5f690fbffe1 Mon Sep 17 00:00:00 2001 From: Dennis Paler Date: Fri, 27 Nov 2026 10:49:37 +0800 Subject: [PATCH] ci(release): refuse a tag that does not match the committed version build-binaries compiles from the committed Cargo.toml version, and the publish job only rewrites package.json files from the tag. Tagging v0.4.0 on a tree still at 0.3.3 would therefore publish npm 0.4.0 packages whose binaries report 0.3.3 (daemon /api version, runs.version, MCP serverInfo, user agent, banners). v0.3.0-v0.3.3 avoided this with a manual bump commit, but nothing enforced it. - quality: fail first unless the tag equals both Cargo.toml's workspace version and npm/tailflow/package.json's version. - Build, clippy and test with --locked, as ci.yml already does. - Attach SHA256SUMS covering every tarball and .exe on the GitHub Release. Checked locally: the guard passes for v0.3.3 and fails for v0.4.0 and an empty tag on the current tree; actionlint is clean. --- .github/workflows/release.yml | 41 ++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8c5b1b..5058de2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,21 @@ jobs: steps: - uses: actions/checkout@v4 + # The binaries are built from the committed Cargo.toml version; the + # publish job only rewrites package.json files. A tag pushed without + # the version-bump commit would ship packages whose binaries report the + # previous version. Fail here, before anything is built or published. + - name: Tag matches the committed version + run: | + TAG="${GITHUB_REF_NAME#v}" + CARGO="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)" + NPM="$(node -p "require('./npm/tailflow/package.json').version")" + echo "tag=$TAG Cargo.toml=$CARGO npm/tailflow=$NPM" + if [ -z "$TAG" ] || [ "$TAG" != "$CARGO" ] || [ "$TAG" != "$NPM" ]; then + echo "::error::tag v$TAG does not match Cargo.toml ($CARGO) and npm/tailflow/package.json ($NPM). Land the version-bump commit (node scripts/bump-version.js $TAG) before tagging." + exit 1 + fi + - name: Create web/dist placeholder run: mkdir -p web/dist && touch web/dist/.gitkeep @@ -30,10 +45,10 @@ jobs: run: cargo fmt --all -- --check - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings + run: cargo clippy --all-targets --all-features --locked -- -D warnings - name: Tests - run: cargo test --all + run: cargo test --all --locked - uses: actions/setup-node@v4 with: @@ -125,7 +140,7 @@ jobs: - name: Build (native) if: "!matrix.cross" run: > - cargo build --release + cargo build --release --locked --target ${{ matrix.target }} -p tailflow-tui -p tailflow-daemon @@ -134,7 +149,7 @@ jobs: - name: Build (cross) if: matrix.cross run: > - cross build --release + cross build --release --locked --target ${{ matrix.target }} -p tailflow-tui -p tailflow-daemon @@ -302,6 +317,15 @@ jobs: name: tarball-linux-arm64 path: dist/ + # One checksum file for every binary attached to the release, so a + # download can be verified (`sha256sum -c SHA256SUMS`). + - name: Checksums + run: | + cp npm/platforms/win32-x64/bin/*.exe dist/ + cd dist + sha256sum -- *.tar.gz *.exe > SHA256SUMS + cat SHA256SUMS + # Create a GitHub Release with the tag as the title - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -312,7 +336,8 @@ jobs: dist/tailflow-darwin-x64.tar.gz dist/tailflow-linux-arm64.tar.gz dist/tailflow-linux-x64.tar.gz - npm/platforms/win32-x64/bin/tailflow.exe - npm/platforms/win32-x64/bin/tailflow-daemon.exe - npm/platforms/win32-x64/bin/tailflow-mcp.exe - npm/platforms/win32-x64/bin/tailflow-logs.exe + dist/tailflow.exe + dist/tailflow-daemon.exe + dist/tailflow-mcp.exe + dist/tailflow-logs.exe + dist/SHA256SUMS