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 #78

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
21 changes: 20 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,26 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.jdk }}
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build "-Pme.champeau.japicmp.javaToolchain.test=${{ matrix.jdk }}"

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:
- '**'

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 }}
- 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 }}
5 changes: 5 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ repositories {
mavenCentral()
gradlePluginPortal()
}

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 @@ -6,6 +6,7 @@ val isCiBuild = providers.environmentVariable("CI").isPresent

tasks.withType<Test>().configureEach {
useJUnitPlatform()
inputs.dir("src/test/test-projects").withPropertyName("testProjects")

maxParallelForks = if (isCiBuild) {
Runtime.getRuntime().availableProcessors()
Expand Down
43 changes: 13 additions & 30 deletions build-logic/src/main/kotlin/me.champeau.convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,48 +1,31 @@
plugins {
id("groovy-gradle-plugin")
id("maven-publish")
id("signing")
`java-gradle-plugin`
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()

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}

tasks.named("test") {
inputs.dir("src/test/test-projects").withPropertyName("testProjects")
}

gradlePlugin {
website = "https://github.com/melix/japicmp-gradle-plugin"
vcsUrl = "https://github.com/melix/japicmp-gradle-plugin"
website = providers.gradleProperty("POM_URL")
vcsUrl = providers.gradleProperty("POM_URL")

plugins {
create("japicmpPlugin") {
id = "me.champeau.gradle.japicmp"
implementationClass = "me.champeau.gradle.japicmp.JapicmpPlugin"
displayName = "Gradle Plugin for JApicmp"
description = "Gradle Plugin for JApicmp"
displayName = providers.gradleProperty("POM_NAME").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()
tags = listOf("jacpicmp")
}
}
}

publishing {
repositories {
maven {
name = "build"
setUrl(layout.buildDirectory.file("repo").get().asFile.path)
}
}
}

signing {
useGpgCmd()
publishing.publications.forEach { pub ->
sign(pub)
}
}
28 changes: 25 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
group=me.champeau.gradle
version=0.4.4-SNAPSHOT

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


GROUP=me.champeau.gradle
POM_ARTIFACT_ID=japicmp-gradle-plugin
VERSION_NAME=0.4.4-SNAPSHOT

SONATYPE_AUTOMATIC_RELEASE=true
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

POM_NAME=Gradle Plugin for JApicmp
POM_DESCRIPTION=The japicmp-gradle-plugin provides binary compatibility reporting through JApicmp using Gradle.
POM_URL=https://github.com/melix/japicmp-gradle-plugin

POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

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

POM_DEVELOPER_ID=melix
POM_DEVELOPER_NAME=C�dric Champeau
POM_DEVELOPER_URL=https://melix.github.io/blog