GitHub actions (#2)
* Updated readme, enabled automatc testing * Snapshot support * Release CI support Co-authored-by: Salomon BRYS <salomon@kodein.net>
This commit is contained in:
parent
08d1692932
commit
fa425731a1
71
.github/workflows/release.yml
vendored
Normal file
71
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
name: Publish release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
publish-ios:
|
||||||
|
name: Publish iOS native
|
||||||
|
runs-on: macOS-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Install automake
|
||||||
|
run: brew install automake
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Check
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
arguments: iosX64Test
|
||||||
|
- name: Publish
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
BINTRAY_USER: ${{ secrets.bintray_user }}
|
||||||
|
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
|
||||||
|
with:
|
||||||
|
arguments: publishIosArm64PublicationToBintrayRepository publishIosX64PublicationToBintrayRepository
|
||||||
|
|
||||||
|
publish:
|
||||||
|
name: Publish JVM & Linux native
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Check
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
arguments: check
|
||||||
|
- name: Publish
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
BINTRAY_USER: ${{ secrets.bintray_user }}
|
||||||
|
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
|
||||||
|
with:
|
||||||
|
arguments: publishAllPublicationsToBintrayRepository
|
72
.github/workflows/snapshot.yml
vendored
Normal file
72
.github/workflows/snapshot.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
name: Publish snapshot
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'snapshot/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
publish-ios:
|
||||||
|
name: Publish iOS native
|
||||||
|
runs-on: macOS-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Install automake
|
||||||
|
run: brew install automake
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Check
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
arguments: iosX64Test
|
||||||
|
- name: Publish
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
BINTRAY_USER: ${{ secrets.bintray_user }}
|
||||||
|
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
|
||||||
|
with:
|
||||||
|
arguments: publishIosArm64PublicationToBintrayRepository publishIosX64PublicationToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} -PgitSha=${{ github.sha }}
|
||||||
|
|
||||||
|
publish:
|
||||||
|
name: Publish JVM & Linux native
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Check
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
arguments: check
|
||||||
|
- name: Publish
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
BINTRAY_USER: ${{ secrets.bintray_user }}
|
||||||
|
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
|
||||||
|
with:
|
||||||
|
arguments: publishAllPublicationsToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} -PgitSha=${{ github.sha }}
|
71
.github/workflows/test.yml
vendored
Normal file
71
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
name: Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- 'snapshot/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
linux:
|
||||||
|
name: JNI & Linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Check JNI
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
arguments: jvmTest -PnoCrossCompile=true
|
||||||
|
- name: Check Linux
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
arguments: linuxTest -PnoCrossCompile=true
|
||||||
|
|
||||||
|
macos:
|
||||||
|
name: iOS & Android
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Cached Konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-konan-
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Install Automake
|
||||||
|
run: brew install automake
|
||||||
|
- name: Check iOS
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
arguments: iosX64Test -PnoCrossCompile=true
|
||||||
|
- name: Check Android
|
||||||
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
|
with:
|
||||||
|
api-level: 29
|
||||||
|
ndk: 21.3.6528147
|
||||||
|
cmake: 3.10.2.4988404
|
||||||
|
script: ./gradlew connectedCheck -PnoCrossCompile=true
|
66
README.md
66
README.md
@ -2,3 +2,69 @@
|
|||||||
|
|
||||||
Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux.
|
Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Multiplatform
|
||||||
|
|
||||||
|
Add the `secp256k1` dependency to the common sourceSet, and the JNI dependencies to JVM and Android sourcesets:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
// build.gradle.kts
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
android()
|
||||||
|
linuxX64("linux")
|
||||||
|
ios()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val commonMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib-common"))
|
||||||
|
implementation(kotlin("fr.acinq.secp256k1:secp256k1:$secp256k1_version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib"))
|
||||||
|
implementation(kotlin("fr.acinq.secp256k1:secp256k1-jni-jvm:$secp256k1_version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val androidMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib"))
|
||||||
|
implementation(kotlin("fr.acinq.secp256k1:secp256k1-jni-android:$secp256k1_version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Native targets (iOS, linux64)
|
||||||
|
|
||||||
|
Native targets include libsecp256k1, called through KMP's c-interop, simply add the `fr.acinq.secp256k1:secp256k1` dependency.
|
||||||
|
|
||||||
|
### JVM target & Android
|
||||||
|
|
||||||
|
The JVM library uses JNI bindings for libsecp256k1, which is much faster than BouncyCastle. It will extract and load native bindings for your operating system in a temporary directory.
|
||||||
|
|
||||||
|
JNI libraries are included for:
|
||||||
|
- Linux 64 bits
|
||||||
|
- Windows 64 bits
|
||||||
|
- Macos 64 bits
|
||||||
|
|
||||||
|
Along this library, you **must** specify which JNI native library to use in your dependency manager:
|
||||||
|
|
||||||
|
* For desktop or server JVMs, you must add the `fr.acinq.secp256k1:secp256k1-jni-jvm` dependency
|
||||||
|
* For Android, you must add the `fr.acinq.secp256k1:secp256k1-jni-android` dependency
|
||||||
|
|
||||||
|
If you are using the JVM on an OS for which we don't provide JNI bindings (32 bits OS for example), you can use your own library native library by
|
||||||
|
adding the `fr.acinq.secp256k1:secp256k1-jni-jvm` dependency and specifying its path with `-Dfr.acinq.secp256k1.lib.path` and optionally its name with `-Dfr.acinq.secp256k1.lib.name`
|
||||||
|
(if unspecified bitcoink use the standard name for your OS i.e. libsecp256k1.so on Linux, secp256k1.dll on Windows, ...).
|
||||||
|
|
||||||
|
You can also specify the temporary directory where the library will be extracted with `-Djava.io.tmpdir` or `-Dfr.acinq.secp256k1.tmpdir`
|
||||||
|
(if you want to use a different directory from `-Djava.io.tmpdir`).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Please have a look at unit tests, more samples will be added soon.
|
||||||
|
@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "fr.acinq.secp256k1"
|
group = "fr.acinq.secp256k1"
|
||||||
version = "0.1.0-1.4-M2"
|
version = "0.1.1-1.4-M2"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
@ -110,7 +110,6 @@ allprojects {
|
|||||||
allprojects {
|
allprojects {
|
||||||
plugins.withId("maven-publish") {
|
plugins.withId("maven-publish") {
|
||||||
publishing {
|
publishing {
|
||||||
val snapshotName: String? by project
|
|
||||||
val snapshotNumber: String? by project
|
val snapshotNumber: String? by project
|
||||||
|
|
||||||
val bintrayUsername: String? = (properties["bintrayUsername"] as String?) ?: System.getenv("BINTRAY_USER")
|
val bintrayUsername: String? = (properties["bintrayUsername"] as String?) ?: System.getenv("BINTRAY_USER")
|
||||||
@ -130,8 +129,12 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val gitRef: String? by project
|
||||||
|
val gitSha: String? by project
|
||||||
|
val eapBranch = gitRef?.split("/")?.last() ?: "dev"
|
||||||
|
val eapSuffix = gitSha?.let { "-${it.substring(0, 7)}" } ?: ""
|
||||||
publications.withType<MavenPublication>().configureEach {
|
publications.withType<MavenPublication>().configureEach {
|
||||||
if (snapshotName != null && snapshotNumber != null) version = "${project.version}-${snapshotName}-${snapshotNumber}"
|
if (snapshotNumber != null) version = "${project.version}-$eapBranch-$snapshotNumber$eapSuffix"
|
||||||
pom {
|
pom {
|
||||||
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
|
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
|
||||||
url.set("https://github.com/ACINQ/secp256k1-kmp")
|
url.set("https://github.com/ACINQ/secp256k1-kmp")
|
||||||
|
@ -49,12 +49,15 @@ sealed class Cross {
|
|||||||
val buildNativeJni by tasks.creating {
|
val buildNativeJni by tasks.creating {
|
||||||
group = "build"
|
group = "build"
|
||||||
}
|
}
|
||||||
|
val noCrossCompile: String? by project
|
||||||
fun creatingBuildNativeJni(target: String, cross: Cross?) = tasks.creating(Exec::class) {
|
fun creatingBuildNativeJni(target: String, cross: Cross?) = tasks.creating(Exec::class) {
|
||||||
group = "build"
|
group = "build"
|
||||||
dependsOn(generateJniHeaders)
|
dependsOn(generateJniHeaders)
|
||||||
dependsOn(":native:buildSecp256k1${target.capitalize()}")
|
dependsOn(":native:buildSecp256k1${target.capitalize()}")
|
||||||
buildNativeJni.dependsOn(this)
|
buildNativeJni.dependsOn(this)
|
||||||
|
|
||||||
|
if (noCrossCompile == "true") onlyIf { cross == null }
|
||||||
|
|
||||||
inputs.files(projectDir.resolve("build.sh"))
|
inputs.files(projectDir.resolve("build.sh"))
|
||||||
outputs.dir(buildDir.resolve("build/cmake/$target"))
|
outputs.dir(buildDir.resolve("build/cmake/$target"))
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ JNI_HEADERS=$TARGET
|
|||||||
if [ "$TARGET" == "linux" ]; then
|
if [ "$TARGET" == "linux" ]; then
|
||||||
OUTFILE=libsecp256k1-jni.so
|
OUTFILE=libsecp256k1-jni.so
|
||||||
ADD_LIB=-lgmp
|
ADD_LIB=-lgmp
|
||||||
|
CC_OPTS="-fPIC"
|
||||||
elif [ "$TARGET" == "darwin" ]; then
|
elif [ "$TARGET" == "darwin" ]; then
|
||||||
OUTFILE=libsecp256k1-jni.dylib
|
OUTFILE=libsecp256k1-jni.dylib
|
||||||
if [ -z "$CROSS_TRIPLE" ]; then
|
if [ -z "$CROSS_TRIPLE" ]; then
|
||||||
@ -24,7 +25,7 @@ elif [ "$TARGET" == "mingw" ]; then
|
|||||||
OUTFILE=secp256k1-jni.dll
|
OUTFILE=secp256k1-jni.dll
|
||||||
CC=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-gcc
|
CC=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-gcc
|
||||||
JNI_HEADERS=linux
|
JNI_HEADERS=linux
|
||||||
CC_OPTS="-fpic"
|
CC_OPTS="-fPIC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p build/jni/$TARGET
|
mkdir -p build/jni/$TARGET
|
||||||
|
@ -25,10 +25,13 @@ val buildSecp256k1Jvm by tasks.creating {
|
|||||||
group = "build"
|
group = "build"
|
||||||
buildSecp256k1.dependsOn(this)
|
buildSecp256k1.dependsOn(this)
|
||||||
}
|
}
|
||||||
|
val noCrossCompile: String? by project
|
||||||
fun creatingBuildSecp256k1(target: String, cross: Cross?) = tasks.creating(Exec::class) {
|
fun creatingBuildSecp256k1(target: String, cross: Cross?) = tasks.creating(Exec::class) {
|
||||||
group = "build"
|
group = "build"
|
||||||
buildSecp256k1Jvm.dependsOn(this)
|
buildSecp256k1Jvm.dependsOn(this)
|
||||||
|
|
||||||
|
if (noCrossCompile == "true") onlyIf { cross == null }
|
||||||
|
|
||||||
inputs.files(projectDir.resolve("build.sh"))
|
inputs.files(projectDir.resolve("build.sh"))
|
||||||
outputs.dir(projectDir.resolve("build/$target"))
|
outputs.dir(projectDir.resolve("build/$target"))
|
||||||
|
|
||||||
|
@ -12,12 +12,15 @@ cd "$(dirname "$0")"
|
|||||||
cd secp256k1
|
cd secp256k1
|
||||||
|
|
||||||
if [ "$TARGET" == "mingw" ]; then
|
if [ "$TARGET" == "mingw" ]; then
|
||||||
CONF_OPTS="CFLAGS=-fpic --host=x86_64-w64-mingw32"
|
CONF_OPTS="CFLAGS=-fPIC --host=x86_64-w64-mingw32"
|
||||||
elif [ "$TARGET" == "linux" ]; then
|
elif [ "$TARGET" == "linux" ]; then
|
||||||
CONF_OPTS="CFLAGS=-fpic"
|
CONF_OPTS="CFLAGS=-fPIC"
|
||||||
[ "$CROSS" == "1" ] && sudo apt -y install libgmp-dev
|
[ "$CROSS" == "1" ] && sudo apt -y install libgmp-dev
|
||||||
elif [ "$TARGET" == "darwin" ]; then
|
elif [ "$TARGET" == "darwin" ]; then
|
||||||
CONF_OPTS="--host=x86_64-w64-darwin"
|
CONF_OPTS="--host=x86_64-w64-darwin"
|
||||||
|
else
|
||||||
|
echo "Unknown TARGET=$TARGET"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user