fix: script to parse binary digests (#7493)

This commit is contained in:
saisatishkarra 2024-06-05 06:12:05 -05:00 committed by GitHub
parent 79cc2ef3ef
commit f2712204ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 25 deletions

37
.github/scripts/generate-binary-digest.sh vendored Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/bash
# To test locally, set ARTIFACT_PATH="packages" CLI_ARTIFACT_SHAFILE=cli.sha256 ELECTRON_ARTIFACT_SHAFILE=electron.sha256 ./.github/scripts/generate-binary-digest.sh
set -euo pipefail
echo "CLI FILES FOUND"
cli_files=$(find "${ARTIFACT_PATH}" -type f \( -name "inso-*.zip" -o -name "inso-*.pkg" -o -name "inso-*.tar.xz" \) -exec sha256sum {} \;)
echo "${cli_files}"
echo "CLI FILES WITH PATH STRIPPED"
echo "${cli_files}" | sed "s/\(.* \)\(.*\(inso\)\)/\1\\3/" | sort > "${CLI_ARTIFACT_SHAFILE}"
cat "${CLI_ARTIFACT_SHAFILE}"
cli_digest=$(base64 -w0 "${CLI_ARTIFACT_SHAFILE}")
echo "ELECTRON APP FILES FOUND"
app_files=$(find "${ARTIFACT_PATH}" -type f \( -name "Insomnia.Core-*" \) -exec sha256sum {} \;)
echo "${app_files}"
echo "ELECTRON APP FILES WITH PATH STRIPPED"
echo "${app_files}" | sed "s/\(.* \)\(.*\(Insomnia.Core\)\)/\1\\3/" | sort > "${ELECTRON_ARTIFACT_SHAFILE}"
cat "${ELECTRON_ARTIFACT_SHAFILE}"
app_digest=$(base64 -w0 "${ELECTRON_ARTIFACT_SHAFILE}")
if [[ -z "$(cat ${CLI_ARTIFACT_SHAFILE})" ]]; then
echo "CLI Artifacts SHA256 Digest file generation failed"
exit 1
else
echo "CLI FILE DIGEST"
echo "${cli_digest}"
fi
if [[ -z "$(cat ${ELECTRON_ARTIFACT_SHAFILE})" ]]; then
echo "ELECTRON Artifacts SHA256 Digest file generation failed"
exit 1
else
echo "ELECTRON APP FILE DIGEST"
echo "${app_digest}"
fi
echo "inso_binary_artifact_digest_base64=${cli_digest}" >> "$GITHUB_OUTPUT"
echo "electron_binary_artifact_digest_base64=${app_digest}" >> "$GITHUB_OUTPUT"

View File

@ -64,31 +64,11 @@ jobs:
run: |
INSO_VERSION=$(jq .version packages/insomnia-inso/package.json -rj)
echo "INSO_VERSION=${INSO_VERSION}" >> $GITHUB_ENV
ARTIFACT_PATH="${{ env.ARTIFACTS_DOWNLOAD_PATH }}"
# To test set ARTIFACT_PATH to a local path, containing an inso-1.zip and Insomnia.Core-1.zip and paste the next 18 lines in a terminal
echo "CLI FILES FOUND"
cli_files=$(find "${ARTIFACT_PATH}" -type f \( -name "inso-*.zip" -o -name "inso-*.pkg" -o -name "inso-*.tar.xz" \) -exec sha256sum {} \;)
echo "${cli_files}"
echo "CLI FILES WITH PATH STRIPPED"
cli_replaced_files=$(echo "${cli_files}" | sed "s/\(.* \)\(.*\(inso\)\)/\1\\3/" | sort)
echo "${cli_replaced_files}"
echo "CLI FILE DIGEST"
cli_digest=$(echo "${cli_replaced_files}" | base64 -w0)
echo "${cli_digest}"
echo "APP FILES FOUND"
app_files=$(find "${ARTIFACT_PATH}" -type f \( -name "Insomnia.Core-*" \) -exec sha256sum {} \;)
echo "${app_files}"
echo "APP FILES WITH PATH STRIPPED"
app_replaced_files=$(echo "${app_files}" | sed "s/\(.* \)\(.*\(Insomnia.Core\)\)/\1\\3/" | sort)
echo "${app_replaced_files}"
echo "APP FILE DIGEST"
app_digest=$(echo "${app_replaced_files}" | base64 -w0)
echo "${app_digest}"
echo "inso_binary_artifact_digest_base64=${cli_digest}" >> $GITHUB_OUTPUT
echo "electron_binary_artifact_digest_base64=${app_digest}" >> $GITHUB_OUTPUT
./.github/scripts/generate-binary-digest.sh
env:
ARTIFACT_PATH: "${{ env.ARTIFACTS_DOWNLOAD_PATH }}"
CLI_ARTIFACT_SHAFILE: ${{runner.temp}}/cli.sha256
ELECTRON_ARTIFACT_SHAFILE: ${{runner.temp}}/electron.sha256
- name: Temporarily move artifacts
shell: bash

View File

@ -53,6 +53,17 @@ jobs:
- name: Package
shell: bash
run: NODE_OPTIONS='--max_old_space_size=6144' BUILD_TARGETS='${{ matrix.build-targets }}' npm run app-package
# - name: Set publish metadata # Checksum for provenance must be calculated before moving artifacts temporarily
# id: metadata
# run: |
# INSO_VERSION=$(jq .version packages/insomnia-inso/package.json -rj)
# echo "INSO_VERSION=${INSO_VERSION}" >> $GITHUB_ENV
# ./.github/scripts/generate-binary-digest.sh
# env:
# ARTIFACT_PATH: "packages"
# CLI_ARTIFACT_SHAFILE: ${{runner.temp}}/cli.sha256
# ELECTRON_ARTIFACT_SHAFILE: ${{runner.temp}}/electron.sha256
- name: Test critical path on packaged electron app
run: npm run test:package -w packages/insomnia-smoke-test -- --project=Critical