Skip to content

chore: add ci to release java lib #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 26, 2024
11 changes: 11 additions & 0 deletions .github/mvn-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
84 changes: 70 additions & 14 deletions .github/workflows/java-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ on:
- "java/**"
workflow_dispatch:

permissions:
contents: read

jobs:
test:
permissions:
Expand Down Expand Up @@ -50,20 +47,19 @@ jobs:
env:
ROOT_POM: ${{ matrix.root-pom }}
steps:
- name: 'Check out repository'
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: actions/checkout@v4

- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
cache: 'maven'
server-id: sonatype-nexus-snapshots
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -78,20 +74,80 @@ jobs:
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Setup for cargo
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

- name: 'Test'
shell: bash
working-directory: java
run: make test

- name: 'Build and Deploy'
shell: bash
working-directory: java
run: mvn clean install -DskipTests -Dcargo-build.profile=release -Djni.classifier=${{ matrix.classifier }} # && make deploy
env:
CI_DEPLOY_USERNAME: ${{ secrets.NEXUS_STAGE_DEPLOYER_USER }}
CI_DEPLOY_PASSWORD: ${{ secrets.NEXUS_STAGE_DEPLOYER_PW }}
run: |
mvn clean package -DskipTests=true -Djni.classifier=${{ matrix.classifier }}

- name: 'Upload artifact'
uses: actions/upload-artifact@v3
with:
name: java-artifact-${{ matrix.classifier }}
name: kcl-lib-${{ matrix.classifier }}
path: |
java/target/*.jar
java/target/classes/native

deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ test ]
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'

- name: Download windows x86_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-windows-x86_64
path: java/native/windows-x86_64

- name: Download linux x86_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-linux-x86_64
path: java/native/linux-x86_64

- name: Download linux aarch_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-linux-aarch_64
path: java/native/linux-aarch_64

- name: Download darwin x86_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-osx-x86_64
path: java/native/osx-x86_64

- name: Download darwin aarch_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-osx-aarch_64
path: java/native/osx-aarch_64

- name: Deploy to Github Packages
working-directory: java
run: |
mvn clean package deploy -DskipTests=true -DserverId=github -s ../.github/mvn-settings.xml
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: kcl-lib
path: java/target/*.jar
45 changes: 10 additions & 35 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
</extension>
</extensions>
<resources>
<resource>
<directory>native</directory>
</resource>
<resource>
<directory>native</directory>
<targetPath>native</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
Expand Down Expand Up @@ -158,20 +165,6 @@
</execution>
</executions>
</plugin>
<!--
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.17.1</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All @@ -180,19 +173,6 @@
<execution>
<id>default-jar</id>
<configuration>
<excludes>
<exclude>native/**</exclude>
</excludes>
</configuration>
</execution>
<!-- Generate the JAR that contains the native library in it. -->
<execution>
<id>native-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${jni.classifier}</classifier>
<includes>
<include>**/*.class</include>
<include>native/**</include>
Expand Down Expand Up @@ -266,15 +246,10 @@
</profile>
</profiles>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/kcl-lang/lib</url>
</repository>
</distributionManagement>
</project>
Loading