|
| 1 | +name: CI build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - staging |
| 7 | + - r[0-9]+.* |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + - r[0-9]+.* |
| 12 | + types: [opened, reopened, synchronize, labeled, unlabeled] |
| 13 | +env: |
| 14 | + STAGING_PROFILE_ID: 46f80d0729c92d |
| 15 | + DEPLOY_SNAPSHOT: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging') }} |
| 16 | + DEPLOY_RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/r') }} |
| 17 | +jobs: |
| 18 | + check-format: |
| 19 | + if: github.event_name == 'pull_request' |
| 20 | + runs-on: ubuntu-22.04 |
| 21 | + steps: |
| 22 | + - name: Configure Java |
| 23 | + uses: actions/setup-java@v2 |
| 24 | + with: |
| 25 | + distribution: 'adopt' |
| 26 | + java-version: '17' |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v1 |
| 29 | + - name: Build project |
| 30 | + run: | |
| 31 | + gcc --version |
| 32 | + mvn -version |
| 33 | + mvn clean install -Pjdk17 -B -U -e -Dlint.skip=true -Dmaven.test.skip=true |
| 34 | + - name: Run format checks |
| 35 | + run: | |
| 36 | + mvn spotless:check -Pjdk17 -B -U -e |
| 37 | + prepare: |
| 38 | + runs-on: ubuntu-22.04 |
| 39 | + outputs: |
| 40 | + repositoryUrl: ${{ steps.repository.outputs.repositoryUrl }} |
| 41 | + steps: |
| 42 | + - name: Create staging repository |
| 43 | + if: env.DEPLOY_RELEASE == 'true' |
| 44 | + id: staging |
| 45 | + run: | |
| 46 | + echo "Creating staging repository with profile $STAGING_PROFILE_ID" |
| 47 | + echo "<promoteRequest><data><description>Releasing TF Java - created by CI build</description></data></promoteRequest>" > request.xml |
| 48 | + curl -X POST -d @request.xml -s -o response.xml -u ${{ secrets.CI_DEPLOY_USERNAME }}:${{ secrets.CI_DEPLOY_PASSWORD }} -H "Content-Type:application/xml" \ |
| 49 | + https://oss.sonatype.org/service/local/staging/profiles/$STAGING_PROFILE_ID/start |
| 50 | + export STAGING_REPOSITORY_ID=`awk -F'[<>]' '/stagedRepositoryId/{print $3}' response.xml` |
| 51 | + echo "Staging repository created: $STAGING_REPOSITORY_ID" |
| 52 | + echo "::set-output name=stagingRepositoryId::$STAGING_REPOSITORY_ID" |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v1 |
| 55 | + - name: Extract distribution repository URL |
| 56 | + id: repository |
| 57 | + run: | |
| 58 | + if [[ "${{ env.DEPLOY_RELEASE }}" = "true" ]]; then |
| 59 | + export REPOSITORY_URL=`mvn exec:exec -q -N -Dexec.executable='echo' -Dexec.args="\\${project.distributionManagement.repository.url}" -DstagingRepositoryId=${{ steps.staging.outputs.stagingRepositoryId }}` |
| 60 | + else |
| 61 | + export REPOSITORY_URL=`mvn exec:exec -q -N -Dexec.executable='echo' -Dexec.args="\\${project.distributionManagement.snapshotRepository.url}"` |
| 62 | + fi |
| 63 | + echo "Repository URL: $REPOSITORY_URL" |
| 64 | + echo "::set-output name=repositoryUrl::$REPOSITORY_URL" |
| 65 | + linux-arm64: |
| 66 | + runs-on: ubuntu-2204-arm64-2c |
| 67 | + needs: prepare |
| 68 | + strategy: |
| 69 | + matrix: |
| 70 | + ext: [""] |
| 71 | + steps: |
| 72 | + - name: Install environment |
| 73 | + run: | |
| 74 | + sudo apt update |
| 75 | + sudo apt install -y curl wget unzip tar git gcc g++ |
| 76 | + - name: Configure Java |
| 77 | + uses: actions/setup-java@v2 |
| 78 | + with: |
| 79 | + distribution: 'zulu' |
| 80 | + java-version: '17' |
| 81 | + architecture: 'aarch64' |
| 82 | + - name: Checkout repository |
| 83 | + uses: actions/checkout@v1 |
| 84 | + - name: Build project |
| 85 | + run: | |
| 86 | + gcc --version |
| 87 | + mvn -version |
| 88 | + echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml |
| 89 | + mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} |
| 90 | + - name: Deploy native artifact |
| 91 | + if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true' |
| 92 | + run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }} |
| 93 | + linux-x86_64: |
| 94 | + runs-on: ubuntu-22.04 |
| 95 | + needs: prepare |
| 96 | + strategy: |
| 97 | + matrix: |
| 98 | + ext: ["", -gpu] |
| 99 | + steps: |
| 100 | + - name: Configure Java |
| 101 | + uses: actions/setup-java@v2 |
| 102 | + with: |
| 103 | + distribution: 'adopt' |
| 104 | + java-version: '11' |
| 105 | + - name: Checkout repository |
| 106 | + uses: actions/checkout@v1 |
| 107 | + - name: Build project |
| 108 | + run: | |
| 109 | + gcc --version |
| 110 | + mvn -version |
| 111 | + echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml |
| 112 | + mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} |
| 113 | + - name: Deploy native artifact |
| 114 | + if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true' |
| 115 | + run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }} |
| 116 | + macosx-arm64: |
| 117 | + runs-on: macos-14 |
| 118 | + needs: prepare |
| 119 | + strategy: |
| 120 | + matrix: |
| 121 | + ext: [""] |
| 122 | + steps: |
| 123 | + - name: Configure Java |
| 124 | + uses: actions/setup-java@v2 |
| 125 | + with: |
| 126 | + distribution: 'zulu' |
| 127 | + java-version: '17' |
| 128 | + architecture: 'arm64' |
| 129 | + - name: Checkout repository |
| 130 | + uses: actions/checkout@v1 |
| 131 | + - name: Build project |
| 132 | + run: | |
| 133 | + clang --version |
| 134 | + mvn -version |
| 135 | + echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml |
| 136 | + mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} |
| 137 | + - name: Deploy native artifact |
| 138 | + if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true' |
| 139 | + run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }} |
| 140 | + windows-x86_64: |
| 141 | + runs-on: windows-2019 |
| 142 | + needs: prepare |
| 143 | + strategy: |
| 144 | + matrix: |
| 145 | + ext: [""] #, -gpu] |
| 146 | + steps: |
| 147 | + - name: Install environment |
| 148 | + shell: cmd |
| 149 | + run: | |
| 150 | + set "PATH=C:\msys64\usr\bin;%PATH%" |
| 151 | + python -m pip install numpy six |
| 152 | + set "EXT=${{ matrix.ext }}" |
| 153 | + echo %JAVA_HOME% |
| 154 | + - name: Configure Java |
| 155 | + uses: actions/setup-java@v2 |
| 156 | + with: |
| 157 | + distribution: 'adopt' |
| 158 | + java-version: '11' |
| 159 | + - name: Checkout repository |
| 160 | + uses: actions/checkout@v1 |
| 161 | + - name: Build project |
| 162 | + shell: cmd |
| 163 | + run: | |
| 164 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 |
| 165 | + set "PATH=C:\msys64\usr\bin;%PATH%" |
| 166 | + echo Shorten work paths to prevent Bazel from reaching MAX_PATH limit |
| 167 | + mkdir C:\tmp |
| 168 | + set "TEST_TMPDIR=C:\tmp" |
| 169 | + set "TMPDIR=C:\tmp" |
| 170 | + set "TEMP=C:\tmp" |
| 171 | + set "TMP=C:\tmp" |
| 172 | + bash --version |
| 173 | + git --version |
| 174 | + cl |
| 175 | + call mvn -version |
| 176 | + echo ^<settings^>^<servers^>^<server^>^<id^>ossrh^</id^>^<username^>${{ secrets.CI_DEPLOY_USERNAME }}^</username^>^<password^>${{ secrets.CI_DEPLOY_PASSWORD }}^</password^>^</server^>^</servers^>^</settings^> > %USERPROFILE%\.m2\settings.xml |
| 177 | + set "SKIP_EXPORT=true" |
| 178 | + call mvn clean install -pl "!tensorflow-framework" -B -U -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} |
| 179 | + if ERRORLEVEL 1 exit /b |
| 180 | + - name: Deploy native artifact |
| 181 | + if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true' |
| 182 | + shell: cmd |
| 183 | + run: | |
| 184 | + call mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }} |
| 185 | + if ERRORLEVEL 1 exit /b |
| 186 | + deploy: |
| 187 | + if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging') }} # DEPLOY_SNAPSHOT (releases should be signed and deployed manually from local machine) |
| 188 | + needs: [linux-x86_64, windows-x86_64, macosx-arm64, linux-arm64] |
| 189 | + runs-on: ubuntu-22.04 |
| 190 | + steps: |
| 191 | + - name: Configure Java |
| 192 | + uses: actions/setup-java@v2 |
| 193 | + with: |
| 194 | + distribution: 'adopt' |
| 195 | + java-version: '11' |
| 196 | + - name: Checkout repository |
| 197 | + uses: actions/checkout@v1 |
| 198 | + - name: Build project |
| 199 | + run: | |
| 200 | + java -version |
| 201 | + mvn -version |
| 202 | + mvn clean install -B -U -e -Pdeploying |
| 203 | + - name: Deploy snapshot artifacts |
| 204 | + run: | |
| 205 | + echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml |
| 206 | + mvn deploy -Pdeploying -B -e -Dmaven.test.skip=true |
0 commit comments