Skip to content

Commit

Permalink
Implement publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Apr 11, 2024
1 parent 7c7bbbf commit 858ed0a
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- run: .scripts/github/release.sh
jvm:
runs-on: macos-14-xlarge
needs: [ release ]
steps:
- uses: actions/[email protected]
- 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/[email protected]
- run: echo TODO
8 changes: 8 additions & 0 deletions .idea/artifacts/library_jvm_0_0_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .scripts/github/release.sh
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .scripts/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -e
usage() {
echo "Usage: $0 -v <version>" >&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"
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
47 changes: 46 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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<MavenPublication>("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://[email protected]/tidal-music/network-time.git")
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 858ed0a

Please sign in to comment.