Skip to content

Commit

Permalink
Build now creates a 'bundle.zip' file, which can be easily published …
Browse files Browse the repository at this point in the history
…to maven central repository.
  • Loading branch information
smyrgeorge committed Jan 20, 2024
1 parent dc429c6 commit cba8e3b
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 9 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: Maven Central
permissions:
contents: read
packages: write
Expand All @@ -28,7 +29,17 @@ jobs:
- name: Gradle Build
run: ./gradlew build

- name: Gradle Publish
run: ./gradlew publish
- name: Gradle Bundle
run: ./scripts/bundle.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_SIGNING_KEY: ${{ secrets.MAVEN_SIGNING_KEY }}
MAVEN_SIGNING_PASSWORD: ${{ secrets.MAVEN_SIGNING_PASSWORD }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: bundle
path: ./.gradle/bundle/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ So, with this example, we validate the cluster consistency.
Run the following script (it will also build the project).

```shell
./run.sh
./scripts/run.sh
```

The above script will do the following:
Expand Down
47 changes: 42 additions & 5 deletions actor4k/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`maven-publish`
`java-library`
signing
kotlin("jvm")
kotlin("plugin.serialization")
// https://plugins.gradle.org/plugin/com.google.protobuf
Expand Down Expand Up @@ -67,29 +68,65 @@ dependencies {
}

java {
withJavadocJar()
withSourcesJar()
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/smyrgeorge/actor4k")
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}

publications {
val archivesBaseName = tasks.jar.get().archiveBaseName.get()
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactId = tasks.jar.get().archiveBaseName.get()
artifactId = archivesBaseName
pom {
name = archivesBaseName
packaging = "jar"
description = "A small actor system written in kotlin using Coroutines (kotlinx.coroutines)."
url = "https://github.com/smyrgeorge/actor4k"

scm {
url = "https://github.com/smyrgeorge/actor4k"
connection = "scm:git:https://github.com/smyrgeorge/actor4k.git"
developerConnection = "scm:git:git@github.com:smyrgeorge/actor4k.git"
}

licenses {
license {
name = "MIT License"
url = "https://github.com/smyrgeorge/actor4k/blob/main/LICENSE"
}
}

developers {
developer {
name = "Yorgos S."
email = "smyrgoerge@gmail.com"
url = "https://smyrgeorge.github.io/"
}
}
}
}
}
}

signing {
val signingKey = System.getenv("MAVEN_SIGNING_KEY")
val signingPassword = System.getenv("MAVEN_SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

tasks.withType<KotlinCompile> {
kotlinOptions {
// Use "-Xcontext-receivers" to enable context receivers.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "io.github.smyrgeorge"
version = "0.3.4"
version = "0.3.6"

// https://mvnrepository.com/artifact/io.grpc/grpc-api
val grpcVersion: String by extra { "1.60.1" }
Expand Down
33 changes: 33 additions & 0 deletions scripts/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

set -e

MAVEN_PROJECT=$(/bin/cat < settings.gradle.kts | grep 'rootProject.name =' | cut -d= -f2 | awk '{ print substr( $0, 3, length($0)-3 ) }')
MAVEN_GROUP=$(/bin/cat < build.gradle.kts | grep 'group =' | cut -d= -f2 | awk '{ print substr( $0, 3, length($0)-3 ) }')
MAVEN_VERSION=$(/bin/cat < build.gradle.kts | grep 'version =' | cut -d= -f2 | awk '{ print substr( $0, 3, length($0)-3 ) }')
MAVEN_PATH=$(echo "$MAVEN_GROUP" | tr . / | awk '{print $1"/'"$MAVEN_PROJECT"'"}'"$1")

./gradlew publishToMavenLocal

mkdir -p .gradle/bundle && cd .gradle/bundle || exit

cp -R ~/.m2/repository/"$MAVEN_PATH"/"$MAVEN_VERSION"/* ./

rm -rf ./*.module*
for file in ./*; do md5sum "$file" | awk '{print $1}' > "$file".md5; done
for file in ./*; do sha1sum "$file" | awk '{print $1}' > "$file".sha1; done
rm -rf ./*.md5.sha1

mkdir -p "$MAVEN_PATH"/"$MAVEN_VERSION"
cp -R ./actor4k-"$MAVEN_VERSION"* ./"$MAVEN_PATH"/"$MAVEN_VERSION"

rm -rf ./actor4k*
rm -rf bundle-"$MAVEN_VERSION".zip
zip -r bundle-"$MAVEN_VERSION".zip io

rm -rf io
rm -rf coordinates-"$MAVEN_VERSION".txt
echo "$MAVEN_GROUP":"$MAVEN_PROJECT":"$MAVEN_VERSION" > coordinates-"$MAVEN_VERSION".txt

rm -rf ./bundle*.md5* && rm -rf ./bundle*.sha1*
rm -rf ./coordinates*.md5* && rm -rf ./coordinates*.sha1*
File renamed without changes.

0 comments on commit cba8e3b

Please sign in to comment.