15
15
workflow_dispatch :
16
16
17
17
jobs :
18
- test :
18
+ test-and-build :
19
19
permissions :
20
20
actions : write # for styfle/cancel-workflow-action to cancel/stop running workflows
21
21
contents : read # for actions/checkout to fetch code
@@ -87,104 +87,26 @@ jobs:
87
87
name : kcl-lib-${{ matrix.classifier }}
88
88
path : |
89
89
java/target/classes/native
90
-
91
- build-on-centos :
92
- name : Build on CentOS 7
90
+
91
+ add-centos7-jni :
93
92
runs-on : ubuntu-latest
94
93
container :
95
- image : " centos:7"
96
-
97
- steps :
98
- - name : Checkout
99
- uses : actions/checkout@v3
100
-
101
- - name : Prepare build environment
102
- run : |
103
- yum makecache
104
- yum install -y wget
105
- yum install -y make
106
- yum install -y epel-release
107
- yum install -y llvm clang llvm-devel
108
- yum install gcc gcc-c++ glibc-static -y
109
- cat /etc/os-release
110
-
111
- - name : Install Python 3
112
- run : |
113
- yum install -y python3 python3-devel python3-pip
114
-
115
- - name : Install Rust
116
- run : |
117
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
118
- mv $HOME/.cargo/bin/* /usr/bin/
119
- rustc --version
120
- cargo --version
121
-
122
- - name : Install Java and Maven
123
- run : |
124
- yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
125
- wget https://repo.huaweicloud.com/apache/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
126
- tar -xzf apache-maven-*.tar.gz
127
- mkdir p /opt/maven
128
- mv apache-maven-* /opt/maven
129
- ln -s /opt/maven/apache-maven-3.9.6/bin/mvn /usr/bin/mvn
130
- mvn --version
131
-
132
- - name : Verify installed versions
133
- run : |
134
- gcc --version
135
- llvm-config --version
136
- python3 --version
137
- rustc --version
138
- mvn --version
139
- cat /etc/os-release
140
-
141
- - name : ' Test'
142
- shell : bash
143
- working-directory : java
144
- run : make test
145
-
146
- - name : ' Build and Deploy'
147
- shell : bash
148
- working-directory : java
149
- run : mvn clean package -DskipTests=true -Djni.classifier=linux-x86_64 -Dcargo-build.profile=release
150
-
151
- - name : ' Upload artifact'
152
- uses : actions/upload-artifact@v3
153
- with :
154
- name : kcl-lib-linux-x86_64
155
- path : java/target/classes/native
156
-
157
-
158
- deploy :
159
- runs-on : ubuntu-latest
94
+ image : " kcllang/kcl-java-builder-centos7:0.1.0"
95
+
160
96
permissions :
161
97
contents : read
162
98
packages : write
163
- if : " startsWith(github.ref, 'refs/tags/')"
164
- needs : [ test, build-on-centos ]
99
+ needs : [ test-and-build ]
165
100
steps :
166
- - uses : actions/checkout@v4
167
-
168
- - name : Set up JDK 8
169
- uses : actions/setup-java@v4
170
- with :
171
- distribution : ' temurin'
172
- java-version : ' 8'
173
- server-id : github # Value of the distributionManagement/repository/id field of the pom.xml
174
- settings-path : ${{ github.workspace }} # location for the settings.xml file
101
+ - name : Checkout
102
+ uses : actions/checkout@v3
175
103
176
104
- name : Download windows x86_64 lib
177
105
uses : actions/download-artifact@v3
178
106
with :
179
107
name : kcl-lib-windows-x86_64
180
108
path : java/native
181
109
182
- - name : Download linux x86_64 lib
183
- uses : actions/download-artifact@v3
184
- with :
185
- name : kcl-lib-linux-x86_64
186
- path : java/native
187
-
188
110
- name : Download linux aarch_64 lib
189
111
uses : actions/download-artifact@v3
190
112
with :
@@ -206,19 +128,60 @@ jobs:
206
128
- name : Package Java artifact
207
129
working-directory : java
208
130
run : |
209
- mvn clean package -DskipTests=true
131
+ rustup default stable && mvn package -DskipTests=true
210
132
211
133
- name : Upload artifact
212
134
uses : actions/upload-artifact@v3
213
135
with :
214
136
name : kcl-lib
215
137
path : java/target/*.jar
216
138
139
+ deploy :
140
+ runs-on : ubuntu-latest
141
+
142
+ permissions :
143
+ contents : read
144
+ packages : write
145
+ if : " startsWith(github.ref, 'refs/tags/')"
146
+ needs : [ add-centos7-jni ]
147
+ steps :
148
+ - name : Checkout
149
+ uses : actions/checkout@v3
150
+
151
+ - name : Set up JDK 8
152
+ uses : actions/setup-java@v4
153
+ with :
154
+ distribution : ' temurin'
155
+ java-version : ' 8'
156
+ server-id : github # Value of the distributionManagement/repository/id field of the pom.xml
157
+ settings-path : ${{ github.workspace }} # location for the settings.xml file
158
+
159
+ - name : Download Artifact
160
+ uses : actions/download-artifact@v3
161
+ with :
162
+ name : kcl-lib
163
+ path : java/target/
164
+
217
165
- name : Deploy to Github Packages
166
+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
167
+ working-directory : java
168
+ run : |
169
+ mvn package deploy \
170
+ -DskipTests=true \
171
+ -DskipCompile=true \
172
+ -Dcargo-build.profile=release \
173
+ -DserverId=github \
174
+ -s $GITHUB_WORKSPACE/settings.xml
175
+ env :
176
+ GITHUB_TOKEN : ${{ github.token }}
177
+
178
+ - name : Release to Github Packages
179
+ if : " startsWith(github.ref, 'refs/tags/')"
218
180
working-directory : java
219
181
run : |
220
- mvn clean package deploy \
182
+ mvn package deploy \
221
183
-DskipTests=true \
184
+ -DskipCompile=true \
222
185
-Dcargo-build.profile=release \
223
186
-DserverId=github \
224
187
-s $GITHUB_WORKSPACE/settings.xml
0 commit comments