Skip to content

Commit 0faae65

Browse files
authored
Upgrade build and publishing scripts (#154)
Upgrade to Kotlin 2.1.21. Upgrade to secp256k1-kmp 0.18.0. Migrate publishing scripts from OSSRH to Central Publisher API.
1 parent 95e66f6 commit 0faae65

File tree

7 files changed

+45
-28
lines changed

7 files changed

+45
-28
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
path: ~/.gradle
3030
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
3131
restore-keys: ${{ runner.os }}-gradle-
32-
- name: Set up JDK 11
32+
- name: Set up JDK 21
3333
uses: actions/setup-java@v4
3434
with:
35-
java-version: 11
35+
java-version: 21
3636
distribution: 'adopt'
3737
- name: Check
3838
run: ./gradlew check

.github/workflows/snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ jobs:
3737
path: ~/.gradle
3838
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
3939
restore-keys: ${{ runner.os }}-gradle-
40-
- name: Set up JDK 11
40+
- name: Set up JDK 21
4141
uses: actions/setup-java@v4
4242
with:
43-
java-version: 11
43+
java-version: 21
4444
distribution: 'adopt'
4545
- name: Check
4646
run: ./gradlew check

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ jobs:
4444
path: ~/.gradle
4545
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
4646
restore-keys: ${{ runner.os }}-gradle-
47-
- name: Set up JDK 11
48-
uses: actions/setup-java@v2
47+
- name: Set up JDK 21
48+
uses: actions/setup-java@v4
4949
with:
50-
java-version: 11
50+
java-version: 21
5151
distribution: 'adopt'
5252
- name: Check
5353
run: ./gradlew check

build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
55
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
66

77
plugins {
8-
kotlin("multiplatform") version "2.1.10"
8+
kotlin("multiplatform") version "2.1.21"
99
id("org.jetbrains.dokka") version "1.9.20"
1010
`maven-publish`
1111
}
1212

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

1515
group = "fr.acinq.bitcoin"
16-
version = "0.24.0"
16+
version = "0.25.0"
1717

1818
repositories {
1919
google()
@@ -30,6 +30,11 @@ kotlin {
3030
}
3131
}
3232

33+
java {
34+
sourceCompatibility = JavaVersion.VERSION_1_8
35+
targetCompatibility = JavaVersion.VERSION_1_8
36+
}
37+
3338
linuxX64()
3439

3540
linuxArm64()
@@ -51,7 +56,7 @@ kotlin {
5156
}
5257

5358
sourceSets {
54-
val secp256k1KmpVersion = "0.17.3"
59+
val secp256k1KmpVersion = "0.18.0"
5560

5661
val commonMain by getting {
5762
dependencies {

publishing/bitcoin-kmp-staging-upload.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ if [[ -z "${VERSION}" ]]; then
99
exit 1
1010
fi
1111

12-
if [[ -z "${OSS_USER}" ]]; then
13-
echo "OSS_USER is not defined"
12+
if [[ -z "${CENTRAL_TOKEN_GPG_FILE}" ]]; then
13+
echo "CENTRAL_TOKEN_GPG_FILE is not defined"
1414
exit 1
1515
fi
1616

17-
read -p "Password : " -s OSS_PASSWORD
17+
CENTRAL_TOKEN=$(gpg --decrypt $CENTRAL_TOKEN_GPG_FILE)
1818

19+
pushd .
20+
cd release
1921
for i in bitcoin-kmp \
2022
bitcoin-kmp-iosarm64 \
2123
bitcoin-kmp-iossimulatorarm64 \
@@ -26,10 +28,20 @@ for i in bitcoin-kmp \
2628
bitcoin-kmp-macosarm64 \
2729
bitcoin-kmp-macosx64
2830
do
29-
pushd .
30-
cd release/fr/acinq/bitcoin/$i/$VERSION &&\
31-
pwd &&\
32-
jar -cvf bundle.jar *&&\
33-
curl -v -XPOST -u $OSS_USER:$OSS_PASSWORD --upload-file bundle.jar https://oss.sonatype.org/service/local/staging/bundle_upload
34-
popd
31+
DIR=fr/acinq/bitcoin/$i/$VERSION
32+
case $1 in
33+
create)
34+
for file in $DIR/*
35+
do
36+
sha1sum $file | sed 's/ .*//' > $file.sha1
37+
md5sum $file | sed 's/ .*//' > $file.md5
38+
gpg -ab $file
39+
done
40+
zip -r $i.zip $DIR
41+
;;
42+
upload)
43+
curl --request POST --verbose --header "Authorization: Bearer ${CENTRAL_TOKEN}" --form bundle=@$i.zip https://central.sonatype.com/api/v1/publisher/upload
44+
;;
45+
esac
3546
done
47+
popd

src/jvmTest/java/fr/acinq/bitcoin/crypto/CryptoJavaTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ public class CryptoJavaTests {
1111

1212
@Test
1313
public void sha1() {
14-
final var bytes = Digest.sha1().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
15-
final var hex = Hex.encode(bytes);
14+
final byte[] bytes = Digest.sha1().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
15+
final String hex = Hex.encode(bytes);
1616
assertEquals("8b6ccb43dca2040c3cfbcd7bfff0b387d4538c33", hex);
1717
}
1818

1919
@Test
2020
public void sha256() {
21-
final var bytes = Digest.sha256().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
22-
final var hex = Hex.encode(bytes);
21+
final byte[] bytes = Digest.sha256().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
22+
final String hex = Hex.encode(bytes);
2323
assertEquals("54ba1fdce5a89e0d3eee6e4c587497833bc38c3586ff02057dd6451fd2d6b640", hex);
2424
}
2525

2626
@Test
2727
public void sha512() {
28-
final var bytes = Digest.sha512().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
29-
final var hex = Hex.encode(bytes);
28+
final byte[] bytes = Digest.sha512().hash("This is a test!".getBytes(StandardCharsets.UTF_8));
29+
final String hex = Hex.encode(bytes);
3030
assertEquals("d4d6331e89ced845639272bc64ca3ef4e94a57c88431c61aef91f4399e30c6ada32c042f72cedad9cb1c7cfaf04d92e06ad044b557ca16f554f1c6d66b06d0e0", hex);
3131
}
3232

src/jvmTest/java/fr/acinq/bitcoin/crypto/Pbkdf2JavaTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ public class Pbkdf2JavaTests {
99

1010
@Test
1111
public void withHmacSha512() {
12-
final var password = Hex.decode("6162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e2061626f7574");
13-
final var salt = Hex.decode("6d6e656d6f6e6963");
14-
final var result = Pbkdf2.withHmacSha512(password, salt, 2048, 64);
12+
final byte[] password = Hex.decode("6162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e206162616e646f6e2061626f7574");
13+
final byte[] salt = Hex.decode("6d6e656d6f6e6963");
14+
final byte[] result = Pbkdf2.withHmacSha512(password, salt, 2048, 64);
1515
assertEquals("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4", Hex.encode(result));
1616
}
1717

0 commit comments

Comments
 (0)