Skip to content

Commit f14f7eb

Browse files
authored
Merge pull request #72 from zong-zhe/test-my-image
feat: fix github action for java sdk in centos7
2 parents 34b02b7 + b6b3e49 commit f14f7eb

File tree

4 files changed

+84
-89
lines changed

4 files changed

+84
-89
lines changed

.devcontainer/Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM centos:7
2+
3+
RUN yum -y update && \
4+
yum install gcc gcc-c++ glibc-static -y
5+
6+
RUN yum -y install wget
7+
8+
RUN yum -y install git
9+
10+
RUN yum -y install python3
11+
12+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
13+
14+
ENV PATH="/root/.cargo/bin:${PATH}"
15+
16+
RUN yum -y install java-1.8.0-openjdk-devel
17+
18+
RUN wget https://repo.huaweicloud.com/apache/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz && \
19+
tar -xzf apache-maven-*.tar.gz && \
20+
mkdir -p /opt/maven && \
21+
mv apache-maven-* /opt/maven && \
22+
ln -s /opt/maven/apache-maven-3.9.6/bin/mvn /usr/bin/mvn
23+
24+
CMD ["tail", "-f", "/dev/null"]

.devcontainer/devcontainer.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "kcl",
3+
"dockerFile": "./Dockerfile",
4+
"forwardPorts": [3000, 5000],
5+
"settings": {
6+
"terminal.integrated.shell.linux": "/bin/bash"
7+
},
8+
}

.github/workflows/java-test.yaml

+51-88
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
workflow_dispatch:
1616

1717
jobs:
18-
test:
18+
test-and-build:
1919
permissions:
2020
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
2121
contents: read # for actions/checkout to fetch code
@@ -87,104 +87,26 @@ jobs:
8787
name: kcl-lib-${{ matrix.classifier }}
8888
path: |
8989
java/target/classes/native
90-
91-
build-on-centos:
92-
name: Build on CentOS 7
90+
91+
add-centos7-jni:
9392
runs-on: ubuntu-latest
9493
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+
16096
permissions:
16197
contents: read
16298
packages: write
163-
if: "startsWith(github.ref, 'refs/tags/')"
164-
needs: [ test, build-on-centos ]
99+
needs: [ test-and-build ]
165100
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
175103

176104
- name: Download windows x86_64 lib
177105
uses: actions/download-artifact@v3
178106
with:
179107
name: kcl-lib-windows-x86_64
180108
path: java/native
181109

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-
188110
- name: Download linux aarch_64 lib
189111
uses: actions/download-artifact@v3
190112
with:
@@ -206,19 +128,60 @@ jobs:
206128
- name: Package Java artifact
207129
working-directory: java
208130
run: |
209-
mvn clean package -DskipTests=true
131+
rustup default stable && mvn package -DskipTests=true
210132
211133
- name: Upload artifact
212134
uses: actions/upload-artifact@v3
213135
with:
214136
name: kcl-lib
215137
path: java/target/*.jar
216138

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+
217165
- 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/')"
218180
working-directory: java
219181
run: |
220-
mvn clean package deploy \
182+
mvn package deploy \
221183
-DskipTests=true \
184+
-DskipCompile=true \
222185
-Dcargo-build.profile=release \
223186
-DserverId=github \
224187
-s $GITHUB_WORKSPACE/settings.xml

java/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.kcl</groupId>
77
<artifactId>kcl-lib</artifactId>
8-
<version>0.8.7</version>
8+
<version>0.9.0-SNAPSHOT</version>
99
<name>KCL Arifact Library for Java</name>
1010
<description>
1111
KCL is an open-source constraint-based record and functional language mainly

0 commit comments

Comments
 (0)