Skip to content

Commit

Permalink
Github actions pipeline for consistently building native libraries fo…
Browse files Browse the repository at this point in the history
…r all supported architectures
  • Loading branch information
pietrygamat committed Aug 4, 2021
1 parent 6a61983 commit 13e9c3c
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Cross-compile native libraries
on: workflow_dispatch

env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
GITHUB_BOT_NAME: github-actions
GITHUB_BOT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com

jobs:
create-branch:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: echo "precompiled_branch=$(git branch --show-current)-precompiled-natives" >> $GITHUB_ENV
- run: echo "rev=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Create branch for precompiled natives
run: git checkout -b ${{ env.precompiled_branch }} && git push --force origin HEAD
outputs:
precompiled_branch: ${{ env.precompiled_branch }}
base_rev: ${{ env.rev }}

compile-natives:
runs-on: ${{ matrix.os }}
needs: create-branch
strategy:
matrix:
include:
- target: linux_32
os: ubuntu-20.04
profile: 'x86'
packages: 'cmake g++-multilib'

- target: linux_64
os: ubuntu-20.04
profile: 'x86_64'
packages: 'cmake g++'

- target: linux_arm
os: ubuntu-20.04
profile: 'armhf'
packages: 'cmake g++-arm-linux-gnueabihf'

- target: linux_arm64
os: ubuntu-20.04
profile: 'aarch64'
packages: 'cmake g++-aarch64-linux-gnu'

- target: linux_ppc
os: ubuntu-20.04
profile: 'ppc64'
packages: 'cmake g++-powerpc64le-linux-gnu'

- target: windows_32
os: ubuntu-20.04
profile: 'mingw32'
packages: 'cmake g++-mingw-w64-i686'

- target: windows_64
os: ubuntu-20.04
profile: 'mingw64'
packages: 'cmake g++-mingw-w64-x86-64'

- target: windows_arm64
os: ubuntu-20.04
profile: 'mingwaarch64'
packages: 'cmake clang'

- target: osx_64
os: macos-10.15
profile: 'x86_64'

- target: osx_arm64
os: macos-10.15
profile: 'aarch64'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup APT packages
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: sudo apt-get install --yes ${{ matrix.packages }}
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Build with Maven
run: mvn -B clean install -P ${{ matrix.profile }}
- run: git config --global user.email "${GITHUB_BOT_EMAIL}"
- run: git config --global user.name "${GITHUB_BOT_NAME}"
- run: git fetch && git checkout -t origin/${{ needs.create-branch.outputs.precompiled_branch }}
- run: git add src/main/resources-precompiled/**
- run: git commit --allow-empty -m "Precompiled natives (@${{ needs.create-branch.outputs.base_rev }}) for ${{ matrix.target }}"
- name: Push recompiled binary for ${{ matrix.profile }}
run: 'while git pull --rebase && ! git push; do sleep 5; done'

compile-natives-solaris:
runs-on: macos-latest
needs: create-branch
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build on solaris
uses: vmactions/solaris-vm@v0.0.3
with:
envs: 'MAVEN_OPTS GITHUB_BOT_EMAIL GITHUB_BOT_NAME'
run: |
wget -qO- https://download.bell-sw.com/java/11.0.12+7/bellsoft-jdk11.0.12+7-solaris-x64-lite.tar.gz | tar xvf -
wget -qO- https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz | gunzip - | tar xvf -
pkg install gcc git cmake
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.1/bin/mvn -B clean install -P x86 -DskipTests
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.1/bin/mvn -B clean install -P x86_64 -DskipTests
git config --global user.email "${GITHUB_BOT_EMAIL}"
git config --global user.name "${GITHUB_BOT_NAME}"
git fetch && git checkout -t origin/${{ needs.create-branch.outputs.precompiled_branch }}
git add src/main/resources-precompiled/**
git commit --allow-empty -m "Precompiled natives (@${{ needs.create-branch.outputs.base_rev }}) for Solaris"
while git pull --rebase && ! git push; do sleep 5; done

0 comments on commit 13e9c3c

Please sign in to comment.