Skip to content

Commit

Permalink
Prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Jul 30, 2024
1 parent 2c5ba18 commit 1302588
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 6 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy to central

on:
workflow_dispatch:
push:
tags:
- '**'

permissions:
contents: read

jobs:
build:
uses: ./.github/workflows/gradle.yml
deploy:
needs: build
strategy:
matrix:
include:
- target: publishIosArm64PublicationToSonatypeRepository --no-configuration-cache
os: macos-latest
- target: publishIosX64PublicationToSonatypeRepository --no-configuration-cache
os: macos-latest
- target: publishAndroidReleasePublicationToSonatypeRepository --no-configuration-cache
os: ubuntu-latest
- target: publishIosSimulatorArm64PublicationToSonatypeRepository --no-configuration-cache
os: macos-latest
- target: publishJvmPublicationToSonatypeRepository --no-configuration-cache
os: ubuntu-latest
# - target: publishLinuxX64PublicationToSonatypeRepository
# os: ubuntu-latest
- target: publishKotlinMultiplatformPublicationToSonatypeRepository --no-configuration-cache
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run Gradle publish
run: |
./gradlew \
${{ matrix.target }} \
closeSonatypeStagingRepository \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PtestSecret='${{ secrets.TEST_SECRET }}' \
-Psigning.gnupg.passphrase='${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}' \
-Psigning.gnupg.keyName='${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}'
50 changes: 50 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_call:

permissions:
contents: read

jobs:
build:
strategy:
matrix:
include:
# - target: iosSimulatorArm64Test
# os: macos-latest
- target: jvmTest
os: ubuntu-latest
# - target: linuxX64Test
# os: ubuntu-latest
# - target: testReleaseUnitTest
# os: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: ${{ matrix.target }}
- name: Upload Test Report
uses: actions/upload-artifact@v2
with:
name: test-results-${{ matrix.target }}
path: '**/build/test-results/**'
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("root.publication")
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
alias(libs.plugins.jetbrains.kotlin.multiplatform) apply false
}
1 change: 1 addition & 0 deletions convention-plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
8 changes: 8 additions & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.nexus.publish)
implementation(libs.bundles.plugins)
}
21 changes: 21 additions & 0 deletions convention-plugins/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}

dependencyResolutionManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
26 changes: 26 additions & 0 deletions convention-plugins/src/main/kotlin/VersionCatalogDsl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.ExternalModuleDependencyBundle
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
import org.gradle.plugin.use.PluginDependency

internal val Project.libs: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")

internal fun VersionCatalog.version(name: String): String {
return findVersion(name).get().requiredVersion
}

internal fun VersionCatalog.library(name: String): MinimalExternalModuleDependency {
return findLibrary(name).get().get()
}

internal fun VersionCatalog.plugin(name: String): PluginDependency {
return findPlugin(name).get().get()
}

internal fun VersionCatalog.bundle(name: String): ExternalModuleDependencyBundle {
return findBundle(name).get().get()
}
49 changes: 49 additions & 0 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`

plugins {
`maven-publish`
signing
}

publishing {
// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set(this@withType.name)
})

// Provide artifacts information required by Maven Central
pom {
name.set("RoboSpec")
description.set("This library enhances Compose Multiplatform by enabling the use of `rememberRetained{}`, which is stored within ViewModel. It broadens the versatility of Compose, allowing it to be utilized in a wider array of contexts and scenarios.")
url.set("https://github.com/takahirom/robospec")

licenses {
license {
name.set("Apache License 2.0")
url.set("https://opensource.org/licenses/Apache-2.0.html")
}
}
developers {
developer {
id.set("takahirom")
name.set("takahirom")
}
}
scm {
url.set("https://github.com/takahirom/robospec")
}
}
}
}

signing {
if (project.hasProperty("signing.gnupg.keyName")) {
useGpgCmd()
sign(publishing.publications)
}
}
19 changes: 19 additions & 0 deletions convention-plugins/src/main/kotlin/root.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("io.github.gradle-nexus.publish-plugin")
}

allprojects {
group = "io.github.takahirom.robospec"
version = "0.0.1"
}

nexusPublishing {
// Configure maven central repository
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
11 changes: 11 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ junitVersion = "1.2.1"
espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
nexus-publish = "2.0.0"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand All @@ -18,9 +19,19 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
# Robolectric
robolectric = { group = "org.robolectric", name = "robolectric", version = "4.13" }
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }

kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }


[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
jetbrains-kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }


[bundles]
plugins = [
"kotlin-gradle-plugin"
]
23 changes: 18 additions & 5 deletions robospec/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
plugins {
alias(libs.plugins.jetbrains.kotlin.jvm)
alias(libs.plugins.jetbrains.kotlin.multiplatform)
id("module.publication")
}

dependencies {
compileOnly(libs.coroutines)
testImplementation(libs.coroutines)
testImplementation(libs.junit)
kotlin {
jvm()
sourceSets {
val commonMain by getting {
dependencies {
compileOnly(libs.coroutines)
}
}
val jvmTest by getting {
dependencies {
implementation(libs.coroutines)
implementation(libs.junit)
}
}
}

}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pluginManagement {
includeBuild("convention-plugins")
repositories {
google {
content {
Expand Down

0 comments on commit 1302588

Please sign in to comment.