Skip to content

Commit

Permalink
maven central release
Browse files Browse the repository at this point in the history
  • Loading branch information
fbzli committed Oct 1, 2024
1 parent 3cb4d45 commit e3e0c06
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Example
on: [ push, workflow_dispatch ]

jobs:
publish:
build:
runs-on: ubuntu-latest
steps:
# Checkout repository
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Plugin to Portal
name: Publish to Maven Central

on:
push:
Expand All @@ -7,15 +7,18 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
gradle:
publish:
runs-on: ubuntu-latest
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PLUGIN_PORTAL_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PLUGIN_PORTAL_PUBLISH_SECRET }}
steps:
- name: Checkout Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'
- name: Grant permission to execute
run: chmod +x gradlew
- name: Publish on Plugin Portal
run: ./gradlew --project-dir preset setupPluginUploadFromEnvironment publishPlugins -PgithubRefName=${{ github.ref_name }}
- name: Upload
run: |
echo "${{secrets.MAVEN_SIGNING_KEY_ARMOR_ASC}}" > ./signingkey.asc
gpg --quiet --output $GITHUB_WORKSPACE/signingkey.gpg --dearmor ./signingkey.asc
./gradlew :preset:plugin:publishAndReleaseToMavenCentral -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/signingkey.gpg -Psigning.password='${{secrets.MAVEN_SIGNING_KEY_PASSPHRASE}}' -Psigning.keyId=${{secrets.MAVEN_SIGNING_KEY_ID}} -PmavenCentralUsername=${{secrets.MAVEN_CENTRAL_USERNAME}} -PmavenCentralPassword=${{secrets.MAVEN_CENTRAL_PASSWORD}} -PgithubRefName=${{ github.ref_name }}
2 changes: 1 addition & 1 deletion appexample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "0.0.1"
versionName = project.version.toString()

testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
23 changes: 6 additions & 17 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
[versions]
agp = "8.6.1"
kotlin = "2.0.20"
pluginPublish = "1.2.2"
coroutines = "1.8.1"
okhttp = "4.12.0"
retrofit = "2.11.0"
moshi = "1.15.1"
agp = "8.6.1"
jfrog-artifactory = "5.1.10"
vanniktech = "0.29.0"

androidx-appcompat = "1.7.0"
androidx-lifecycle = "2.8.6"
Expand All @@ -16,20 +12,13 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "pluginPublish"}
androidApplication = { id = "com.android.application", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jfrog-artifactory = { id = "com.jfrog.artifactory", version.ref = "jfrog-artifactory" }
vanniktech = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }

[libraries]
junit = "junit:junit:4.13.2"

coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp"}
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit"}
retrofitConverterScalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "retrofit"}
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi"}
moshiKotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi"}
moshiAdapters = { module = "com.squareup.moshi:moshi-adapters", version.ref = "moshi"}
agp = { module = "com.android.tools.build:gradle", version.ref = "agp"}
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin"}

androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-lifecycle-viewmodelKtx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin"}

junit = "junit:junit:4.13.2"
1 change: 0 additions & 1 deletion preset/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.pluginPublish) apply false
alias(libs.plugins.jfrog.artifactory) apply false
}

allprojects {
Expand Down
29 changes: 25 additions & 4 deletions preset/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@ GROUP=ch.ubique.gradle
ARTIFACT_ID=preset
# VERSION will only be used if no property "githubRefName" is set (which the release workflow does)
VERSION=0.0.0
DISPLAY_NAME=Ubique Preset
DESCRIPTION=Provides default Gradle configurations and utility methods for Android app projects.
WEBSITE=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android
VCS_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android
IMPLEMENTATION_CLASS=ch.ubique.gradle.preset.PresetPlugin

# POM metadata
POM_NAME=preset
POM_PACKAGING=jar
POM_DESCRIPTION=Provides default Gradle configurations and utility methods for Android app projects.
POM_INCEPTION_YEAR=2024

# POM URLs
POM_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android
POM_SCM_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android
POM_SCM_CONNECTION=scm:[email protected]:UbiqueInnovation/gradle-plugin-ubique-preset-android.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:UbiqueInnovation/gradle-plugin-ubique-preset-android.git

# License information
POM_LICENCE_NAME=License
POM_LICENCE_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android/blob/main/LICENSE
POM_LICENCE_DIST=repo

# Developer information
POM_DEVELOPER_ID=UbiqueInnovation
POM_DEVELOPER_NAME=Ubique Innovation
POM_DEVELOPER_URL=https://www.ubique.ch/

# Sonatype metadata
SONATYPE_STAGING_PROFILE=ch.ubique
70 changes: 27 additions & 43 deletions preset/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,64 +1,48 @@
import com.vanniktech.maven.publish.GradlePublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
`java-gradle-plugin`
alias(libs.plugins.pluginPublish)
alias(libs.plugins.jfrog.artifactory)
kotlin("jvm")
`java-gradle-plugin`
alias(libs.plugins.pluginPublish)
alias(libs.plugins.vanniktech)
}

dependencies {
implementation(kotlin("stdlib"))
implementation(gradleApi())
implementation(kotlin("stdlib"))
implementation(gradleApi())

implementation(libs.agp)
implementation(libs.kotlin.gradle)
implementation(libs.agp)
implementation(libs.kotlin.gradle)

implementation(libs.coroutines)
implementation(libs.okhttp)
implementation(libs.retrofit)
implementation(libs.retrofitConverterScalars)
implementation(libs.moshi)
implementation(libs.moshiKotlin)
implementation(libs.moshiAdapters)

testImplementation(libs.junit)
testImplementation(libs.junit)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget = JvmTarget.JVM_17
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
compilerOptions.jvmTarget = JvmTarget.JVM_17
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
}

gradlePlugin {
plugins {
create(property("ID").toString()) {
id = property("ID").toString()
implementationClass = property("IMPLEMENTATION_CLASS").toString()
version = project.version
description = property("DESCRIPTION").toString()
displayName = property("DISPLAY_NAME").toString()
tags = listOf("android", "ubique")
}
}
website.set(property("WEBSITE").toString())
vcsUrl.set(property("VCS_URL").toString())
plugins {
create(property("ID").toString()) {
id = property("ID").toString()
implementationClass = property("IMPLEMENTATION_CLASS").toString()
version = project.version
}
}
}

tasks.create("setupPluginUploadFromEnvironment") {
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
val secret = System.getenv("GRADLE_PUBLISH_SECRET")
if (key == null || secret == null) {
throw GradleException("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables")
}
System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
}
mavenPublishing {
configure(GradlePublishPlugin())
coordinates(property("GROUP").toString(), property("ARTIFACT_ID").toString(), project.version.toString())
publishToMavenCentral(SonatypeHost.S01, true)
signAllPublications()
}
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ dependencyResolutionManagement {
}
}

rootProject.name = "gradle-plugin-preset-android"

include("appexample")
includeBuild("preset")

0 comments on commit e3e0c06

Please sign in to comment.