-
Notifications
You must be signed in to change notification settings - Fork 202
201 lines (200 loc) · 8.9 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
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
DEPLOY_SNAPSHOT: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging') }}
DEPLOY_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.DEPLOY_RELEASE == 'true'
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
export STAGING_REPOSITORY_ID=`awk -F'[<>]' '/stagedRepositoryId/{print $3}' response.xml`
echo "Staging repository created: $STAGING_REPOSITORY_ID"
- name: Checkout repository
uses: actions/checkout@v1
- name: Extract distribution repository URL
id: repository
run: |
if [[ "${{ env.DEPLOY_RELEASE }}" = "true" ]]; then
export REPOSITORY_URL=`mvn exec:exec -q -N -Dexec.executable='echo' -Dexec.args="\\${project.distributionManagement.repository.url}" -DstagingRepositoryId=$STAGING_REPOSITORY_ID`
else
export REPOSITORY_URL=`mvn exec:exec -q -N -Dexec.executable='echo' -Dexec.args="\\${project.distributionManagement.snapshotRepository.url}"`
fi
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=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }}
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
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 }}
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=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }}
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
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 }}
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=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }}
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
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 }}
windows-x86_64:
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=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }}
if ERRORLEVEL 1 exit /b
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
shell: cmd
run: |
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 }}
if ERRORLEVEL 1 exit /b
deploy:
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)
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: Build project
run: |
java -version
mvn -version
mvn clean install -B -U -e -Pdeploying
- 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>" > $HOME/.m2/settings.xml
mvn deploy -Pdeploying -B -e -Dmaven.test.skip=true