Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: script to parse binary digests #7493

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/scripts/generate-binary-digest.sh
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 5 additions & 25 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release-recurring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading