Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
ROC_NIGHTLY_VERSION: 2025-10-31-8553832

# Do not add permissions here! Configure them at the job level!
permissions: {}
Expand Down Expand Up @@ -36,3 +38,180 @@ jobs:
- run: |
cd website
roc check build_website.roc

test-install-script-unix:
strategy:
matrix:
include:
- os: ubuntu-24.04
platform: linux
arch: x86_64
- os: ubuntu-24.04-arm
platform: linux
arch: arm64
- os: macos-15
platform: macos
arch: apple_silicon
- os: macos-15-intel
platform: macos
arch: x86_64
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- name: Test install script (answer no to PATH)
run: |
cd website/content/installnew/install_scripts
bash install_roc.sh <<< "n"

- name: Verify installation (no PATH)
run: |
cd website/content/installnew/install_scripts
DIR_NAME="roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
if [ ! -d "$DIR_NAME" ]; then
echo "Error: Installation directory $DIR_NAME not found"
exit 1
fi

- name: Test roc binary (no PATH)
run: |
cd website/content/installnew/install_scripts
DIR_NAME="roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
"$DIR_NAME/roc" version

- name: Clean up for second test
run: |
cd website/content/installnew/install_scripts
rm -rf roc_nightly-*

- name: Test install script (answer yes to PATH)
run: |
cd website/content/installnew/install_scripts
bash install_roc.sh <<< "y"

- name: Verify PATH was updated
run: |
# Detect shell profile based on SHELL
if [ -n "${SHELL:-}" ]; then
case "$SHELL" in
*/bash) PROFILE="$HOME/.bashrc" ;;
*/zsh) PROFILE="$HOME/.zshrc" ;;
*/fish) PROFILE="$HOME/.config/fish/config.fish" ;;
*) PROFILE="$HOME/.profile" ;;
esac
else
PROFILE="$HOME/.profile"
fi

if ! grep -q "roc_nightly-${{ matrix.platform }}_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}" "$PROFILE"; then
echo "Error: PATH not updated in $PROFILE"
exit 1
fi
echo "✅ PATH successfully updated in $PROFILE"

test-install-script-windows:
strategy:
matrix:
include:
- os: windows-2022
arch: x86_64
proc_arch: AMD64
- os: windows-2025
arch: x86_64
proc_arch: AMD64
- os: windows-11-arm
arch: arm64
proc_arch: ARM64

runs-on: ${{ matrix.os }}
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Test install script (answer no to PATH)
shell: pwsh
env:
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
run: |
Set-Location website\content\installnew\install_scripts
"n" | pwsh -ExecutionPolicy Bypass -File .\install_roc.ps1

- name: Verify installation (no PATH)
shell: pwsh
run: |
Set-Location website\content\installnew\install_scripts
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
if (-not (Test-Path $dirName)) {
Write-Error "❌ Installation directory $dirName not found"
} else {
Write-Host "✅ Found $dirName"
}

- name: Test roc binary (no PATH) – x86_64 only
if: ${{ matrix.arch == 'x86_64' }}
shell: pwsh
run: |
Set-Location website\content\installnew\install_scripts
$dirName = "roc_nightly-windows_x86_64-${{ env.ROC_NIGHTLY_VERSION }}"
$rocPath = Join-Path $dirName "roc.exe"
if (-not (Test-Path $rocPath)) {
Write-Host "❌ roc.exe not found at $rocPath"
Write-Host "Contents of ${dirName}:"
Get-ChildItem $dirName -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $_" }
exit 1
} else {
Write-Host "Running roc.exe version..."
& $rocPath version
}

- name: Clean up for second test
shell: pwsh
run: |
Set-Location website\content\installnew\install_scripts
Get-Item .\roc_nightly-* -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force
Write-Host "🧹 Cleaned up previous installation directories"

- name: Test install script (answer yes to PATH)
shell: pwsh
env:
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
run: |
Set-Location website\content\installnew\install_scripts
"y" | pwsh -ExecutionPolicy Bypass -File .\install_roc.ps1

- name: Verify PATH was updated
shell: pwsh
env:
PROCESSOR_ARCHITECTURE: ${{ matrix.proc_arch }}
run: |
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"

# The script uses SetEnvironmentVariable("Path", "User")
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")

if ([string]::IsNullOrEmpty($userPath)) {
Write-Error "❌ User PATH is empty or not readable"
exit 1
}

if ($userPath -notlike "*$dirName*") {
Write-Error "❌ PATH not updated with $dirName"
exit 1
} else {
Write-Host "✅ PATH successfully updated with $dirName"
}

- name: Test roc binary (after PATH update)
shell: pwsh
run: |
$dirName = "roc_nightly-windows_${{ matrix.arch }}-${{ env.ROC_NIGHTLY_VERSION }}"
$rocPath = Join-Path $PWD "website\content\installnew\install_scripts\$dirName\roc.exe"

# Pull the updated user PATH and merge into current session
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$env:PATH = "$userPath;$env:PATH"

