Skip to content

Commit 2b14f3d

Browse files
committed
build: Calculate checksums after the nix fixup phase
crossplane/crossplane#7467 reported that checksums for the amd64 crank binaries in our releases are incorrect. It turns out this applies to both the CLI (now the crossplane binary from this repository) and the core crossplane controller binary (the crossplane binary in c/c). The issue is that Nix strips binaries in its `fixup` build phase, which runs after our `postInstall` hook. The stripping applies only to binaries for the host architecture, which in our release actions is always amd64. Calculate checksums in the `postFixup` phase so that we checksum the already stripped binary. Add a checksum verification step before uploading artifacts to catch any similar issues in the future. Signed-off-by: Adam Wolfe Gordon <awg@upbound.io>
1 parent 6f65d73 commit 2b14f3d

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ jobs:
160160
- name: Build Artifacts
161161
run: nix build .#release --option warn-dirty false --print-build-logs
162162

163+
- name: Validate Artifacts
164+
run: |
165+
for f in $(find result/ -type f -not -name '*.sha256'); do
166+
want=$(sha256sum "${f}" | head -c 64)
167+
got=$(cat "${f}.sha256")
168+
if [[ "${want}" != "${got}" ]]; then
169+
echo "File ${f} has incorrect checksum; want ${want}, got ${got}"
170+
exit 1
171+
fi
172+
done
173+
163174
- name: Upload Artifacts
164175
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
165176
with:

nix/build.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ let
4545
mv $out/bin/${platform.os}_${platform.arch}/* $out/bin/
4646
rmdir $out/bin/${platform.os}_${platform.arch}
4747
fi
48+
'';
49+
50+
postFixup = ''
4851
cd $out/bin
4952
sha256sum ${pname}${ext} | head -c 64 > ${pname}${ext}.sha256
5053
'';

0 commit comments

Comments
 (0)