88 version :
99 description : ' Version of Roc to install (e.g., "nightly", "nightly-new-compiler", "alpha4-rolling")'
1010 required : true
11+ token :
12+ description : ' GitHub token used to authenticate API requests (avoids rate limiting). Defaults to the workflow token.'
13+ required : false
14+ default : ${{ github.token }}
1115
1216runs :
1317 using : ' composite'
1822 set -euo pipefail
1923
2024 VERSION="${{ inputs.version }}"
25+ TOKEN="${{ inputs.token }}"
2126 echo "Installing Roc version: $VERSION"
2227
2328 # Detect OS and architecture
2732 echo "Detected OS: $OS"
2833 echo "Detected architecture: $ARCH"
2934
35+ # Archive extension (most platforms ship .tar.gz, Windows ships .zip)
36+ ASSET_EXT="tar.gz"
37+
3038 # Determine platform-specific values
3139 case "$OS" in
3240 Linux)
6573 ;;
6674 esac
6775 ;;
76+ MINGW*|MSYS*|CYGWIN*)
77+ if [[ "$VERSION" != "nightly-new-compiler" ]]; then
78+ echo "Error: Windows is only supported for the 'nightly-new-compiler' version"
79+ exit 1
80+ fi
81+ case "$ARCH" in
82+ x86_64)
83+ PLATFORM="windows_x86_64"
84+ DIR_PATTERN="roc_nightly-windows_x86_64-*"
85+ SHA_CMD="sha256sum"
86+ ASSET_EXT="zip"
87+ ;;
88+ *)
89+ echo "Error: Unsupported Windows architecture: $ARCH"
90+ exit 1
91+ ;;
92+ esac
93+ ;;
6894 *)
6995 echo "Error: Unsupported operating system: $OS"
7096 exit 1
@@ -115,8 +141,12 @@ runs:
115141 # Download Roc
116142 if [[ "$VERSION" == "nightly-new-compiler" ]]; then
117143 # Fetch the latest release from roc-lang/nightlies and find the asset for our platform
118- DOWNLOAD_URL=$(curl -fsSL "https://api.github.com/repos/roc-lang/nightlies/releases/latest" | \
119- jq -r ".assets[] | select(.name | contains(\"${PLATFORM}\")) | select(.name | endswith(\".tar.gz\")) | .browser_download_url")
144+ AUTH_HEADER=()
145+ if [[ -n "$TOKEN" ]]; then
146+ AUTH_HEADER=(-H "Authorization: Bearer $TOKEN")
147+ fi
148+ DOWNLOAD_URL=$(curl -fsSL "${AUTH_HEADER[@]}" "https://api.github.com/repos/roc-lang/nightlies/releases/latest" | \
149+ jq -r ".assets[] | select(.name | contains(\"${PLATFORM}\")) | select(.name | endswith(\".${ASSET_EXT}\")) | .browser_download_url")
120150 if [[ -z "$DOWNLOAD_URL" ]]; then
121151 echo "Error: Could not find a nightly-new-compiler release for platform: $PLATFORM"
122152 exit 1
@@ -133,12 +163,13 @@ runs:
133163 fi
134164
135165 echo "Downloading Roc for $PLATFORM..."
136- curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL"
166+ ARCHIVE="roc.${ASSET_EXT}"
167+ curl -fsSL -o "$ARCHIVE" "$DOWNLOAD_URL"
137168
138169 # Verify SHA256 checksum (skip for nightly releases)
139170 if [[ "$SKIP_SHA_CHECK" == "false" ]]; then
140171 echo "Verifying SHA256 checksum..."
141- ACTUAL_SHA=$($SHA_CMD roc.tar.gz | awk '{print $1}')
172+ ACTUAL_SHA=$($SHA_CMD "$ARCHIVE" | awk '{print $1}')
142173
143174 if [[ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]]; then
144175 echo "Error: SHA256 checksum mismatch!"
@@ -155,8 +186,12 @@ runs:
155186
156187 # Extract Roc
157188 echo "Extracting Roc..."
158- tar -xzf roc.tar.gz
159- rm roc.tar.gz
189+ if [[ "$ASSET_EXT" == "zip" ]]; then
190+ unzip -q "$ARCHIVE"
191+ else
192+ tar -xzf "$ARCHIVE"
193+ fi
194+ rm "$ARCHIVE"
160195
161196 # Find the extracted directory and add to PATH
162197 ROC_DIR=$(find . -maxdepth 1 -type d -name "$DIR_PATTERN" | head -n 1)
0 commit comments