Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release and snapshot workflows on CI #268

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,22 @@ jobs:
- uses: gradle/actions/setup-gradle@v4
- name: Execute Gradle build
run: ./gradlew build

publish-snapshot:
needs: build
runs-on: ubuntu-latest
if: github.repository_owner == 'melix' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: true
# Disable CC due to https://github.com/gradle/gradle/issues/22779
- run: ./gradlew publish --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '**'
Goooler marked this conversation as resolved.
Show resolved Hide resolved

jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'melix'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: true
# Disable CC due to https://github.com/gradle/gradle/issues/22779
- run: ./gradlew publish publishPlugins --no-configuration-cache
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_SECRET }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
Comment on lines +26 to +31
Copy link
Collaborator Author

@Goooler Goooler Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@Goooler Goooler Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can configure them for melix/japicmp-gradle-plugin#78 too.

- name: Create release
run: |
# Extract version from tag, e.g. RELEASE_1_2_3 -> 1.2.3
version=$(echo ${{ github.ref_name }} | sed -E 's/RELEASE_([0-9]+)_([0-9]+)_([0-9]+)/\1.\2.\3/')
echo "$version"

gh release create ${{ github.ref_name }} --title "$version" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ repositories {

dependencies {
implementation("com.gradle.publish:plugin-publish-plugin:1.2.1")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.29.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
* limitations under the License.
*/
import java.text.SimpleDateFormat
import java.util.Date
import java.util.*

plugins {
`maven-publish`
`java-gradle-plugin`
signing
id("com.gradle.plugin-publish")
id("com.vanniktech.maven.publish")
}

version = providers.gradleProperty("VERSION_NAME").get()
group = providers.gradleProperty("GROUP").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()

val buildTimeAndDate: Date by lazy {
if ((version as String).endsWith("SNAPSHOT")) {
Date(0)
Expand All @@ -45,10 +48,10 @@ tasks.jar {
"Build-Date" to buildDate,
"Build-Time" to buildTime,
// "Build-Revision" to versioning.info.commit,
"Specification-Title" to project.name,
"Specification-Version" to project.version,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
"Specification-Title" to name,
"Specification-Version" to version,
"Implementation-Title" to name,
"Implementation-Version" to version
)
}
metaInf {
Expand All @@ -58,69 +61,23 @@ tasks.jar {
}
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
name = "Gradle Plugin for JMH"
description = properties.getting("project_description")
url = properties.getting("project_website")
issueManagement {
system = "GitHub"
url = properties.getting("project_issues")
}
scm {
url = properties.getting("project_website")
connection = properties.getting("project_vcs").map { "scm:git:$it" }
developerConnection = "scm:git:git@github.com:melix/jmh-gradle-plugin.git"
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id = "melix"
name = "Cédric Champeau"
organization {
name = "Personal"
url = "https://melix.github.io/blog"
}
}
}
}
}
}
}

signing {
isRequired = gradle.taskGraph.allTasks.any {
it.name.startsWith("publish")
}
publishing.publications.configureEach {
sign(this)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
sign(configurations.archives.get())
useGpgCmd()
}

tasks.withType<Sign>().configureEach {
onlyIf { signing.isRequired }
withSourcesJar()
withJavadocJar()
}

gradlePlugin {
website = properties["project_website"].toString()
vcsUrl = properties["project_vcs"].toString()
website = providers.gradleProperty("POM_URL")
vcsUrl = providers.gradleProperty("POM_URL")

plugins.create("jmh") {
id = "me.champeau.jmh"
implementationClass = "me.champeau.jmh.JMHPlugin"
displayName = properties["project_description"].toString()
description = properties["project_description"].toString()
displayName = providers.gradleProperty("POM_NAME").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()
tags = listOf("jmh")
}
}
Expand Down
8 changes: 0 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ dependencies {
testImplementation("commons-io:commons-io:2.16.1")
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
withSourcesJar()
withJavadocJar()
}

jacoco {
toolVersion = "0.8.12"
}
Expand Down
33 changes: 25 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
group=me.champeau.jmh
version=0.7.3-SNAPSHOT

project_description=Integrates the JMH microbenchmarking framework with Gradle, providing conventional ways to setup sources and execute micro-benchmarks with JMH. Also known as the jmh-gradle-plugin.
project_website=https://github.com/melix/jmh-gradle-plugin
project_issues=https://github.com/melix/jmh-gradle-plugin/issues
project_vcs=https://github.com/melix/jmh-gradle-plugin.git

org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true


GROUP=me.champeau.jmh
POM_ARTIFACT_ID=jmh-gradle-plugin
VERSION_NAME=0.7.3-SNAPSHOT

SONATYPE_AUTOMATIC_RELEASE=true
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

POM_NAME=Gradle Plugin for JMH
POM_DESCRIPTION=Integrates the JMH microbenchmarking framework with Gradle, providing conventional ways to setup sources and execute micro-benchmarks with JMH. Also known as the jmh-gradle-plugin.
POM_URL=https://github.com/melix/jmh-gradle-plugin

POM_LICENSE_NAME=The Apache Software License, Version 2.0
Goooler marked this conversation as resolved.
Show resolved Hide resolved
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/melix/jmh-gradle-plugin
POM_SCM_CONNECTION=scm:git:git://github.com/melix/jmh-gradle-plugin.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/melix/jmh-gradle-plugin.git

POM_DEVELOPER_ID=melix
POM_DEVELOPER_NAME=C�dric Champeau
Goooler marked this conversation as resolved.
Show resolved Hide resolved
POM_DEVELOPER_URL=https://melix.github.io/blog