From 105587386144ba6f1de4dff9c751732752165957 Mon Sep 17 00:00:00 2001 From: principalwater Date: Mon, 17 Aug 2026 20:24:06 +0300 Subject: [PATCH] ci(release): never rebuild an artifact that is already published Re-running the release workflow on an existing tag rebuilt every target and replaced the uploaded tarballs. The build is not byte-reproducible, so the bytes behind an already-published version changed silently: v0.5.11 was re-dispatched to exercise the new tap job and both checksums moved, which the tap job then dutifully committed as a second formula bump. Anyone who had downloaded and pinned the first build would have found the published artifact no longer matching. The build now checks the release for its own target first and skips compiling and uploading when that asset exists, with overwrite_files: false behind it. Re-running becomes what it was assumed to be: a way to re-run the tap job, or to fill in a target whose upload failed, without touching what is already out. Signed-off-by: principalwater --- .github/workflows/release.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80e076d..1ec9547 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,13 +30,37 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ inputs.tag || github.ref_name }} + # A published tarball is what people have already downloaded and checksummed. The build is + # not byte-reproducible, so rebuilding one would silently change the bytes behind a version + # that is already out. Re-running this workflow is useful for the tap job below; it must not + # be a way to rewrite history. + - name: Skip targets already published for this tag + id: published + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ inputs.tag || github.ref_name }} + shell: bash + run: | + set -uo pipefail + version="${TAG#v}" + asset="artesian-${version}-${{ matrix.target }}.tar.gz" + if gh release view "$TAG" --repo "${{ github.repository }}" \ + --json assets --jq '.assets[].name' 2>/dev/null | grep -qx "$asset"; then + echo "$asset is already published; leaving it untouched" + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi - uses: dtolnay/rust-toolchain@stable + if: steps.published.outputs.skip != 'true' with: targets: ${{ matrix.target }} - name: Build the unified binary + if: steps.published.outputs.skip != 'true' # One multi-call binary serves the CLI, the MCP server, and the daemon. run: cargo build --release --locked --target ${{ matrix.target }} -p artesian-cli --features "qdrant,llm,http" - name: Package + checksum + if: steps.published.outputs.skip != 'true' shell: bash run: | tag="${{ inputs.tag || github.ref_name }}" @@ -49,8 +73,11 @@ jobs: tar -czf "${name}.tar.gz" -C "$name" artesian shasum -a 256 "${name}.tar.gz" | tee "${name}.tar.gz.sha256" - uses: softprops/action-gh-release@v2 + if: steps.published.outputs.skip != 'true' with: tag_name: ${{ inputs.tag || github.ref_name }} + # Belt and braces behind the skip above: never replace an asset that is already there. + overwrite_files: false files: | artesian-*.tar.gz artesian-*.tar.gz.sha256