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
20 changes: 4 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- run: scala-cli compile .

build-linux:
if: github.event_name == 'push'
if: github.event_name == 'push' || github.event_name == 'pull_request'
needs: compile
strategy:
matrix:
Expand All @@ -30,16 +30,7 @@ jobs:

- name: Build in Alpine container
run: |
docker run --rm -v "$PWD":/work -w /work alpine:latest sh -c '
apk add --no-cache bash curl clang lld musl-dev openjdk17-jre-headless &&
curl -fLo /usr/local/bin/coursier https://github.com/coursier/launchers/raw/master/coursier.jar &&
chmod +x /usr/local/bin/coursier &&
coursier launch scala-cli -- --power package . -o comport -f \
--native-mode release-fast \
--native-lto thin \
--native-gc commix \
--native-linking "-static"
'
./build-with-container.sh

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -48,7 +39,7 @@ jobs:
path: comport

build-macos:
if: github.event_name == 'push'
if: github.event_name == 'push' || github.event_name == 'pull_request'
needs: compile
strategy:
matrix:
Expand All @@ -64,10 +55,7 @@ jobs:

- name: Build native binary
run: |
scala-cli --power package . -o comport -f \
--native-mode release-fast \
--native-lto full \
--native-gc commix
./build.sh

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:latest

# libc++-dev is for exception handling
RUN apk add --no-cache bash curl clang libc++-dev alpine-sdk lld musl-dev openjdk17-jre-headless
RUN curl -fLo /usr/local/bin/coursier https://github.com/coursier/launchers/raw/master/coursier.jar && chmod +x /usr/local/bin/coursier
RUN coursier launch scala-cli
ENV PATH="$PATH:/root/.local/share/coursier/bin"
WORKDIR /work
7 changes: 7 additions & 0 deletions build-with-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

set -eux
set pipefail

docker build -t comport-builder .
docker run --rm -v "$PWD":/work --rm -e SCALA_CLI_LAUNCH='coursier launch scala-cli --' -e LINKFLAGS=-static comport-builder:latest sh /work/build.sh
16 changes: 16 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Build script using scala-cli. Overwrites `./comport` if exists.

set -eux
set pipefail

LINKFLAGS=${LINKFLAGS:-}
COURSIER=${COURSIER:-cs}
SCALA_CLI_LAUNCH=${SCALA_CLI_LAUNCH:-scala-cli}

${SCALA_CLI_LAUNCH} --power package . -o comport -f \
--native-mode release-fast \
--native-lto full \
--native-gc commix \
--native-linking "${LINKFLAGS}"
2 changes: 1 addition & 1 deletion comport.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using platform native
//> using scala 3.3
//> using scala 3.8.2
//> using options -no-indent -rewrite
//> using dep com.lihaoyi::mainargs::0.7.8
//> using dep com.lihaoyi::os-lib::0.11.8
Expand Down
Loading