-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zksync-sdk/develop
Add release lib action
- Loading branch information
Showing
1 changed file
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
env: | ||
GITHUB_REF: "${{ github.ref }}" | ||
|
||
jobs: | ||
build_desktop: | ||
name: Build depends native library | ||
runs-on: ${{ matrix.cfg.os }} | ||
strategy: | ||
matrix: | ||
cfg: | ||
- { os: ubuntu-latest, name: linux } | ||
- { os: macos-latest, name: macos } | ||
- { os: windows-latest, name: windows } | ||
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.cfg.os == 'ubuntu-latest' }} | ||
run: sudo apt-get update && sudo apt-get install -y build-essential | ||
- name: Build project using cargo | ||
run: cargo build --release | ||
- name: Save artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: zks-crypto-${{ matrix.cfg.name }}-x64 | ||
path: target/release/*zks_crypto.* | ||
if-no-files-found: ignore | ||
build_android: | ||
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 | ||
- name: Save artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: zks-crypto-android-${{ matrix.cfg.name }} | ||
path: target/${{ matrix.cfg.target }}/release/libzks_crypto.so | ||
build_ios: | ||
name: Build depends native library | ||
runs-on: macos-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 Cargo Lipo | ||
run: cargo install cargo-lipo && rustup target add aarch64-apple-ios x86_64-apple-ios | ||
- name: Build project using cargo | ||
run: cargo lipo --release | ||
- name: Save artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: zks-crypto-ios-x64 | ||
path: target/universal/release/libzks_crypto.a | ||
release: | ||
name: Github release | ||
runs-on: ubuntu-latest | ||
needs: [build_desktop, build_android, build_ios] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
path: binaries | ||
- run: | | ||
set -x | ||
assets=() | ||
for file in ./binaries/*/*.*; do | ||
parentname="$(basename "$(dirname "$file")")" | ||
mv ${file} "./binaries/${parentname}.${file##*.}" | ||
done | ||
for asset in ./binaries/*.*; do | ||
assets+=("-a" "$asset") | ||
done | ||
tag_name="${GITHUB_REF:10}" | ||
git checkout ${tag_name} | ||
hub release create "${assets[@]}" -m "$tag_name" "$tag_name" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |