Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 42640d2

Browse files
committedNov 26, 2024·
Add release actions & publish plugins
1 parent f4028dc commit 42640d2

File tree

3 files changed

+134
-4
lines changed

3 files changed

+134
-4
lines changed
 

‎.github/workflows/release.yml

+36-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Rename and prepare assets
3434
run: |
3535
cd ./cli/build/libs
36-
mv cli-all.jar app-sizer-cli-${{ env.VERSION }}.jar
36+
mv cli-app-sizer.jar app-sizer-cli-${{ env.VERSION }}.jar
3737
sha256sum app-sizer-cli-${{ env.VERSION }}.jar > app-sizer-cli-${{ env.VERSION }}.jar.sha256
3838
3939
- name: Upload CLI JAR
@@ -58,12 +58,45 @@ jobs:
5858

5959
release-plugin:
6060
runs-on: ubuntu-latest
61+
permissions:
62+
contents: write
63+
packages: write
64+
6165
steps:
6266
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
6370
- name: Set up JDK 11
6471
uses: actions/setup-java@v4
6572
with:
6673
distribution: "zulu"
6774
java-version: "11"
68-
- name: Publish plugin to Artifactory
69-
run: ./gradlew artifactoryPublish
75+
cache: 'gradle'
76+
77+
- name: Get version
78+
id: get_version
79+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
80+
81+
- name: Import GPG key
82+
uses: crazy-max/ghaction-import-gpg@v5
83+
with:
84+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
85+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
86+
87+
- name: Validate Gradle wrapper
88+
uses: gradle/wrapper-validation-action@v1
89+
90+
- name: Publish to Maven Central
91+
env:
92+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
93+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
94+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
95+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
96+
VERSION: ${{ env.VERSION }}
97+
run: |
98+
./gradlew :gradle-plugin:publish \
99+
-Pversion=${VERSION} \
100+
--no-daemon \
101+
--no-parallel \
102+
--stacktrace

‎build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ plugins {
3737
alias(libs.plugins.kotlin.jvm) apply false
3838
alias(libs.plugins.kotlin.kapt) apply false
3939
alias(libs.plugins.johnrengelman.shadow) apply false
40+
alias(libs.plugins.gradle.plugin.publish) apply false
4041
}
4142

‎gradle-plugin/build.gradle

+97-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ plugins {
3838
id "com.grab.sizer.kotlin"
3939
id 'java-gradle-plugin'
4040
alias(libs.plugins.kotlin.dsl)
41+
alias(libs.plugins.gradle.plugin.publish)
42+
id 'maven-publish'
43+
id 'signing'
4144
}
4245

46+
group = 'com.grab.sizer'
47+
version = '1.0.0-SNAPSHOT'
48+
4349
dependencies {
4450
compileOnly libs.android.gradle.plugin
4551
compileOnly libs.android.gradle.api
@@ -55,13 +61,103 @@ dependencies {
5561
testImplementation libs.android.gradle.api
5662
}
5763

64+
java {
65+
withJavadocJar()
66+
withSourcesJar()
67+
}
68+
5869
gradlePlugin {
70+
website = 'https://grab.github.io/app-sizer/'
71+
vcsUrl = 'https://github.com/grab/app-sizer.git'
72+
5973
plugins {
6074
appSizerPlugin {
6175
id = 'com.grab.sizer'
6276
implementationClass = 'com.grab.plugin.sizer.AppSizerPlugin'
63-
displayName = "app-sizer-plugin"
77+
displayName = 'App Sizer Plugin'
78+
description = 'A tool designed to analyze the download size of Android applications'
79+
tags.set(['android', 'size', 'analysis', 'app-size'])
6480
}
6581
}
6682
}
6783

84+
def configurePom(pom) {
85+
pom.with {
86+
name = 'App Sizer'
87+
description = 'A tool designed to analyze the download size of Android applications'
88+
url = 'https://github.com/grab/app-sizer'
89+
90+
licenses {
91+
license {
92+
name = 'MIT License'
93+
url = 'https://opensource.org/licenses/MIT'
94+
distribution = 'repo'
95+
}
96+
}
97+
98+
developers {
99+
developer {
100+
id = 'grab'
101+
name = 'Grab Engineers'
102+
email = 'van.minh@grab.com'
103+
organization = 'Grab'
104+
organizationUrl = 'https://github.com/grab'
105+
}
106+
}
107+
108+
scm {
109+
connection = 'scm:git:git://github.com/grab/app-sizer.git'
110+
developerConnection = 'scm:git:ssh://github.com:grab/app-sizer.git'
111+
url = 'https://github.com/grab/app-sizer'
112+
}
113+
}
114+
}
115+
116+
publishing {
117+
publications.withType(MavenPublication).configureEach { publication ->
118+
if (publication.name == 'pluginMaven') {
119+
publication.artifactId = 'sizer-gradle-plugin' // Set the artifact ID
120+
}
121+
configurePom(publication.pom)
122+
}
123+
124+
repositories {
125+
maven {
126+
name = 'sonatype'
127+
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
128+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
129+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
130+
131+
credentials {
132+
username = findProperty('ossrhUsername') ?: System.getenv('OSSRH_USERNAME')
133+
password = findProperty('ossrhPassword') ?: System.getenv('OSSRH_PASSWORD')
134+
}
135+
}
136+
}
137+
}
138+
139+
signing {
140+
def signingKey = findProperty('signingKey') ?: System.getenv('GPG_PRIVATE_KEY')
141+
def signingPassword = findProperty('signingPassword') ?: System.getenv('GPG_PASSPHRASE')
142+
143+
useInMemoryPgpKeys(signingKey, signingPassword)
144+
sign publishing.publications
145+
}
146+
147+
// Fixed task ordering
148+
tasks.withType(AbstractPublishToMaven).configureEach { publishTask ->
149+
publishTask.mustRunAfter(tasks.withType(Sign))
150+
}
151+
152+
tasks.withType(Sign).configureEach { signTask ->
153+
signTask.onlyIf { !version.endsWith('SNAPSHOT') }
154+
tasks.withType(AbstractPublishToMaven).forEach {
155+
it.dependsOn(signTask)
156+
}
157+
}
158+
159+
tasks.register('publishAll') {
160+
group = 'publishing'
161+
description = 'Publishes all publications to all repositories'
162+
dependsOn(tasks.withType(AbstractPublishToMaven))
163+
}

0 commit comments

Comments
 (0)
Please sign in to comment.