-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathsnapshot-bundled-cli-version.sh
More file actions
executable file
·52 lines (47 loc) · 1.6 KB
/
Copy pathsnapshot-bundled-cli-version.sh
File metadata and controls
executable file
·52 lines (47 loc) · 1.6 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
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Snapshot the Copilot CLI version + per-platform SHA-256 hashes for the
# rust crate's bundled-CLI build.rs. Runs at SDK publish time, mirroring
# how .NET's _GenerateVersionProps BeforeTargets="Pack" target writes
# GitHub.Copilot.SDK.props before NuGet packing.
#
# Input:
# - ../nodejs/package.json - pinned release version.
# - The release's SHA256SUMS.txt - per-platform hashes.
#
# Output:
# - cli-version.txt (in the rust crate root). Gitignored.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RUST_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
REPO_ROOT="$(cd "${RUST_DIR}/.." && pwd)"
OUTPUT="${RUST_DIR}/cli-version.txt"
source "${SCRIPT_DIR}/snapshot-release.sh" "$@"
ASSETS=(
"copilot-darwin-arm64.tar.gz"
"copilot-darwin-x64.tar.gz"
"copilot-linux-arm64.tar.gz"
"copilot-linux-x64.tar.gz"
"copilot-linuxmusl-arm64.tar.gz"
"copilot-linuxmusl-x64.tar.gz"
"copilot-win32-arm64.zip"
"copilot-win32-x64.zip"
)
TEMP_OUTPUT="${OUTPUT}.tmp.$$"
trap 'rm -f "${TEMP_OUTPUT}"' EXIT
{
echo "# Auto-generated by rust/scripts/snapshot-bundled-cli-version.sh"
echo "# Do not edit. Regenerated by the publish workflow on every release."
echo "version=${VERSION}"
if [[ "${RELEASE_URL}" != "${DEFAULT_RELEASE_URL}" ]]; then
echo "release-url=${RELEASE_URL}"
fi
for asset in "${ASSETS[@]}"; do
hash="$(snapshot_hash "${asset}")"
echo "${asset}=${hash}"
done
} > "${TEMP_OUTPUT}"
mv "${TEMP_OUTPUT}" "${OUTPUT}"
trap - EXIT
echo "Wrote ${OUTPUT} (version=${VERSION}, ${#ASSETS[@]} hashes)"