Skip to content

Commit bd311e2

Browse files
authored
Add windows support (#6)
* windows support + misc improvements * add token to prevent http 403
1 parent 83d3e8f commit bd311e2

2 files changed

Lines changed: 58 additions & 7 deletions

File tree

.github/workflows/test.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,26 @@ jobs:
7474
arch: arm64
7575
runner: macos-latest
7676
version: nightly-new-compiler
77+
- os: macOS
78+
arch: x86_64
79+
runner: macos-26-intel
80+
version: nightly-new-compiler
81+
- os: macOS
82+
arch: arm64
83+
runner: macos-26
84+
version: nightly-new-compiler
85+
- os: Windows
86+
arch: x86_64
87+
runner: windows-2022
88+
version: nightly-new-compiler
89+
- os: Windows
90+
arch: x86_64
91+
runner: windows-2025
92+
version: nightly-new-compiler
7793

7894
steps:
7995
- name: Checkout repository
80-
uses: actions/checkout@v4
96+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
8197

8298
- name: Setup Roc
8399
uses: ./

action.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
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

1216
runs:
1317
using: 'composite'
@@ -18,6 +22,7 @@ runs:
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
@@ -27,6 +32,9 @@ runs:
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)
@@ -65,6 +73,24 @@ runs:
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

Comments
 (0)