Deploy native artifacts in GHA runners #58
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI build | |
on: | |
push: | |
branches: | |
- master | |
- staging | |
- r[0-9]+.* | |
pull_request: | |
branches: | |
- master | |
- r[0-9]+.* | |
types: [opened, reopened, synchronize, labeled, unlabeled] | |
env: | |
STAGING_PROFILE_ID: 46f80d0729c92d | |
IS_SNAPSHOT: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging') }} | |
IS_RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/r') }} | |
jobs: | |
check-format: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Build project | |
run: | | |
gcc --version | |
mvn -version | |
mvn clean install -Pjdk17 -B -U -e -Dlint.skip=true -Dmaven.test.skip=true | |
- name: Run format checks | |
run: | | |
mvn spotless:check -Pjdk17 -B -U -e | |
prepare: | |
runs-on: ubuntu-20.04 | |
outputs: | |
repositoryUrl: ${{ steps.repository.outputs.repositoryUrl }} | |
steps: | |
- name: Create staging repository | |
if: ${{ env.IS_RELEASE }} | |
id: staging | |
run: | | |
echo "Creating staging repository with profile $STAGING_PROFILE_ID" | |
echo "<promoteRequest><data><description>Releasing TF Java - created by CI build</description></data></promoteRequest>" > request.xml | |
curl -X POST -d @request.xml -s -o response.xml -u ${{ secrets.CI_DEPLOY_USERNAME }}:${{ secrets.CI_DEPLOY_PASSWORD }} -H "Content-Type:application/xml" \ | |
https://oss.sonatype.org/service/local/staging/profiles/$STAGING_PROFILE_ID/start | |
STAGING_REPOSITORY_ID=`awk -F'[<>]' '/stagedRepositoryId/{print $3}' response.xml` | |
echo "Staging repository created: $STAGING_REPOSITORY_ID" | |
- name: Extract repository URL | |
id: repository | |
run: | | |
if [[ "${{ env.IS_RELEASE }}" ]]; then | |
export URL_PROPERTY="project.distributionManagement.repository.url" | |
else | |
export URL_PROPERTY="project.distributionManagement.snapshotRepository.url" | |
fi | |
REPOSITORY_URL=`mvn exec:exec -q -N -Dexec.executable='echo' -Dexec.args="\${$URL_PROPERTY}" -DstagingRepositoryId=$STAGING_REPOSITORY_ID` | |
echo "Repository URL: $REPOSITORY_URL" | |
echo "::set-output name=repositoryUrl::$REPOSITORY_URL" | |
linux-x86_64: | |
runs-on: ubuntu-20.04 | |
needs: prepare | |
strategy: | |
matrix: | |
ext: ["", -gpu] | |
steps: | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Build project | |
run: | | |
gcc --version | |
mvn -version | |
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 | |
mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -am | |
- name: Deploy native artifact | |
if: ${{ env.IS_RELEASE }} || ${{ env.IS_SNAPSHOT }} | |
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -Durl=${{ needs.prepare.outputs.repositoryUrl }} | |
macosx-arm64: | |
runs-on: macos-14 | |
needs: prepare | |
strategy: | |
matrix: | |
ext: [""] | |
steps: | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
architecture: 'arm64' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Build project | |
run: | | |
clang --version | |
mvn -version | |
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 | |
mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=macosx-arm64 -Djavacpp.platform.extension=${{ matrix.ext }} -am | |
- name: Deploy native artifact | |
if: ${{ env.IS_RELEASE }} || ${{ env.IS_SNAPSHOT }} | |
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -Durl=${{ needs.prepare.outputs.repositoryUrl }} | |
macosx-x86_64: | |
runs-on: macos-11 | |
needs: prepare | |
strategy: | |
matrix: | |
ext: [""] | |
steps: | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Build project | |
run: | | |
clang --version | |
mvn -version | |
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 | |
mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=macosx-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -am | |
- name: Deploy native artifact | |
if: ${{ env.IS_RELEASE }} || ${{ env.IS_SNAPSHOT }} | |
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -Durl=${{ needs.prepare.outputs.repositoryUrl }} | |
windows-x86_64: | |
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build') | |
runs-on: windows-2019 | |
needs: prepare | |
strategy: | |
matrix: | |
ext: [""] #, -gpu] | |
steps: | |
- name: Install environment | |
shell: cmd | |
run: | | |
set "PATH=C:\msys64\usr\bin;%PATH%" | |
python -m pip install numpy six | |
set "EXT=${{ matrix.ext }}" | |
echo %JAVA_HOME% | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Build project | |
shell: cmd | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 | |
set "PATH=C:\msys64\usr\bin;%PATH%" | |
echo Shorten work paths to prevent Bazel from reaching MAX_PATH limit | |
mkdir C:\tmp | |
set "TEST_TMPDIR=C:\tmp" | |
set "TMPDIR=C:\tmp" | |
set "TEMP=C:\tmp" | |
set "TMP=C:\tmp" | |
bash --version | |
git --version | |
cl | |
call mvn -version | |
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 | |
set "SKIP_EXPORT=true" | |
call mvn clean install -pl "!tensorflow-framework" -B -U -e -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -am | |
if ERRORLEVEL 1 exit /b | |
- name: Deploy native artifact | |
if: ${{ env.IS_RELEASE }} || ${{ env.IS_SNAPSHOT }} | |
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -Durl=${{ needs.prepare.outputs.repositoryUrl }} | |
deploy: | |
if: false # ${{ env.IS_SNAPSHOT }} | |
needs: [linux-x86_64, macosx-x86_64, windows-x86_64, macosx-arm64] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Configure Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Checkout repository | |
uses: actions/checkout@v1 | |
- name: Deploy snapshot artifacts | |
run: | | |
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > settings.xml | |
bash deploy.sh |