-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·85 lines (64 loc) · 2.56 KB
/
update.sh
File metadata and controls
executable file
·85 lines (64 loc) · 2.56 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -euo pipefail
CHANNELS=("${@:-stable staging dev}")
if [[ $# -eq 0 ]]; then
CHANNELS=(stable staging dev)
fi
SYSTEMS=("x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin")
declare -A PLATFORM_MAP=(
[x86_64-linux]="linux-x64"
[aarch64-linux]="linux-arm64"
[x86_64-darwin]="osx-x64"
[aarch64-darwin]="osx-arm64"
)
resolve_url() {
local channel="$1" platform="$2"
case "$channel" in
stable) echo "https://aka.ms/dotnet/9/aspire/ga/daily/aspire-cli-${platform}.tar.gz" ;;
staging) echo "https://aka.ms/dotnet/9/aspire/rc/daily/aspire-cli-${platform}.tar.gz" ;;
dev) echo "https://aka.ms/dotnet/9/aspire/daily/aspire-cli-${platform}.tar.gz" ;;
*) echo "Unknown channel: $channel" >&2; exit 1 ;;
esac
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSIONS_FILE="$SCRIPT_DIR/versions.nix"
# Build the new versions.nix content
output="{\n"
for channel in "${CHANNELS[@]}"; do
echo "=== Updating $channel channel ==="
# Resolve version from the first platform (linux-x64)
redirect_url=$(resolve_url "$channel" "linux-x64")
echo "Resolving latest version from $channel channel..."
tarball_url=$(curl -sL -o /dev/null -w '%{url_effective}\n' "$redirect_url")
version=$(echo "$tarball_url" | sed -n 's#^.*/public/aspire/\([^/]*\)/.*#\1#p')
if [[ -z "$version" ]]; then
echo "Failed to resolve version for $channel" >&2
exit 1
fi
echo "Found version: $version"
# Extract fileVersion from the tarball filename
file_version=$(basename "$tarball_url" .tar.gz | sed 's/^aspire-cli-linux-x64-//' | sed 's/^aspire-cli-linux-x64$//')
file_version="${file_version:-$version}"
current_version=$(sed -n "/^ $channel = {/,/};/{s/.*version = \"\([^\"]*\)\".*/\1/p;}" "$VERSIONS_FILE")
if [[ "$version" == "$current_version" ]]; then
echo "$channel is already up to date."
fi
output+=" $channel = {\n"
output+=" version = \"$version\";\n"
output+=" fileVersion = \"$file_version\";\n"
output+=" hashes = {\n"
for sys in "${SYSTEMS[@]}"; do
platform="${PLATFORM_MAP[$sys]}"
url="https://ci.dot.net/public/aspire/${version}/aspire-cli-${platform}-${file_version}.tar.gz"
echo " Fetching hash for $sys ($platform)..."
hash=$(nix-prefetch-url --type sha512 "$url" 2>/dev/null | xargs nix hash convert --hash-algo sha512 --to sri)
echo " $hash"
output+=" $sys = \"$hash\";\n"
done
output+=" };\n"
output+=" };\n"
echo "Updated $channel to version $version"
done
output+="}\n"
echo -e "$output" > "$VERSIONS_FILE"
echo "Done."