diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 00000000..8b902b6b
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,27 @@
+name: Publish
+on:
+ release:
+ types: [ published ]
+env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+jobs:
+ release:
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v3.5.3
+ - run: .scripts/github/release.sh
+ jvm:
+ runs-on: macos-14-xlarge
+ needs: [ release ]
+ steps:
+ - uses: actions/checkout@v3.5.3
+ - uses: ./.github/actions/runGradleTask
+ with:
+ preTaskString: -Pversion=$GITHUB_REF_NAME
+ task: library:publishKotlinMultiplatformPublicationToGithubPackagesRepository --continue
+ apple:
+ runs-on: macos-14-xlarge
+ needs: [ release ]
+ steps:
+ - uses: actions/checkout@v3.5.3
+ - run: echo TODO
diff --git a/.idea/artifacts/library_jvm_0_0_0_SNAPSHOT.xml b/.idea/artifacts/library_jvm_0_0_0_SNAPSHOT.xml
new file mode 100644
index 00000000..dc30dbec
--- /dev/null
+++ b/.idea/artifacts/library_jvm_0_0_0_SNAPSHOT.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/library/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.scripts/github/release.sh b/.scripts/github/release.sh
new file mode 100755
index 00000000..491a8948
--- /dev/null
+++ b/.scripts/github/release.sh
@@ -0,0 +1,14 @@
+BODY="{
+ \"tag_name\": \"${GITHUB_REF_NAME}\",
+ \"target_commitish\": \"${GITHUB_SHA}\",
+ \"name\": \"${GITHUB_REF_NAME}\",
+ \"body\": \"$(cat ../../changelog/"$GITHUB_REF_NAME")\"
+ }"
+
+curl -s \
+ -u "${GITHUB_ACTOR}":"${GITHUB_TOKEN}" \
+ --header "Accept: application/vnd.github.v3+json" \
+ --header "Content-Type: application/json; charset=utf-8" \
+ --request POST \
+ --data "${BODY}" \
+ https://api.github.com/repos/"${GITHUB_REPOSITORY}"/releases
diff --git a/.scripts/tag.sh b/.scripts/tag.sh
new file mode 100755
index 00000000..4bc6ab9c
--- /dev/null
+++ b/.scripts/tag.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+set -e
+usage() {
+ echo "Usage: $0 -v " >&2
+ exit 1
+}
+
+VERSION=""
+
+if [ -n "$(git status --porcelain)" ]; then
+ echo "Cannot tag from a dirty working tree"
+ exit 1
+fi
+
+while getopts ":v" opt; do
+ case $opt in
+ v)
+ VERSION=$OPTARG
+ ;;
+ \?)
+ echo "Invalid option: -$OPTARG" >&2
+ exit 1
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+if [ -z "$VERSION" ]; then
+ usage
+fi
+
+FILE_CHANGELOG="changelog/$VERSION"
+if [ ! -f "$FILE_CHANGELOG" ]; then
+ echo "Changelog file $FILE_CHANGELOG missing"
+fi
+
+git fetch &&
+ git tag "${VERSION}" "HEAD" -m "${VERSION}" &&
+ git push --tags &&
+ echo "New release ${VERSION} for revision $(git rev-parse --short "HEAD") requested successfully"
diff --git a/build.gradle.kts b/build.gradle.kts
index 6cfd5f90..9bdb5845 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,6 +5,7 @@ buildscript {
}
dependencies {
val kotlinVersion = "1.9.20"
+ classpath("org.jetbrains.dokka:dokka-gradle-plugin:$kotlinVersion")
classpath(kotlin("gradle-plugin", version = kotlinVersion))
classpath(kotlin("serialization", version = kotlinVersion))
classpath("com.android.tools.build:gradle:8.1.4")
diff --git a/library/build.gradle.kts b/library/build.gradle.kts
index 3aa263fe..562f335b 100644
--- a/library/build.gradle.kts
+++ b/library/build.gradle.kts
@@ -1,9 +1,14 @@
+import org.gradle.jvm.tasks.Jar
+import java.net.URI
+
plugins {
+ id("org.jetbrains.dokka")
+ id("maven-publish")
kotlin("multiplatform")
kotlin("plugin.serialization")
}
-group = "com.tidal.network-time"
+group = "com.tidal.networktime"
kotlin {
jvm()
@@ -36,3 +41,43 @@ kotlin {
}
}
}
+
+val htmlDoc by tasks.registering(Jar::class) {
+ dependsOn(tasks.dokkaHtml)
+ archiveClassifier = "documentation"
+ from(layout.buildDirectory.dir("dokka").get().dir("html"))
+}
+
+publishing {
+ repositories {
+ maven {
+ name = "GithubPackages"
+ url = URI.create("https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY")}")
+ credentials {
+ username = System.getenv("GITHUB_ACTOR")
+ password = System.getenv("GITHUB_TOKEN")
+ }
+ }
+ }
+ publications {
+ getByName("kotlinMultiplatform") {
+ pom {
+ artifact(htmlDoc)
+ inceptionYear.set("2023")
+ url.set("https://github.com/tidal-music/network-time")
+ licenses {
+ license {
+ name.set("The Apache License, Version 2.0")
+ url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
+ distribution.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
+ }
+ }
+ scm {
+ url.set("https://github.com/tidal-music/network-time")
+ connection.set("scm:git:https://github.com/tidal-music/network-time.git")
+ developerConnection.set("scm:git:ssh://git@github.com/tidal-music/network-time.git")
+ }
+ }
+ }
+ }
+}
diff --git a/library/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt b/library/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt
index ca0b6404..daa6c1f7 100644
--- a/library/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt
+++ b/library/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt
@@ -7,7 +7,7 @@ import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
/**
- * Construct a new SNTP client that can be requested to periodically interact with the provided
+ * Constructs a new SNTP client that can be requested to periodically interact with the provided
* [ntpServers] to obtain information about their provided time.
*
* @param ntpServers Representation of supported unicast NTP sources.