Repository navigation
Expand file tree
/
Copy pathsnapshot-bundled-in-process-version.sh
More file actions
executable file
·58 lines (51 loc) · 1.84 KB
/
Copy pathsnapshot-bundled-in-process-version.sh
File metadata and controls
executable file
·58 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#
# Snapshot the Copilot CLI version + per-platform release hashes for the
# rust crate's bundled-in-process build path.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RUST_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
REPO_ROOT="$(cd "${RUST_DIR}/.." && pwd)"
PACKAGE_FILE="${REPO_ROOT}/nodejs/package.json"
OUTPUT="${RUST_DIR}/cli-version-in-process.txt"
if [[ ! -f "${PACKAGE_FILE}" ]]; then
echo "error: ${PACKAGE_FILE} not found" >&2
exit 1
fi
VERSION="$(node -e "console.log(require('${PACKAGE_FILE}').copilotCliVersion)")"
if [[ -z "${VERSION}" ]]; then
echo "error: could not read copilotCliVersion from ${PACKAGE_FILE}" >&2
exit 1
fi
CHECKSUMS_URL="https://github.com/github/copilot-cli/releases/download/v${VERSION}/SHA256SUMS.txt"
SHA256SUMS="$(curl --fail --silent --show-error --location --retry 3 "${CHECKSUMS_URL}")"
PACKAGES=(
"copilot-darwin-arm64"
"copilot-darwin-x64"
"copilot-linux-arm64"
"copilot-linux-x64"
"copilot-linuxmusl-arm64"
"copilot-linuxmusl-x64"
"copilot-win32-arm64"
"copilot-win32-x64"
)
TEMP_OUTPUT="${OUTPUT}.tmp.$$"
trap 'rm -f "${TEMP_OUTPUT}"' EXIT
{
echo "# Auto-generated by rust/scripts/snapshot-bundled-in-process-version.sh"
echo "# Do not edit. Regenerated by the publish workflow on every release."
echo "version=${VERSION}"
for package in "${PACKAGES[@]}"; do
platform="${package#copilot-}"
asset="github-copilot-${VERSION}-${platform}.tgz"
hash="$(printf '%s\n' "${SHA256SUMS}" | awk -v asset="${asset}" '$2 == asset || $2 == "*" asset { print $1; exit }')"
if [[ -z "${hash}" ]]; then
echo "error: SHA256SUMS.txt does not contain ${asset}" >&2
exit 1
fi
echo "${package}=${hash}"
done
} > "${TEMP_OUTPUT}"
mv "${TEMP_OUTPUT}" "${OUTPUT}"
trap - EXIT
echo "Wrote ${OUTPUT} (version=${VERSION}, ${#PACKAGES[@]} hashes)"