Use GitHub Action to build M1 (aarch64) binary #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Native Image | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
native-image: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: macOS-latest | |
uploaded_filename: sbtn-x86_64-apple-darwin | |
local_path: client/target/bin/sbtn | |
jobtype: 1 | |
- os: macos-13-xlarge | |
uploaded_filename: sbtn-aarch64-apple-darwin | |
local_path: client/target/bin/sbtn | |
jobtype: 1 | |
- os: ubuntu-20.04 | |
uploaded_filename: sbtn-x86_64-pc-linux | |
local_path: client/target/bin/sbtn | |
jobtype: 1 | |
- os: ubuntu-20.04 | |
uploaded_filename: sbtn-aarch64-pc-linux | |
local_path: client/target/bin/sbtn | |
jobtype: 2 | |
- os: windows-2019 | |
uploaded_filename: sbtn-x86_64-pc-win32.exe | |
local_path: client\target\bin\sbtn.exe | |
jobtype: 1 | |
env: | |
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M | |
steps: | |
- name: Checkout sbt/sbt | |
uses: actions/checkout@v3 | |
with: | |
repository: sbt/sbt | |
ref: 1.9.x | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 8 | |
- run: git fetch --tags || true | |
- name: Setup Windows C++ toolchain | |
uses: ilammy/msvc-dev-cmd@v1 | |
if: ${{ matrix.os == 'windows-2019' }} | |
- name: Build | |
if: ${{ matrix.uploaded_filename != 'sbtn-aarch64-pc-linux' }} | |
shell: bash | |
run: | | |
echo $(pwd) | |
sbt clean nativeImage | |
- name: Build Linux aarch64 | |
if: ${{ matrix.uploaded_filename == 'sbtn-aarch64-pc-linux' }} | |
uses: uraimo/[email protected] | |
with: | |
arch: aarch64 | |
distro: ubuntu20.04 | |
# Speeds up builds per the run-on-arch-action README | |
githubToken: ${{ github.token }} | |
# The shell to run commands with in the container | |
shell: /bin/bash | |
# build-essential and libz-dev are required to build native images. | |
install: | | |
apt-get update -q -y | |
apt-get install -q -y curl openjdk-8-jdk build-essential libz-dev | |
# Does not work, see https://github.com/sbt/sbt/issues/6614 | |
#echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list | |
#curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add | |
#apt-get update -q && apt-get install -q -y sbt | |
# Workaround: | |
curl -Ls https://scala.jfrog.io/artifactory/debian/sbt-1.8.0.deb -o sbt-1.8.0.deb | |
apt install -y ./sbt-1.8.0.deb | |
run: | | |
sbt clean nativeImage | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ${{ matrix.local_path }} | |
name: ${{ matrix.uploaded_filename }} | |
- name: Upload release | |
if: github.event_name == 'release' | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ matrix.local_path }} | |
asset_name: ${{ matrix.uploaded_filename }} | |
asset_content_type: application/zip |