Skip to content

Commit

Permalink
Build a static native image
Browse files Browse the repository at this point in the history
  • Loading branch information
just-sultanov committed Jan 16, 2024
1 parent b52eef5 commit ef6b430
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ jobs:
path: target/xdeps.jar
name: xdeps-${{ steps.xdeps.outputs.version }}.jar


native-image:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: uberjar
Expand Down Expand Up @@ -236,3 +237,89 @@ jobs:
with:
path: target/xdeps
name: xdeps-${{ steps.xdeps.outputs.version }}-${{ matrix.name }}-amd64


native-image-static:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: uberjar
strategy:
matrix:
include:
- os: ubuntu-latest
name: linux
runs-on: ${{ matrix.os }}
steps:

# Git

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# Variables

- name: Setup variables
id: xdeps
run: |
XDEPS_VERSION=$(cat version)
echo "version=${XDEPS_VERSION}" >> $GITHUB_OUTPUT
# Tools

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
java-version: '17'
components: 'native-image'
native-image-musl: true
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install native dev tools
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
sudo apt-get -y install musl
- name: Setup clojure tools
uses: DeLaGuardo/[email protected]
with:
bb: latest
cli: latest
clj-kondo: latest
cljstyle: latest
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Cache deps
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gitlibs
~/.clojure
~/.cpcache
key: ${{ matrix.os}}-deps-${{ hashFiles('deps.edn') }}
restore-keys: ${{ matrix.name }}-deps-

# Native image

- name: Download uberjar
uses: actions/download-artifact@v4
with:
path: target
name: xdeps-${{ steps.xdeps.outputs.version }}.jar
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build native image
run: bb build native-image static

- name: Check artifact
run: ./target/xdeps

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: target/xdeps
name: xdeps-${{ steps.xdeps.outputs.version }}-${{ matrix.name }}-static-amd64

0 comments on commit ef6b430

Please sign in to comment.