-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
170 lines (154 loc) · 6.18 KB
/
action.yml
File metadata and controls
170 lines (154 loc) · 6.18 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: 'Setup Roc'
description: 'Download and setup the Roc compiler.'
branding:
icon: 'download'
color: 'purple'
inputs:
version:
description: 'Version of Roc to install (e.g., "nightly", "nightly-new-compiler", "alpha4-rolling")'
required: true
runs:
using: 'composite'
steps:
- name: Download and verify Roc
shell: bash
run: |
set -euo pipefail
VERSION="${{ inputs.version }}"
echo "Installing Roc version: $VERSION"
# Detect OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
echo "Detected OS: $OS"
echo "Detected architecture: $ARCH"
# Determine platform-specific values
case "$OS" in
Linux)
case "$ARCH" in
x86_64)
PLATFORM="linux_x86_64"
DIR_PATTERN="roc_nightly-linux_x86_64-*"
SHA_CMD="sha256sum"
;;
aarch64|arm64)
PLATFORM="linux_arm64"
DIR_PATTERN="roc_nightly-linux_arm64-*"
SHA_CMD="sha256sum"
;;
*)
echo "Error: Unsupported Linux architecture: $ARCH"
exit 1
;;
esac
;;
Darwin)
case "$ARCH" in
x86_64)
PLATFORM="macos_x86_64"
DIR_PATTERN="roc_nightly-macos_x86_64-*"
SHA_CMD="shasum -a 256"
;;
arm64)
PLATFORM="macos_apple_silicon"
DIR_PATTERN="roc_nightly-macos_apple_silicon-*"
SHA_CMD="shasum -a 256"
;;
*)
echo "Error: Unsupported macOS architecture: $ARCH"
exit 1
;;
esac
;;
*)
echo "Error: Unsupported operating system: $OS"
exit 1
;;
esac
# Set expected SHA256 based on version and platform
case "$VERSION-$PLATFORM" in
alpha3-rolling-linux_x86_64)
EXPECTED_SHA="c96045f1f54dc3d9e20c33ede8698d79b01e43f09652795beb4f0bc7fb38cba8"
;;
alpha3-rolling-linux_arm64)
EXPECTED_SHA="3eaf492e5e11d39a1c5a549005589405c40902fc0bed517acf8e8a18d190a409"
;;
alpha3-rolling-macos_x86_64)
EXPECTED_SHA="205c70d1f6f6f46c2c681350a68cd91886bdb7a24fd09646f3ba5c2b1e1e1379"
;;
alpha3-rolling-macos_apple_silicon)
EXPECTED_SHA="ef64605d0be3296ad25e34b2d6841ed506ded6208565cbd4289bc81c9dbd3c9d"
;;
alpha4-rolling-linux_x86_64)
EXPECTED_SHA="96e8be05e6f7176433ada74532ff36a62b8dc44c5247a82cdf919f2dadc5178b"
;;
alpha4-rolling-linux_arm64)
EXPECTED_SHA="95558e2b5564b9f2b19fb29ad7df440d4ef7163dea571ffcd39409ef678ecccf"
;;
alpha4-rolling-macos_x86_64)
EXPECTED_SHA="e8378bdec9fbeaf8f7bae49159a7b43d42050b047375521799984311dcda7078"
;;
alpha4-rolling-macos_apple_silicon)
EXPECTED_SHA="416fbd983280eda11ac87b0947e27bf0a86d186a94baebeb71e163942bb5bd84"
;;
nightly-new-compiler-*)
# New compiler nightly builds - no SHA verification
;;
nightly-*)
# Nightly builds - no SHA verification
;;
*)
echo "Error: Unsupported version: $VERSION"
echo "Supported versions: nightly, nightly-new-compiler, alpha3-rolling, alpha4-rolling"
echo "Make sure your version is listed in https://github.com/roc-lang/roc/tags and try updating to"
echo "the latest commit of the setup-roc action, see <https://github.com/roc-lang/setup-roc>."
exit 1
;;
esac
# Download Roc
if [[ "$VERSION" == "nightly-new-compiler" ]]; then
# Fetch the latest release from roc-lang/nightlies and find the asset for our platform
DOWNLOAD_URL=$(curl -fsSL "https://api.github.com/repos/roc-lang/nightlies/releases/latest" | \
jq -r ".assets[] | select(.name | contains(\"${PLATFORM}\")) | select(.name | endswith(\".tar.gz\")) | .browser_download_url")
if [[ -z "$DOWNLOAD_URL" ]]; then
echo "Error: Could not find a nightly-new-compiler release for platform: $PLATFORM"
exit 1
fi
SKIP_SHA_CHECK=true
DIR_PATTERN="roc_nightly-${PLATFORM}-*"
elif [[ "$VERSION" == "nightly" ]]; then
DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-${PLATFORM}-latest.tar.gz"
SKIP_SHA_CHECK=true
DIR_PATTERN="roc_nightly-${PLATFORM}-*"
else
DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/${VERSION}/roc-${PLATFORM}-${VERSION}.tar.gz"
SKIP_SHA_CHECK=false
fi
echo "Downloading Roc for $PLATFORM..."
curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL"
# Verify SHA256 checksum (skip for nightly releases)
if [[ "$SKIP_SHA_CHECK" == "false" ]]; then
echo "Verifying SHA256 checksum..."
ACTUAL_SHA=$($SHA_CMD roc.tar.gz | awk '{print $1}')
if [[ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]]; then
echo "Error: SHA256 checksum mismatch!"
echo "Expected: $EXPECTED_SHA"
echo "Actual: $ACTUAL_SHA"
echo "This should never happen and could mean the file is malicious. Please make a post on <https://roc.zulipchat.com> and request investigation of this incident."
exit 1
fi
echo "SHA256 checksum verified successfully"
else
echo "Skipping SHA256 verification for nightly release"
fi
# Extract Roc
echo "Extracting Roc..."
tar -xzf roc.tar.gz
rm roc.tar.gz
# Find the extracted directory and add to PATH
ROC_DIR=$(find . -maxdepth 1 -type d -name "$DIR_PATTERN" | head -n 1)
if [[ -z "$ROC_DIR" ]]; then
echo "Error: Could not find extracted Roc directory"
exit 1
fi
echo "$GITHUB_WORKSPACE/$ROC_DIR" >> $GITHUB_PATH
echo "Roc setup completed successfully"