From 34a870e94a5ef1d2da3801409c436b867363fa62 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:21:12 +0200 Subject: [PATCH 1/6] more OS support + test --- .github/workflows/test.yml | 43 +++++++++++++++++++++++ README.md | 22 +++++++----- action.yml | 72 ++++++++++++++++++++++++++++++-------- 3 files changed, 115 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..eccb48e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test Action + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + test: + name: Test on ${{ matrix.os }} ${{ matrix.arch }} + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - os: Linux + arch: x86_64 + runner: ubuntu-latest + - os: Linux + arch: arm64 + runner: ubuntu-24.04-arm64 + - os: macOS + arch: x86_64 + runner: macos-15-intel + - os: macOS + arch: arm64 + runner: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Roc + uses: ./ + + - name: Check Roc version + run: roc version + + - name: Download HelloWorld example + run: curl -fsSL -o main.roc https://raw.githubusercontent.com/roc-lang/examples/main/examples/HelloWorld/main.roc + + - name: Run HelloWorld example + run: roc main.roc diff --git a/README.md b/README.md index ac53aab..3728d3d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Setup Roc -A GitHub Action to download and setup the Roc compiler for Linux x86_64. +A GitHub Action to download and setup the Roc compiler for Linux and macOS. ## Usage @@ -12,16 +12,22 @@ TODO ## Platform Support -This action currently supports: -- **OS**: Linux -- **Architecture**: x86_64 +This action supports the following platforms: + +| OS | Architecture | Status | +|----|--------------|--------| +| Linux | x86_64 | ✅ | +| Linux | arm64 | ✅ | +| macOS | x86_64 (Intel) | ✅ | +| macOS | arm64 (Apple Silicon) | ✅ | ## What it does -1. Downloads the Roc compiler (`roc-linux_x86_64-alpha4-rolling.tar.gz`) from the official releases -2. Verifies the SHA256 checksum to ensure file integrity -3. Extracts the compiler -4. Adds the Roc executable to the PATH +1. Detects your operating system and architecture +2. Downloads the appropriate Roc compiler release for your platform +3. Verifies the SHA256 checksum to ensure file integrity +4. Extracts the compiler +5. Adds the Roc executable to the PATH ## Security diff --git a/action.yml b/action.yml index 6081d27..1a6775e 100644 --- a/action.yml +++ b/action.yml @@ -12,25 +12,69 @@ runs: run: | set -euo pipefail - # Check if running on Linux x86_64 - if [[ "$OSTYPE" != "linux-gnu"* ]]; then - echo "Error: This action currently only supports Linux" - exit 1 - fi + # Detect OS and architecture + OS=$(uname -s) + ARCH=$(uname -m) - if [[ "$(uname -m)" != "x86_64" ]]; then - echo "Error: This action currently only supports x86_64 architecture" - exit 1 - fi + 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" + EXPECTED_SHA="96e8be05e6f7176433ada74532ff36a62b8dc44c5247a82cdf919f2dadc5178b" + DIR_PATTERN="roc_nightly-linux_x86_64-*" + SHA_CMD="sha256sum" + ;; + aarch64|arm64) + PLATFORM="linux_arm64" + EXPECTED_SHA="95558e2b5564b9f2b19fb29ad7df440d4ef7163dea571ffcd39409ef678ecccf" + 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" + EXPECTED_SHA="e8378bdec9fbeaf8f7bae49159a7b43d42050b047375521799984311dcda7078" + DIR_PATTERN="roc_nightly-macos_x86_64-*" + SHA_CMD="shasum -a 256" + ;; + arm64) + PLATFORM="macos_apple_silicon" + EXPECTED_SHA="416fbd983280eda11ac87b0947e27bf0a86d186a94baebeb71e163942bb5bd84" + 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 # Download Roc - echo "Downloading Roc for Linux x86_64..." - curl -fsSL -o roc.tar.gz https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-linux_x86_64-alpha4-rolling.tar.gz + DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-${PLATFORM}-alpha4-rolling.tar.gz" + echo "Downloading Roc for $PLATFORM..." + curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL" # Verify SHA256 checksum echo "Verifying SHA256 checksum..." - EXPECTED_SHA="96e8be05e6f7176433ada74532ff36a62b8dc44c5247a82cdf919f2dadc5178b" - ACTUAL_SHA=$(sha256sum roc.tar.gz | awk '{print $1}') + ACTUAL_SHA=$($SHA_CMD roc.tar.gz | awk '{print $1}') if [[ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]]; then echo "Error: SHA256 checksum mismatch!" @@ -48,7 +92,7 @@ runs: rm roc.tar.gz # Find the extracted directory and add to PATH - ROC_DIR=$(find . -maxdepth 1 -type d -name "roc_nightly-linux_x86_64-*" | head -n 1) + 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 From ddec69275f7f321f7139e2fcc15878faf0f6bc54 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:23:44 +0200 Subject: [PATCH 2/6] simplify trigger --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eccb48e..0381df8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,6 @@ name: Test Action on: pull_request: - branches: [main] - push: - branches: [main] jobs: test: From 82bef17d8bfb329fe60ba786d785265208d12da0 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:26:30 +0200 Subject: [PATCH 3/6] fix runner name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0381df8..7410252 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: runner: ubuntu-latest - os: Linux arch: arm64 - runner: ubuntu-24.04-arm64 + runner: ubuntu-24.04-arm - os: macOS arch: x86_64 runner: macos-15-intel From 1750d73722969709de1d653f879e884d1f28963b Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:28:05 +0200 Subject: [PATCH 4/6] make sure SHA mismatch works --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1a6775e..d14a981 100644 --- a/action.yml +++ b/action.yml @@ -68,7 +68,7 @@ runs: esac # Download Roc - DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-${PLATFORM}-alpha4-rolling.tar.gz" + DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-${PLATFORM}-alpha3-rolling.tar.gz" echo "Downloading Roc for $PLATFORM..." curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL" From 5db721cd657826827395503008f0dfcd39967196 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:32:13 +0200 Subject: [PATCH 5/6] fix alpha3 link --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d14a981..dfab43d 100644 --- a/action.yml +++ b/action.yml @@ -68,7 +68,7 @@ runs: esac # Download Roc - DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-${PLATFORM}-alpha3-rolling.tar.gz" + DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha3-rolling/roc-${PLATFORM}-alpha3-rolling.tar.gz" echo "Downloading Roc for $PLATFORM..." curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL" From 46b11905cd8f1a52a37e9cc71e6fdc14c273e7f4 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:34:00 +0200 Subject: [PATCH 6/6] Back to normal alpha4 links --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index dfab43d..1a6775e 100644 --- a/action.yml +++ b/action.yml @@ -68,7 +68,7 @@ runs: esac # Download Roc - DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha3-rolling/roc-${PLATFORM}-alpha3-rolling.tar.gz" + DOWNLOAD_URL="https://github.com/roc-lang/roc/releases/download/alpha4-rolling/roc-${PLATFORM}-alpha4-rolling.tar.gz" echo "Downloading Roc for $PLATFORM..." curl -fsSL -o roc.tar.gz "$DOWNLOAD_URL"