diff --git a/.github/mvn-settings.xml b/.github/mvn-settings.xml new file mode 100644 index 00000000..4a4c1419 --- /dev/null +++ b/.github/mvn-settings.xml @@ -0,0 +1,11 @@ + + + + github + ${env.GITHUB_ACTOR} + ${env.GITHUB_TOKEN} + + + \ No newline at end of file diff --git a/.github/workflows/java-test.yaml b/.github/workflows/java-test.yaml index da768b5d..b8fa77e5 100644 --- a/.github/workflows/java-test.yaml +++ b/.github/workflows/java-test.yaml @@ -14,9 +14,6 @@ on: - "java/**" workflow_dispatch: -permissions: - contents: read - jobs: test: permissions: @@ -50,24 +47,23 @@ 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: - toolchain: 1.74 + toolchain: 1.77 override: true components: clippy, rustfmt @@ -78,20 +74,90 @@ 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 }} -Dcargo-build.profile=release + - 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 + + - name: Download linux x86_64 lib + uses: actions/download-artifact@v3 + with: + name: kcl-lib-linux-x86_64 + path: java/native + + - name: Download linux aarch_64 lib + uses: actions/download-artifact@v3 + with: + name: kcl-lib-linux-aarch_64 + path: java/native + + - name: Download darwin x86_64 lib + uses: actions/download-artifact@v3 + with: + name: kcl-lib-osx-x86_64 + path: java/native + + - name: Download darwin aarch_64 lib + uses: actions/download-artifact@v3 + with: + name: kcl-lib-osx-aarch_64 + path: java/native + + - name: Package Java artifact + working-directory: java + run: | + mvn clean package -DskipTests=true + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: kcl-lib + path: java/target/*.jar + + - name: Deploy to Github Packages + working-directory: java + run: | + mvn clean package deploy \ + -DskipTests=true \ + -Dcargo-build.profile=release \ + -DserverId=github \ + -s ../.github/mvn-settings.xml + env: + GITHUB_ACTOR: ${{ secrets.MAVEN_DEPLOY_USER }} + GITHUB_TOKEN: ${{ secrets.DEPLOY_ACCESS_TOKEN }} + diff --git a/.github/workflows/rust-test.yaml b/.github/workflows/rust-test.yaml index d3292c81..e9ff3f64 100644 --- a/.github/workflows/rust-test.yaml +++ b/.github/workflows/rust-test.yaml @@ -25,7 +25,7 @@ jobs: - name: Install rust nightly toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.74 + toolchain: 1.77 override: true components: clippy, rustfmt - name: Rust code test diff --git a/java/pom.xml b/java/pom.xml index 52cc2d20..66a42bc9 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -100,6 +100,13 @@ + + native + + + native + native + src/main/resources true @@ -158,20 +165,6 @@ - org.apache.maven.plugins maven-jar-plugin @@ -180,19 +173,6 @@ default-jar - - native/** - - - - - - native-jar - - jar - - - ${jni.classifier} **/*.class native/** @@ -266,15 +246,10 @@ - - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - sonatype-nexus-staging - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + github + GitHub Packages + https://maven.pkg.github.com/kcl-lang/lib