deeplearning4j/deeplearning4j

View on GitHub
.github/workflows/build-deploy-android-x86.yml

Summary

Maintainability
Test Coverage
on:
  workflow_dispatch:
    inputs:
      buildThreads:
        description: 'Build threads for libnd4j. Used to control memory usage of builds.'
        required: true
        default: 2

      deployToReleaseStaging:
        description: 'Whether to deploy to release staging or not.'
        required: false
        default: 0

      releaseVersion:
        description: 'Release version target'
        required: false
        default: 1.0.0-M3

      snapshotVersion:
        description: 'Snapshot version target'
        required: false
        default: 1.0.0-SNAPSHOT

      releaseRepoId:
        description: 'Release repository id'
        required: false
        default:

      serverId:
        description: 'Server id to publish to'
        required: false
        default: ossrh

      mvnFlags:
        description: "Extra maven flags (must escape input yourself if used)"
        required: false
        default:

      libnd4jUrl:
        description: 'Sets a libnd4j download url for this build. LIBND4J_HOME will automatically be set. Should be used when only needing to build other modules.'
        required: false
        default:

      runsOn:
        description: 'System to run on'
        required: false
        default: ubuntu-20.04

      debug_enabled:
        description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
        required: false
        default: false

jobs:
   android-x86:
    runs-on: ${{ github.event.inputs.runsOn }}
    steps:
      - uses: AutoModality/action-clean@v1
      - name: Cancel Previous Runs
        uses: styfle/cancel-workflow-action@0.8.0
        with:
          access_token: ${{ github.token }}
      - uses: actions/checkout@v2
      - uses: ./.github/actions/set-linux-distro-version
      - uses: ./.github/actions/update-deps-linux
      - name: Cache cmake install
        uses: actions/cache@v2
        id: cache-cmake
        with:
          path: /opt/cmake
          key: ${{ runner.os }}-cmake
          restore-keys: ${{ runner.os }}-cmake
      - name: Cache protobuf install
        uses: actions/cache@v2
        id: cache-protobuf
        with:
          path: /opt/protobuf
          key: ${{ runner.os }}-protobuf
          restore-keys: ${{ runner.os }}-protobuf
      - uses: ./.github/actions/install-protobuf-linux
        if: steps.cache-protobuf.outputs.cache-hit != 'true'
      - uses: ./.github/actions/install-cmake-linux
        if: steps.cache-cmake.outputs.cache-hit != 'true'
      - name: Set up Java for publishing to OSSRH
        uses: actions/setup-java@v2
        with:
          java-version: 11
          distribution: 'temurin'
          server-id:  ${{ github.event.inputs.serverId }}
          server-username: MAVEN_USERNAME
          server-password: MAVEN_PASSWORD
          gpg-private-key: ${{ secrets.SONATYPE_GPG_KEY }}
          gpg-passphrase:  MAVEN_GPG_PASSPHRASE
          cache: 'maven'

      - uses: nttld/setup-ndk@v1
        id: setup-ndk
        with:
          ndk-version: r21d
      - name: Setup libnd4j home if a download url is specified
        shell: bash
        run: |
              mkdir "${GITHUB_WORKSPACE}/openblas_home"
              cd "${GITHUB_WORKSPACE}/openblas_home"
              wget https://repo1.maven.org/maven2/org/bytedeco/openblas/0.3.19-1.5.7/openblas-0.3.19-1.5.7-android-x86.jar
              unzip openblas-0.3.19-1.5.7-android-x86.jar
              cd ..
              echo "OPENBLAS_PATH=${GITHUB_WORKSPACE}/openblas_home/lib/x86" >> "$GITHUB_ENV"
              cp ${GITHUB_WORKSPACE}/openblas_home/lib/x86/libopenblas.so.0  ${GITHUB_WORKSPACE}/openblas_home/lib/x86/libopenblas.so

        if: ${{ github.event.inputs.libnd4jUrl != '' }}
      - name: Build on  android-x86
        shell: bash
        env:
          MAVEN_GPG_KEY: ${{ secrets.SONATYPE_GPG_KEY }}
          CROSS_COMPILER_DIR: ${{ steps.setup-ndk.outputs.ndk-path }}
          DEBIAN_FRONTEND: noninteractive
          GITHUB_TOKEN:  ${{ secrets.GITHUB_TOKEN }}
          DEPLOY: 1
          BUILD_USING_MAVEN: 1
          NDK_VERSION: r21d
          CURRENT_TARGET: android-x86
          LIBND4J_CLASSIFIER: android-x86
          PUBLISH_TO: ossrh
          MAVEN_USERNAME: ${{ secrets.SONATYPE_USER_1 }}
          MAVEN_PASSWORD: ${{ secrets.SONATYPE_USER1_PASS }}
          MAVEN_GPG_PASSPHRASE: ${{ secrets.PACKAGES_GPG_PASS }}
          DEPLOY_TO: ossrh
          OPENBLAS_PATH: ${GITHUB_WORKSPACE}/openblas_home/lib/x86
          # note: we don't pass this in directly, this is for the pi_build.sh script
          LIBND4J_BUILD_THREADS: ${{ github.event.inputs.buildThreads }}
          PROTO_EXEC: /opt/protobuf/bin/protoc
          PERFORM_RELEASE: ${{ github.event.inputs.deployToReleaseStaging }}
          RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
          SNAPSHOT_VERSION: ${{ github.event.inputs.snapshotVersion }}
          RELEASE_REPO_ID: ${{ github.event.inputs.releaseRepoId }}
          MODULES: ${{ github.event.inputs.mvnFlags }}
          LIBND4J_FILE_NAME: ${{ matrix.libnd4j_file_download }}


        run: |
          echo "libnd4j build threads ${{ github.event.inputs.buildThreads }}"
          echo "deploy to release staging repo or not ${{ github.event.inputs.deployToReleaseStaging }}"
          echo "release version ${{ github.event.inputs.releaseVersion }}"
          echo "snapshot version ${{ github.event.inputs.snapshotVersion }}"
          echo "debug enabled ${{ github.event.inputs.debug_enabled }}"
          echo "libnd4j url ${{ github.event.inputs.libnd4jUrl }}"
          echo "maven flags ${{ github.event.inputs.mvnFlags }}"
          echo "snapshot version ${{ github.event.inputs.snapshotVersion }}"
          echo "server id ${{ github.event.inputs.serverId }}"
          echo "release repo id ${{ github.event.inputs.releaseRepoId }}"

          export PATH=/opt/protobuf/bin:/opt/cmake/bin:$PATH
          mvn --version
          cmake --version
          protoc --version
          sudo apt install -y unzip wget
          mkdir "${GITHUB_WORKSPACE}/openblas_home"
          cd "${GITHUB_WORKSPACE}/openblas_home"
          wget https://repo1.maven.org/maven2/org/bytedeco/openblas/0.3.19-1.5.7/openblas-0.3.19-1.5.7-android-x86.jar
          unzip openblas-0.3.19-1.5.7-android-x86.jar
          cd ..
          export PATH=/opt/protobuf/bin:$PATH
          export OPENBLAS_PATH=${GITHUB_WORKSPACE}/openblas_home/lib/x86/
          # download libnd4j from a url and set it up if LIBND4J_FILE_NAME is defined
          bash ./bootstrap-libnd4j-from-url.sh android x86
          ${GITHUB_WORKSPACE}/libnd4j/pi_build.sh