Skip to content

Commit

Permalink
Progress on CI overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
mockitoguy committed May 9, 2021
1 parent bc93f41 commit 587b78e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 83 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -80,7 +80,7 @@ jobs:

steps:

- name: Check out code
- name: Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
Expand All @@ -91,11 +91,9 @@ jobs:
distribution: 'adopt'
java-version: 8

- name: Build and publish to Bintray/MavenCentral
- name: Build and release
run: ./gradlew bintrayUpload githubRelease --scan
env:
MAVEN_CENTRAL_RELEASE: ${{contains(toJSON(github.event.commits.*.message), '[ci maven-central-release]')}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
BINTRAY_API_KEY: ${{secrets.BINTRAY_API_KEY}}
NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -10,9 +10,8 @@ Most popular mocking framework for Java
[![Coverage Status](https://img.shields.io/codecov/c/github/mockito/mockito.svg)](https://codecov.io/github/mockito/mockito)
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/mockito/mockito/blob/release/3.x/LICENSE)

[![Release Notes](https://img.shields.io/badge/release%20notes-3.x-yellow.svg)](https://github.com/mockito/mockito/blob/release/3.x/doc/release-notes/official.md)
[![Release Notes](https://img.shields.io/badge/release%20notes-3.x-yellow.svg)](https://github.com/mockito/mockito/releases/)
[![Maven Central](https://img.shields.io/maven-central/v/org.mockito/mockito-core.svg)](https://search.maven.org/artifact/org.mockito/mockito-core/)
[![Bintray](https://img.shields.io/bintray/v/mockito/maven/mockito-development)](https://bintray.com/mockito/maven/mockito/_latestVersion)
[![Javadoc](https://www.javadoc.io/badge/org.mockito/mockito-core.svg)](https://www.javadoc.io/doc/org.mockito/mockito-core)


Expand All @@ -23,15 +22,25 @@ Still on Mockito 1.x? See [what's new](https://github.com/mockito/mockito/wiki/W

Available as part of the Tidelift Subscription

The maintainers of org.mockito:mockito-core and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/maven-org-mockito-mockito-core?utm_source=maven-org-mockito-mockito-core&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
The maintainers of org.mockito:mockito-core and thousands of other packages are working with Tidelift to deliver
commercial support and maintenance for the open source dependencies you use to build your applications. Save time,
reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
[Learn more.](https://tidelift.com/subscription/pkg/maven-org-mockito-mockito-core?utm_source=maven-org-mockito-mockito-core&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## Development

Mockito [continuously delivers](https://github.com/mockito/mockito/wiki/Continuous-Delivery-Overview) improvements using Shipkit library (http://shipkit.org). See the [latest release notes](https://github.com/mockito/mockito/blob/release/3.x/doc/release-notes/official.md) and [latest documentation](https://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html). Docs in javadoc.io are available 24h after release. Read also about [semantic versioning in Mockito](https://github.com/mockito/mockito/wiki/Semantic-Versioning). **Note: not every version is published to Maven Central.**
Mockito publishes every change as a `-SNAPSHOT` version to a public Sonatype repository. Roughly once a month, we
publish a new minor or patch version to Maven Central. For release automation we use Shipkit
library (http://shipkit.org), Gradle Nexus [Publish Plugin](https://github.com/gradle-nexus/publish-plugin), and
Allegro's [Axion Release Plugin](https://github.com/allegro/axion-release-plugin). Fully automated releases are awesome,
and you should do that for your libraries, too!
See the [latest release notes](https://github.com/mockito/mockito/releases/)
and [latest documentation](https://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html). Docs in
javadoc.io are available 24h after release. Read also
about [semantic versioning in Mockito](https://github.com/mockito/mockito/wiki/Semantic-Versioning).

Older 1.x and 2.x releases are available in
[Central Repository](https://search.maven.org/artifact/org.mockito/mockito-core/1.10.19/jar)
, [Bintray](https://bintray.com/mockito/maven/mockito/1.10.19/view)
and [javadoc.io](https://javadoc.io/doc/org.mockito/mockito-core/1.10.19/org/mockito/Mockito.html) (documentation).

## More information
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Expand Up @@ -9,10 +9,8 @@ buildscript {
classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:2.0.1'

//Using buildscript.classpath so that we can resolve plugins from maven local, during local testing
classpath "org.shipkit:shipkit-auto-version:1.1.9"
classpath "org.shipkit:shipkit-changelog:1.1.15"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
classpath "org.shipkit:shipkit-auto-version:1.+"
classpath "org.shipkit:shipkit-changelog:1.+"

classpath 'com.google.googlejavaformat:google-java-format:1.10.0'
}
Expand Down
38 changes: 0 additions & 38 deletions gradle/java-publication.gradle
Expand Up @@ -90,41 +90,3 @@ publishing {

//fleshes out problems with Maven pom generation when building
tasks.build.dependsOn("publishJavaLibraryPublicationToMavenLocal")

//Bintray Gradle plugin configuration (https://github.com/bintray/gradle-bintray-plugin)
//Plugin jars are added to the buildscript classpath in the root build.gradle file
apply plugin: "com.jfrog.bintray"

bintray {
//We need to use some user id here, because the Bintray key is associated with the user
//However, any user id is good, so longer the user has necessary privileges to the repository
user = 'szczepiq' //https://bintray.com/szczepiq
key = System.getenv('BINTRAY_API_KEY')
publish = true //can be changed to 'false' for testing
dryRun = project.hasProperty("bintrayDryRun")
publications = ['javaLibrary']

pkg {
repo = 'maven' //https://bintray.com/mockito/maven
userOrg = 'mockito' //https://bintray.com/mockito

//See our Bintray packages at https://bintray.com/mockito/maven
name = project.rootProject.ext.mavenCentralRelease? "mockito" : "mockito-development"

licenses = ['MIT']
labels = ['mocks', 'tdd', 'unit tests']
vcsUrl = "https://github.com/mockito/mockito.git"

version {
name = project.version
vcsTag = "v$project.version"

//Notable versions are automatically synced to Maven Central repository (https://oss.sonatype.org/)
mavenCentralSync {
sync = project.rootProject.ext.mavenCentralRelease
user = System.env.NEXUS_TOKEN_USER
password = System.env.NEXUS_TOKEN_PWD
}
}
}
}
36 changes: 4 additions & 32 deletions gradle/shipkit.gradle
Expand Up @@ -16,41 +16,13 @@ tasks.named("githubRelease") {
githubToken = System.getenv("GITHUB_TOKEN")
}

/**
* Mockito team does not publish to Maven Central every release as requested by the community.
* We publish to maven central only some versions. All versions are published to Bintray on every change.
* See https://github.com/mockito/mockito/issues/911
*/
ext.mavenCentralRelease = shouldReleaseToCentral(project)

/**
* Finds out if we should release to Maven Central.
* To test this logic, run build with '-i' (info logging) and inspect the build output.
*/
static boolean shouldReleaseToCentral(project) {
boolean centralReleaseByCommit = 'true' == System.getenv("MAVEN_CENTRAL_RELEASE")
boolean centralReleaseByProjectProperty = project.hasProperty("maven-central-release")
boolean centralRelease = centralReleaseByCommit || centralReleaseByProjectProperty
def message = """Bintray publish was using following settings:
- commit message contains '[ci maven-central-release]': $centralReleaseByCommit
- project property 'maven-central-release' exists: $centralReleaseByProjectProperty
- Maven Central release is enabled: $centralRelease"""
project.logger.info(message)
project.afterEvaluate {
project.tasks.bintrayPublish.doLast { logger.lifecycle(message) }
}
return centralRelease
}

//TODO: remove bintray and rename this file to release.gradle
if (version.endsWith("-SNAPSHOT")) {
tasks.named("githubRelease") {
//snapshot versions do not produce changelog / GitHub releases
enabled = false
}
//TODO enable below when nexus publish plugin is applied
// tasks.named("closeAndReleaseStagingRepository") {
// //snapshot binaries are available in Sonatype without the need to close the staging repo
// enabled = false
// }
tasks.named("closeAndReleaseStagingRepository") {
//snapshot binaries are available in Sonatype without the need to close the staging repo
enabled = false
}
}

0 comments on commit 587b78e

Please sign in to comment.