Write-Host "Running roc.exe version..."
roc.exe version
2 changes: 1 addition & 1 deletion website/content/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ If you are looking for more resources to learn about Roc, check out the followin
- [Roc Examples](/examples)
- [Roc Guides](/docs#guides)
- [Roc Language Reference](/docs#language-reference)
- [Roc Exercism Track](https://exercism.org/tracks/roc)
- [Roc Exercism Track](https://exercism.org/tracks/roc)
14 changes: 14 additions & 0 deletions website/content/installnew/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Install

<div class="banner">
Roc is a <b>Work in Progress!</b>
</div>

<!-- TODO detect current OS with browser and show that one first -->
<!-- TODO docker release -->
- [Linux or macOS](/installnew/unix)
- [Windows](/installnew/windows)
- [Other Systems](/installnew/other)

<!-- TODO mention editor plugins once they are up to date -->

117 changes: 117 additions & 0 deletions website/content/installnew/install_scripts/install_roc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Roc Nightly Installer for Windows
# Downloads, verifies, extracts, and (optionally) adds Roc to the user PATH.
# Based on your 2025-10-31 nightly.

$ErrorActionPreference = "Stop"

# ---- Configuration ----
$VersionDate = "2025-10-31"
$BuildId = "8553832"
$BaseUrl = "https://github.com/roc-lang/nightlies/releases/download/nightly-2025-October-31-$BuildId"

# Known SHA256 checksums for Windows
$Sha_Windows_x86_64 = "1d37d0262ec272cca1c7a32acb23b7c02115cc94a11e721bf50ddb352943f332"
$Sha_Windows_arm64 = "6c148e8e362c9a594446145481f872d5777a02d6c47d3320f92377be5b9a60d6"

# ---- Detect architecture ----
$arch = $env:PROCESSOR_ARCHITECTURE
switch ($arch.ToLower()) {
"amd64" { $ArchName = "x86_64" }
"arm64" { $ArchName = "arm64" }
default { throw "Unsupported architecture: $arch" }
}

$Platform = "windows"

# ---- Pick the right file ----
# You gave us the exact filenames, so we can just branch:
if ($ArchName -eq "x86_64") {
$File = "roc_nightly-windows_x86_64-$VersionDate-$BuildId.zip"
$ExpectedSha = $Sha_Windows_x86_64
} elseif ($ArchName -eq "arm64") {
$File = "roc_nightly-windows_arm64-$VersionDate-$BuildId.zip"
$ExpectedSha = $Sha_Windows_arm64
} else {
throw "No Windows artifact for architecture $ArchName"
}

$Url = "$BaseUrl/$File"

Write-Host "➡️ Step 1: Downloading Roc for $Platform ($ArchName)..."
$downloadPath = Join-Path $PWD $File

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $Url -OutFile $downloadPath -UseBasicParsing
Write-Host "✅ Download complete: $downloadPath"
Write-Host ""

# ---- Verify SHA256 ----
Write-Host "🔒 Step 2: Checking file integrity..."
$actualHash = (Get-FileHash -Algorithm SHA256 -Path $downloadPath).Hash.ToLower()
if ($actualHash -ne $ExpectedSha.ToLower()) {
Write-Host "❌ Checksum mismatch!"
Write-Host "Expected: $ExpectedSha"
Write-Host "Actual: $actualHash"
throw "The file might be corrupted. Aborting."
} else {
Write-Host "✅ File verified successfully!"
Write-Host ""
}

# ---- Extract ----
Write-Host "📦 Step 3: Extracting files..."

$installDirName = "roc_nightly-$Platform`_$ArchName-$VersionDate-$BuildId"
$installDir = Join-Path $PWD $installDirName

Expand-Archive -Path $downloadPath -DestinationPath $PWD -Force

Write-Host "✅ Roc was extracted to: $installDir"
Write-Host ""

Write-Host @"
⭐ Step 4: Making Roc easy to run

Right now, Roc is installed in:
$installDir

You can add that folder to your Windows user PATH so you can run `roc`
from any new PowerShell or CMD window.
"@

$folderToAdd = $installDir

# ---- Ask to add to PATH ----
$answer = Read-Host "Would you like me to add Roc to your *user* PATH automatically? [y/N]"
if ($answer -match '^(y|Y)$') {
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", "User")

$pathParts = @()
if ($currentPath) {
$pathParts = $currentPath.Split(";") | Where-Object { $_ -ne "" }
}

if ($pathParts -contains $folderToAdd) {
Write-Host "ℹ️ PATH already contains $folderToAdd"
} else {
$newPath = if ($currentPath) { "$currentPath;$folderToAdd" } else { $folderToAdd }
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host "✅ Added Roc to your user PATH."
Write-Host " (Open a new terminal for it to take effect.)"
}

Write-Host ""
Write-Host "🎉 All done!"
Write-Host "Open a new PowerShell and run: roc version"
} else {
Write-Host ""
Write-Host "ℹ️ No problem!"
Write-Host "To run Roc in *this* PowerShell session, run:"
Write-Host ""
Write-Host " `$env:PATH += `";$folderToAdd`""
Write-Host ""
Write-Host "Then:"
Write-Host " roc version"
Write-Host ""
Write-Host "🎉 All done!"
}
Loading