@@ -54,8 +54,11 @@ has_tools() {
5454}
5555
5656normalize_arch () {
57- local arch=" $1 "
58- [[ $arch == " x86_64" ]] && echo " amd64" || echo " $arch "
57+ case " $1 " in
58+ x86_64) echo " amd64" ;;
59+ aarch64) echo " arm64" ;;
60+ * ) echo " $1 " ;;
61+ esac
5962}
6063
6164get_os () {
@@ -70,6 +73,10 @@ get_binary_name() {
7073 echo " ${BIN_NAME} _${1} _${2} _${3} " # version, os, arch
7174}
7275
76+ get_archive_name () {
77+ echo " ${BIN_NAME} _${1} _${2} _${3} .tar.gz" # version, os, arch
78+ }
79+
7380# ==============================================================================
7481# GitHub API Functions
7582# ==============================================================================
@@ -192,44 +199,70 @@ main() {
192199 has_tools " ${REQUIRED_TOOLS[@]} "
193200
194201 # Fetch release information
195- local release_json
202+ local release_json archive_name
196203 release_json=$( fetch_latest_release)
197204 version=$( extract_version " $release_json " )
198- binary_name =$( get_binary_name " $version " " $os " " $arch " )
199-
205+ archive_name =$( get_archive_name " $version " " $os " " $arch " )
206+
200207 msg " Platform: $os /$arch "
201208 msg " Version: $version "
202-
203- # Download and verify binary
209+
210+ # Download archive and checksums
204211 temp_dir=$( mktemp -d)
205212 trap " rm -rf $temp_dir " EXIT
206213
207- # Extract asset URLs from release JSON (handles both public and private repos)
208- local binary_url checksum_url
209- binary_url=$( extract_asset_url " $release_json " " $binary_name " )
214+ local archive_url checksum_url
215+ archive_url=$( extract_asset_url " $release_json " " $archive_name " )
210216 checksum_url=$( extract_asset_url " $release_json " " $CHECKSUMS_FILE " )
211217
212- download_release_asset " $binary_url " " ${temp_dir} /${binary_name } " " $binary_name "
218+ download_release_asset " $archive_url " " ${temp_dir} /${archive_name } " " $archive_name "
213219 download_release_asset " $checksum_url " " ${temp_dir} /checksums.txt" " checksums"
214-
215- # Verify checksum
220+
221+ # Verify archive checksum
216222 msg " Verifying checksum..."
217- (cd " $temp_dir " && grep " $binary_name " checksums.txt | shasum -a 256 --check --strict) \
223+ (cd " $temp_dir " && grep " $archive_name " checksums.txt | shasum -a 256 --check --strict) \
218224 || err " Checksum verification failed"
219-
220- # Install binary
221- chmod +x " ${temp_dir} /${binary_name} "
225+
226+ # Extract archive
227+ msg " Extracting archive..."
228+ tar -xzf " ${temp_dir} /${archive_name} " -C " $temp_dir "
229+
230+ # Optional: verify attestation if cosign is available
231+ if command -v cosign & > /dev/null && [[ -f " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" ]]; then
232+ msg " Verifying attestation with cosign..."
233+ if cosign verify-blob-attestation \
234+ --bundle " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" \
235+ --type https://slsa.dev/provenance/v1 \
236+ --certificate-oidc-issuer https://token.actions.githubusercontent.com \
237+ --certificate-identity-regexp ' https://github.com/NVIDIA/aicr/.github/workflows/on-tag\.yaml@refs/tags/.*' \
238+ " ${temp_dir} /${BIN_NAME} " 2> /dev/null; then
239+ msg " Attestation verified: binary built by github.com/NVIDIA/aicr"
240+ else
241+ msg " Warning: attestation verification failed — cannot confirm this binary was built by the official CI pipeline"
242+ fi
243+ elif [[ -f " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" ]]; then
244+ msg " Tip: install cosign to verify binary attestation (https://docs.sigstore.dev/cosign/system_config/installation/)"
245+ fi
246+
247+ # Install binary and attestation
248+ chmod +x " ${temp_dir} /${BIN_NAME} "
222249 msg " Installing $BIN_NAME to $INSTALL_DIR "
223250 mkdir -p " $INSTALL_DIR "
224251 if [[ -w " $INSTALL_DIR " ]]; then
225- mv " ${temp_dir} /${binary_name} " " ${INSTALL_DIR} /${BIN_NAME} "
252+ mv " ${temp_dir} /${BIN_NAME} " " ${INSTALL_DIR} /${BIN_NAME} "
253+ [[ -f " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" ]] && \
254+ mv " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" " ${INSTALL_DIR} /${BIN_NAME} -attestation.sigstore.json"
226255 else
227- sudo mv " ${temp_dir} /${binary_name} " " ${INSTALL_DIR} /${BIN_NAME} "
256+ sudo mv " ${temp_dir} /${BIN_NAME} " " ${INSTALL_DIR} /${BIN_NAME} "
257+ [[ -f " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" ]] && \
258+ sudo mv " ${temp_dir} /${BIN_NAME} -attestation.sigstore.json" " ${INSTALL_DIR} /${BIN_NAME} -attestation.sigstore.json"
228259 fi
229-
260+
230261 # Verify installation
231262 msg " $BIN_NAME installed successfully!"
232263 " ${BIN_NAME} " --version
264+ [[ -f " ${INSTALL_DIR} /${BIN_NAME} -attestation.sigstore.json" ]] && \
265+ msg " Attestation: ${INSTALL_DIR} /${BIN_NAME} -attestation.sigstore.json"
233266}
234267
235268# Run main function
0 commit comments