Skip to content

Commit

Permalink
Upgrade to kotlin 1.9 (#108)
Browse files Browse the repository at this point in the history
Use kotlin 1.9
  • Loading branch information
sstone authored Jan 24, 2024
1 parent 1fadd6f commit ad3c6d9
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Publish Linux
if: matrix.os == 'ubuntu-latest'
shell: bash
run: ./gradlew publishLinuxPublicationToMavenLocal
run: ./gradlew publishLinuxX64PublicationToMavenLocal
- name: Publish MacOS
if: matrix.os == 'macOS-latest'
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Publish Linux to Maven Local
if: matrix.os == 'ubuntu-latest'
shell: bash
run: ./gradlew publishLinuxPublicationToMavenLocal
run: ./gradlew publishLinuxX64PublicationToMavenLocal
- name: Publish MacOS to Maven Local
if: matrix.os == 'macOS-latest'
shell: bash
Expand Down
30 changes: 22 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest

plugins {
kotlin("multiplatform") version "1.8.21"
id("org.jetbrains.dokka") version "1.8.10"
kotlin("multiplatform") version "1.9.22"
id("org.jetbrains.dokka") version "1.9.10"
`maven-publish`
}

val currentOs = org.gradle.internal.os.OperatingSystem.current()

group = "fr.acinq.bitcoin"
version = "0.15.0"
version = "0.16.0-SNAPSHOT"

repositories {
google()
Expand All @@ -30,14 +30,22 @@ kotlin {
}
}

linuxX64("linux")
linuxX64()

ios {
iosX64 {
compilations["main"].cinterops.create("CoreCrypto")
}

iosArm64 {
compilations["main"].cinterops.create("CoreCrypto")
}

iosSimulatorArm64 {
compilations["main"].cinterops.create("CoreCrypto")
}

sourceSets {
val secp256k1KmpVersion = "0.12.0"
val secp256k1KmpVersion = "0.13.0"

val commonMain by getting {
dependencies {
Expand All @@ -48,7 +56,7 @@ kotlin {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.kodein.memory:kodein-memory-files:0.7.0")
implementation("org.kodein.memory:klio-files:0.12.0")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
}
}
Expand Down Expand Up @@ -76,12 +84,18 @@ kotlin {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
// We use expect/actual for classes (see Chacha20Poly1305CipherFunctions). This feature is in beta and raises a warning.
// See https://youtrack.jetbrains.com/issue/KT-61573
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
}
}
}
}

configurations.forEach {
// do not cache changing (i.e. SNAPSHOT) dependencies
it.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)

if (it.name.contains("testCompileClasspath")) {
it.attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "java-runtime"))
}
Expand All @@ -94,7 +108,7 @@ plugins.withId("org.jetbrains.kotlin.multiplatform") {
val currentOs = org.gradle.internal.os.OperatingSystem.current()
val targets = when {
currentOs.isLinux -> listOf()
else -> listOf("linux")
else -> listOf("linuxX64")
}.mapNotNull { kotlin.targets.findByName(it) as? org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget }

configure(targets) {
Expand Down
21 changes: 21 additions & 0 deletions publishing/PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Publishing bitcoin-kmp artifacts

## snapshots

Snapshots are published to the Sonatype snapshot repository (https://oss.sonatype.org/content/repositories/snapshots/).
To publish a snapshot, you must add your sonatype credentials for the `ossrh` server to your local maven settings (typically in $HOME/.m2/settings.xml)

- Download `snapshot.zip` generated by the `Publish snapshot` github action
- unzip `snapshot.zip` in the `publishing` directory
- run `bitcoin-kmp-snapshot-deploy.sh`

## releases

Releases are published to the Sonatype staging repository. If all items are valid they will be published to the `maven central` repository.
You must edit `bitcoin-kmp-staging-upload.sh` and add your sonatype credentials. You must also have a valid GPG key.

- Download `release.zip` generated by the `Publish release` github action (which is triggered every time you publish a github release)
- unzip `release.zip` in the `publishing` directory
- sign all artifacts with a valid gpg key: `find release -type f -print -exec gpg -ab {} \;`
- run `bitcoin-kmp-staging-upload.sh`
- log into sonatype, close and publish your staging repository. Artifacts will be available on Maven Central within a few hours.
56 changes: 56 additions & 0 deletions publishing/bitcoin-kmp-snapshot-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash -x

GROUP_ID=fr.acinq.bitcoin
ARTIFACT_ID_BASE=bitcoin-kmp

if [[ -z "${VERSION}" ]]; then
echo "VERSION is not defined"
exit 1
fi

cd snapshot
pushd .
cd fr/acinq/bitcoin/bitcoin-kmp/$VERSION
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$VERSION.jar \
-Dfiles=$ARTIFACT_ID_BASE-$VERSION.module,$ARTIFACT_ID_BASE-$VERSION-kotlin-tooling-metadata.json \
-Dtypes=module,json \
-Dclassifiers=,kotlin-tooling-metadata \
-Dsources=$ARTIFACT_ID_BASE-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$VERSION-javadoc.jar
popd
pushd .
for i in iosarm64 iossimulatorarm64 iosx64 jvm linuxx64; do
cd fr/acinq/bitcoin/bitcoin-kmp-$i/$VERSION
if [ $i == iosarm64 ] || [ $i == iossimulatorarm64 ] || [ $i == iosx64 ]; then
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION-metadata.jar,$ARTIFACT_ID_BASE-$i-$VERSION.module,$ARTIFACT_ID_BASE-$i-$VERSION-cinterop-CoreCrypto.klib \
-Dtypes=jar,module,klib \
-Dclassifiers=metadata,,cinterop-CoreCrypto \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
elif [ $i == linuxx64 ]; then
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
else
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.jar \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
fi
popd
pushd .
done
31 changes: 31 additions & 0 deletions publishing/bitcoin-kmp-staging-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -x
#
# first you must sign all files with something like:
# find release -type f -print -exec gpg -ab {} \;
#

if [[ -z "${VERSION}" ]]; then
echo "VERSION is not defined"
exit 1
fi

if [[ -z "${OSS_USER}" ]]; then
echo "OSS_USER is not defined"
exit 1
fi

read -p "Password : " -s OSS_PASSWORD

for i in bitcoin-kmp \
bitcoin-kmp-iosarm64 \
bitcoin-kmp-iosx64 \
bitcoin-kmp-jvm \
bitcoin-kmp-linux
do
pushd .
cd release/fr/acinq/bitcoin/$i/$VERSION &&\
pwd &&\
jar -cvf bundle.jar *&&\
curl -v -XPOST -u $OSS_USER:$OSS_PASSWORD --upload-file bundle.jar https://oss.sonatype.org/service/local/staging/bundle_upload
popd
done
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/fr/acinq/bitcoin/Crypto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ public object Crypto {
/**
* private key is used as-is
*/
public object NoTweak : SchnorrTweak()
public data object NoTweak : SchnorrTweak()
}

public sealed class TaprootTweak : SchnorrTweak() {
/**
* private key is tweaked with H_TapTweak(public key) (this is used for key path spending when no scripts are present)
*/
public object NoScriptTweak : TaprootTweak()
public data object NoScriptTweak : TaprootTweak()

/**
* private key is tweaked with H_TapTweak(public key || merkle_root) (this is used for key path spending, with specific Merkle root of the script tree).
Expand Down
Loading

0 comments on commit ad3c6d9

Please sign in to comment.