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
16 changes: 16 additions & 0 deletions .github/scripts/pre-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

releases=$1
debug=${2:-}

[[ -n "$debug" ]] && tree

mkdir -p "$releases"
artifacts=(bf-x86_64-apple-darwin bf-x86_64-linux)

for artifact in "${artifacts[@]}"; do
chmod +x "$artifact/bf"
tar cvfz "$releases/$artifact.tar.gz" "$artifact/bf"
done
4 changes: 2 additions & 2 deletions .github/test.sh → .github/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if [ ! -f "$file" ]; then
fi

if [ -n "$input" ]; then
output=$(echo -n "$input" | scala-cli run . -q -- "$(cat "$file")")
output=$(echo -n "$input" | scala-cli run . -q -- "$(< "$file")")
else
output=$(scala-cli run . -q -- "$(cat "$file")")
output=$(scala-cli run . -q -- "$(< "$file")")
fi

if [ "$output" = "$expected" ]; then
Expand Down
67 changes: 66 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,70 @@ jobs:
fi

echo "Running examples/$name.b $input"
.github/test.sh "$name" "$expected" "$input"
.github/scripts/test.sh "$name" "$expected" "$input"
done

build-native:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
include:
- name: MacOS
os: macos-latest
artifact: bf-x86_64-apple-darwin
- name: Ubuntu
os: ubuntu-latest
artifact: bf-x86_64-linux

name: Graal Build
runs-on: ${{ matrix.os }}
needs: [ test, example ]

steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: VirtusLab/scala-cli-setup@main
with:
power: true

- name: Build
run: |
scala-cli --power package . -o ./out/bf --native-image \
--graalvm-java-version 21 \
--graalvm-version 21 \
--graalvm-args "--verbose" \
--graalvm-args "--no-fallback" \
--graalvm-args "--native-image-info" \
--graalvm-args "-H:+ReportExceptionStackTraces" \
--graalvm-args "-H:-UseServiceLoaderFeature"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ./out/bf
if-no-files-found: error
retention-days: 1

release:
name: Release
runs-on: ubuntu-latest
needs: [ test, example, build-native ]
if: "startsWith(github.ref, 'refs/tags/')"

steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4

- name: Prepare release
run: .github/scripts/pre-release.sh releases

- name: Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: releases/*
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ scala-cli test .

You can find example programs in the `examples/` directory and run them using:
```bash
scala-cli run . -- "$(cat path-to-example)"
scala-cli run . -- "$(< path-to-example)"
```
All examples are sourced from [wikipedia.org](https://en.wikipedia.org/wiki/Brainfuck#Examples) and [brainfuck.org](https://brainfuck.org/).

Expand Down
3 changes: 2 additions & 1 deletion project.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//> using scala "3.3.5"
//> using jvm 17
//> using jvm 21

//> using options -deprecation -feature -explain
//> using options -Wunused:imports,implicits,privates -Werror
//> using option -Ykind-projector

Expand Down