From 13e9c3c079b2e169f3e9fcc664de95c2e985318a Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Thu, 20 May 2021 00:37:34 +0200 Subject: [PATCH] Github actions pipeline for consistently building native libraries for all supported architectures --- .github/workflows/cross-compile.yml | 117 ++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/cross-compile.yml diff --git a/.github/workflows/cross-compile.yml b/.github/workflows/cross-compile.yml new file mode 100644 index 000000000..84ad15277 --- /dev/null +++ b/.github/workflows/cross-compile.yml @@ -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 \ No newline at end of file