Skip to content

Commit f0e9048

Browse files
committed
ci: add native image build and release workflow
1 parent 9dcd738 commit f0e9048

File tree

5 files changed

+87
-5
lines changed

5 files changed

+87
-5
lines changed

.github/scripts/pre-release.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
releases=$1
6+
debug=${2:-}
7+
8+
[[ -n "$debug" ]] && tree
9+
10+
mkdir -p "$releases"
11+
artifacts=(bf-x86_64-apple-darwin bf-x86_64-linux)
12+
13+
for artifact in "${artifacts[@]}"; do
14+
chmod +x "$artifact/bf"
15+
tar cvfz "$releases/$artifact.tar.gz" "$artifact/bf"
16+
done

.github/test.sh renamed to .github/scripts/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ if [ ! -f "$file" ]; then
1212
fi
1313

1414
if [ -n "$input" ]; then
15-
output=$(echo -n "$input" | scala-cli run . -q -- "$(cat "$file")")
15+
output=$(echo -n "$input" | scala-cli run . -q -- "$(< "$file")")
1616
else
17-
output=$(scala-cli run . -q -- "$(cat "$file")")
17+
output=$(scala-cli run . -q -- "$(< "$file")")
1818
fi
1919

2020
if [ "$output" = "$expected" ]; then

.github/workflows/ci.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,70 @@ jobs:
6161
fi
6262
6363
echo "Running examples/$name.b $input"
64-
.github/test.sh "$name" "$expected" "$input"
64+
.github/scripts/test.sh "$name" "$expected" "$input"
6565
done
66+
67+
build-native:
68+
strategy:
69+
matrix:
70+
os: [ macos-latest, ubuntu-latest ]
71+
include:
72+
- name: MacOS
73+
os: macos-latest
74+
artifact: bf-x86_64-apple-darwin
75+
- name: Ubuntu
76+
os: ubuntu-latest
77+
artifact: bf-x86_64-linux
78+
79+
name: Graal Build
80+
runs-on: ${{ matrix.os }}
81+
needs: [ test, example ]
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: coursier/cache-action@v6
86+
- uses: VirtusLab/scala-cli-setup@main
87+
with:
88+
power: true
89+
90+
- name: Build
91+
run: |
92+
scala-cli --power package . -o ./out/bf --native-image \
93+
--graalvm-java-version 21 \
94+
--graalvm-version 21 \
95+
--graalvm-args "--verbose" \
96+
--graalvm-args "--no-fallback" \
97+
--graalvm-args "--native-image-info" \
98+
--graalvm-args "-H:+ReportExceptionStackTraces" \
99+
--graalvm-args "-H:-UseServiceLoaderFeature"
100+
101+
- name: Upload artifacts
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: ${{ matrix.artifact }}
105+
path: ./out/bf
106+
if-no-files-found: error
107+
retention-days: 1
108+
109+
release:
110+
name: Release
111+
runs-on: ubuntu-latest
112+
needs: [ test, example, build-native ]
113+
if: "startsWith(github.ref, 'refs/tags/')"
114+
115+
steps:
116+
- uses: actions/checkout@v4
117+
118+
- name: Download artifacts
119+
uses: actions/download-artifact@v4
120+
121+
- name: Prepare release
122+
run: .github/scripts/pre-release.sh releases
123+
124+
- name: Release
125+
uses: softprops/action-gh-release@v2
126+
with:
127+
generate_release_notes: true
128+
fail_on_unmatched_files: true
129+
files: releases/*
130+
token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ scala-cli test .
1818

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

project.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//> using scala "3.3.5"
2-
//> using jvm 17
2+
//> using jvm 21
33

4+
//> using options -deprecation -feature -explain
45
//> using options -Wunused:imports,implicits,privates -Werror
56
//> using option -Ykind-projector
67

0 commit comments

Comments
 (0)