Skip to content

Commit 8f04fff

Browse files
authored
Merge pull request #64 from zong-zhe/release-java
chore: add ci to release java lib
2 parents 7a849ec + e14d832 commit 8f04fff

File tree

4 files changed

+103
-51
lines changed

4 files changed

+103
-51
lines changed

.github/mvn-settings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
3+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<servers>
5+
<server>
6+
<id>github</id>
7+
<username>${env.GITHUB_ACTOR}</username>
8+
<password>${env.GITHUB_TOKEN}</password>
9+
</server>
10+
</servers>
11+
</settings>

.github/workflows/java-test.yaml

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ on:
1414
- "java/**"
1515
workflow_dispatch:
1616

17-
permissions:
18-
contents: read
19-
2017
jobs:
2118
test:
2219
permissions:
@@ -50,24 +47,23 @@ jobs:
5047
env:
5148
ROOT_POM: ${{ matrix.root-pom }}
5249
steps:
53-
- name: 'Check out repository'
54-
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
50+
- uses: actions/checkout@v4
51+
5552
- name: 'Set up JDK ${{ matrix.java }}'
5653
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
5754
with:
5855
java-version: ${{ matrix.java }}
5956
distribution: 'zulu'
6057
cache: 'maven'
61-
server-id: sonatype-nexus-snapshots
62-
server-username: CI_DEPLOY_USERNAME
63-
server-password: CI_DEPLOY_PASSWORD
58+
6459
- uses: actions/setup-python@v5
6560
with:
6661
python-version: '3.10'
62+
6763
- name: Install rust nightly toolchain
6864
uses: actions-rs/toolchain@v1
6965
with:
70-
toolchain: 1.74
66+
toolchain: 1.77
7167
override: true
7268
components: clippy, rustfmt
7369

@@ -78,20 +74,90 @@ jobs:
7874
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
7975
# Setup for cargo
8076
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
77+
8178
- name: 'Test'
8279
shell: bash
8380
working-directory: java
8481
run: make test
82+
8583
- name: 'Build and Deploy'
8684
shell: bash
8785
working-directory: java
88-
run: mvn clean install -DskipTests -Dcargo-build.profile=release -Djni.classifier=${{ matrix.classifier }} # && make deploy
89-
env:
90-
CI_DEPLOY_USERNAME: ${{ secrets.NEXUS_STAGE_DEPLOYER_USER }}
91-
CI_DEPLOY_PASSWORD: ${{ secrets.NEXUS_STAGE_DEPLOYER_PW }}
86+
run: |
87+
mvn clean package -DskipTests=true -Djni.classifier=${{ matrix.classifier }} -Dcargo-build.profile=release
88+
9289
- name: 'Upload artifact'
9390
uses: actions/upload-artifact@v3
9491
with:
95-
name: java-artifact-${{ matrix.classifier }}
92+
name: kcl-lib-${{ matrix.classifier }}
9693
path: |
97-
java/target/*.jar
94+
java/target/classes/native
95+
96+
deploy:
97+
runs-on: ubuntu-latest
98+
permissions:
99+
contents: read
100+
packages: write
101+
needs: [ test ]
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Set up JDK 8
106+
uses: actions/setup-java@v4
107+
with:
108+
distribution: 'temurin'
109+
java-version: '8'
110+
111+
- name: Download windows x86_64 lib
112+
uses: actions/download-artifact@v3
113+
with:
114+
name: kcl-lib-windows-x86_64
115+
path: java/native
116+
117+
- name: Download linux x86_64 lib
118+
uses: actions/download-artifact@v3
119+
with:
120+
name: kcl-lib-linux-x86_64
121+
path: java/native
122+
123+
- name: Download linux aarch_64 lib
124+
uses: actions/download-artifact@v3
125+
with:
126+
name: kcl-lib-linux-aarch_64
127+
path: java/native
128+
129+
- name: Download darwin x86_64 lib
130+
uses: actions/download-artifact@v3
131+
with:
132+
name: kcl-lib-osx-x86_64
133+
path: java/native
134+
135+
- name: Download darwin aarch_64 lib
136+
uses: actions/download-artifact@v3
137+
with:
138+
name: kcl-lib-osx-aarch_64
139+
path: java/native
140+
141+
- name: Package Java artifact
142+
working-directory: java
143+
run: |
144+
mvn clean package -DskipTests=true
145+
146+
- name: Upload artifact
147+
uses: actions/upload-artifact@v3
148+
with:
149+
name: kcl-lib
150+
path: java/target/*.jar
151+
152+
- name: Deploy to Github Packages
153+
working-directory: java
154+
run: |
155+
mvn clean package deploy \
156+
-DskipTests=true \
157+
-Dcargo-build.profile=release \
158+
-DserverId=github \
159+
-s ../.github/mvn-settings.xml
160+
env:
161+
GITHUB_ACTOR: ${{ secrets.MAVEN_DEPLOY_USER }}
162+
GITHUB_TOKEN: ${{ secrets.DEPLOY_ACCESS_TOKEN }}
163+

.github/workflows/rust-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install rust nightly toolchain
2626
uses: actions-rs/toolchain@v1
2727
with:
28-
toolchain: 1.74
28+
toolchain: 1.77
2929
override: true
3030
components: clippy, rustfmt
3131
- name: Rust code test

java/pom.xml

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@
100100
</extension>
101101
</extensions>
102102
<resources>
103+
<resource>
104+
<directory>native</directory>
105+
</resource>
106+
<resource>
107+
<directory>native</directory>
108+
<targetPath>native</targetPath>
109+
</resource>
103110
<resource>
104111
<directory>src/main/resources</directory>
105112
<filtering>true</filtering>
@@ -158,20 +165,6 @@
158165
</execution>
159166
</executions>
160167
</plugin>
161-
<!--
162-
<plugin>
163-
<groupId>net.revelc.code.formatter</groupId>
164-
<artifactId>formatter-maven-plugin</artifactId>
165-
<version>2.17.1</version>
166-
<executions>
167-
<execution>
168-
<goals>
169-
<goal>format</goal>
170-
</goals>
171-
</execution>
172-
</executions>
173-
</plugin>
174-
-->
175168
<plugin>
176169
<groupId>org.apache.maven.plugins</groupId>
177170
<artifactId>maven-jar-plugin</artifactId>
@@ -180,19 +173,6 @@
180173
<execution>
181174
<id>default-jar</id>
182175
<configuration>
183-
<excludes>
184-
<exclude>native/**</exclude>
185-
</excludes>
186-
</configuration>
187-
</execution>
188-
<!-- Generate the JAR that contains the native library in it. -->
189-
<execution>
190-
<id>native-jar</id>
191-
<goals>
192-
<goal>jar</goal>
193-
</goals>
194-
<configuration>
195-
<classifier>${jni.classifier}</classifier>
196176
<includes>
197177
<include>**/*.class</include>
198178
<include>native/**</include>
@@ -266,15 +246,10 @@
266246
</profile>
267247
</profiles>
268248
<distributionManagement>
269-
<snapshotRepository>
270-
<id>sonatype-nexus-snapshots</id>
271-
<name>Sonatype Nexus Snapshots</name>
272-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
273-
</snapshotRepository>
274249
<repository>
275-
<id>sonatype-nexus-staging</id>
276-
<name>Nexus Release Repository</name>
277-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
250+
<id>github</id>
251+
<name>GitHub Packages</name>
252+
<url>https://maven.pkg.github.com/kcl-lang/lib</url>
278253
</repository>
279254
</distributionManagement>
280255
</project>

0 commit comments

Comments
 (0)