deeplearning4j/deeplearning4j

View on GitHub
.github/workflows/build-deploy-cross-platform.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: 'Release 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

      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:
   linux-x86_64:
    runs-on: ${{ github.event.inputs.runsOn }}
    steps:
      - 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'


      - name: Build on  linux-x86_64
        shell: bash
        env:
          MAVEN_GPG_KEY: ${{ secrets.SONATYPE_GPG_KEY }}
          DEBIAN_FRONTEND: noninteractive
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PUBLISH_TO: ossrh
          MAVEN_USERNAME: ${{ secrets.SONATYPE_USER_1 }}
          MAVEN_PASSWORD: ${{ secrets.SONATYPE_USER1_PASS }}
          MAVEN_GPG_PASSPHRASE: ${{ secrets.PACKAGES_GPG_PASS }}
          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 }}

        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 }}"

          sudo sysctl vm.overcommit_memory=2
          export PATH=/opt/protobuf/bin:/opt/cmake/bin:$PATH
          mvn --version
          cmake --version
          protoc --version
          sudo apt-get autoremove
          sudo apt-get clean
          command="mvn   -Possrh -pl !:nd4j-native,!libnd4j,!:nd4j-native-preset,!:nd4j-native-platform  -DskipTestResourceEnforcement=true -Djavacpp.platform=linux-x86_64 -Dlibnd4j.chip=cpu -Pcpu --batch-mode deploy -DskipTests"
          if [ "$PERFORM_RELEASE" == 1 ]; then
                    echo "Performing release"
                    bash ${GITHUB_WORKSPACE}/release-specified-component.sh  "${RELEASE_VERSION}" "${SNAPSHOT_VERSION}" "${RELEASE_REPO_ID}" "${command}"
                   else
                       echo "Running build and deploying to snapshots"
                       eval "$command"
          fi

          bash ./change-spark-versions.sh 3.1.2

          if [ "$PERFORM_RELEASE" == 1 ]; then
                        echo "Performing release"
                        bash ${GITHUB_WORKSPACE}/release-specified-component.sh  "${RELEASE_VERSION}" "${SNAPSHOT_VERSION}" "${RELEASE_REPO_ID}" "${command}"
                       else
                           echo "Running build and deploying to snapshots"
                           eval "$command"
          fi