Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from matter-labs/develop
Browse files Browse the repository at this point in the history
Add build and publish desktop and android to maven central
  • Loading branch information
popzxc authored Oct 7, 2020
2 parents 6113a75 + 3c26be7 commit 7a46236
Show file tree
Hide file tree
Showing 26 changed files with 734 additions and 529 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/java-release-android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release Java library for Android

on:
push:
tags:
- "v*"

env:
GITHUB_REF: "${{ github.ref }}"

jobs:
build_native:
name: Build depends native library
runs-on: ubuntu-latest
env:
ANDROID_NDK_HOME: /opt/android-ndk
ANDROID_NDK_VERSION: r21d
strategy:
matrix:
cfg:
- { target: aarch64-linux-android, name: arm64-v8a }
- { target: armv7-linux-androideabi, name: armeabi-v7a }
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Rust environment
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install Cargo-NDK
run: cargo install cargo-ndk && rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Install NDK
shell: bash
run: mkdir /opt/android-ndk-tmp && cd /opt/android-ndk-tmp && wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME} && cd ${ANDROID_NDK_HOME} && rm -rf /opt/android-ndk-tmp
- name: Build project using cargo
run: cargo ndk --platform 21 --target ${{ matrix.cfg.target }} build --release
working-directory: zks-crypto/zks-crypto-c
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: zks-crypto-lib-${{ matrix.cfg.name }}
path: zks-crypto/zks-crypto-c/target/${{ matrix.cfg.target }}/release/libzks_crypto.so
build_and_publish:
name: Build jar library
runs-on: ubuntu-latest
needs: build_native
steps:
- name: Query version number
id: get_version
shell: bash
run: |
echo "using app version ${GITHUB_REF:11}"
echo ::set-output name=app::"${GITHUB_REF:11}"
- uses: actions/checkout@v2
- name: Load native libraries for arm64-v8a
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib-arm64-v8a
path: java/zksync-crypto/src/main/libs/arm64-v8a
- name: Load native libraries for armeabi-v7a
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib-armeabi-v7a
path: java/zksync-crypto/src/main/libs/armeabi-v7a
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build with Maven
working-directory: java/zksync-crypto
run: mvn install -PAndroid -Dmaven.test.skip=true
env:
APP_VERSION: ${{ steps.get_version.outputs.APP }}
- name: Save distribution
uses: actions/upload-artifact@v2
with:
name: zksync-crypto-java-dist
path: java/zksync-crypto/target/*.aar
- name: Publish package
working-directory: java/zksync-crypto
run: mvn clean deploy -PAndroid -Dmaven.test.skip=true
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
APP_VERSION: ${{ steps.get_version.outputs.APP }}-android
156 changes: 156 additions & 0 deletions .github/workflows/java-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Release Java library

on:
push:
tags:
- "v*"

env:
GITHUB_REF: "${{ github.ref }}"

jobs:
build_native:
name: Build depends native library
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Rust environment
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Build project using cargo
run: cargo build --release
working-directory: zks-crypto/zks-crypto-c
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: zks-crypto-lib
path: zks-crypto/zks-crypto-c/target/release/*zks_crypto.*
test:
name: Test java project
runs-on: ubuntu-latest
needs: build_native
steps:
- uses: actions/checkout@v2
- name: Load native libraries
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib
path: java/zksync-crypto
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- name: Build with Gradle
working-directory: java/zksync-crypto
run: mvn test
build_and_publish:
name: Build jar library
runs-on: ubuntu-latest
needs: build_native
steps:
- name: Query app version number
id: get_version
shell: bash
run: |
echo "using app version ${GITHUB_REF:11}"
echo ::set-output name=app::"${GITHUB_REF:11}"
- uses: actions/checkout@v2
- name: Load native libraries
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib
path: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/osx_64 && cp ./libzks_crypto.dylib ./src/main/resources/natives/osx_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/osx_32 && cp ./libzks_crypto.dylib ./src/main/resources/natives/osx_32
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/linux_64 && cp ./libzks_crypto.so ./src/main/resources/natives/linux_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/linux_32 && cp ./libzks_crypto.so ./src/main/resources/natives/linux_32
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/windows_64 && cp ./zks_crypto.dll ./src/main/resources/natives/windows_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/windows_32 && cp ./zks_crypto.dll ./src/main/resources/natives/windows_32
working-directory: java/zksync-crypto
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build with Maven
working-directory: java/zksync-crypto
run: mvn install
env:
APP_VERSION: ${{ steps.get_version.outputs.APP }}
- name: Save distribution
uses: actions/upload-artifact@v2
with:
name: zksync-crypto-java-dist
path: java/zksync-crypto/target/*.jar
- name: Publish package
working-directory: java/zksync-crypto
run: mvn clean deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
APP_VERSION: ${{ steps.get_version.outputs.APP }}
release:
name: Github release
needs: build_and_publish
runs-on: ubuntu-latest
steps:
- name: Query version number
id: get_version
shell: bash
run: |
echo "using version tag ${GITHUB_REF:10}"
echo ::set-output name=version::"${GITHUB_REF:10}"
echo ::set-output name=app::"${GITHUB_REF:11}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
- name: Dowload distribution
uses: actions/download-artifact@v2
with:
name: zksync-crypto-java-dist
- name: Release Java library
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./zkscrypto-${{ steps.get_version.outputs.APP }}.jar
asset_content_type: application/java-archive
asset_name: zksync-crypto.jar
- name: Release Java library sources
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./zkscrypto-${{ steps.get_version.outputs.APP }}-sources.jar
asset_content_type: application/java-archive
asset_name: zksync-crypto-sources.jar

98 changes: 98 additions & 0 deletions .github/workflows/java.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build Java library

on:
pull_request:
branches:
- master
push:
branches:
- develop

jobs:
build_native:
name: Build depends native library
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Rust environment
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Build project using cargo
run: cargo build --release
working-directory: zks-crypto/zks-crypto-c
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: zks-crypto-lib
path: zks-crypto/zks-crypto-c/target/release/*zks_crypto.*
test:
name: Test java project
runs-on: ubuntu-latest
needs: build_native
steps:
- uses: actions/checkout@v2
- name: Load native libraries
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib
path: java/zksync-crypto
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Test with Maven
working-directory: java/zksync-crypto
run: mvn test
build:
name: Build jar library
runs-on: ubuntu-latest
needs: build_native
steps:
- uses: actions/checkout@v2
- name: Load native libraries
uses: actions/download-artifact@v2
with:
name: zks-crypto-lib
path: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/osx_64 && cp ./libzks_crypto.dylib ./src/main/resources/natives/osx_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/osx_32 && cp ./libzks_crypto.dylib ./src/main/resources/natives/osx_32
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/linux_64 && cp ./libzks_crypto.so ./src/main/resources/natives/linux_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/linux_32 && cp ./libzks_crypto.so ./src/main/resources/natives/linux_32
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/windows_64 && cp ./zks_crypto.dll ./src/main/resources/natives/windows_64
working-directory: java/zksync-crypto
- run: mkdir -p ./src/main/resources/natives/windows_32 && cp ./zks_crypto.dll ./src/main/resources/natives/windows_32
working-directory: java/zksync-crypto
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
working-directory: java/zksync-crypto
run: mvn install
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: zksync-crypto-java-dist
path: java/zksync-crypto/target/*.jar



36 changes: 0 additions & 36 deletions java/zksync-crypto/build.gradle

This file was deleted.

Binary file not shown.
5 changes: 5 additions & 0 deletions java/zksync-crypto/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 7a46236

Please sign in to comment.