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

Added CI + Bintray releases #402

Merged
merged 9 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#
# CI build that assembles artifacts and runs tests.
# If validation is successful this workflow releases from the main dev branch.
#
# - skipping CI: add [skip ci] to the commit message
# - skipping release: add [skip release] to the commit message
#
name: CI

on:
push:
branches:
- main
tags-ignore:
- v* # release tags are automatically generated after a successful CI build, no need to run CI against them
pull_request:
branches:
- main

jobs:

#
# SINGLE-JOB
#
verify:
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

steps:

- name: 1. Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout

- name: 2. Set up Java 8
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
with:
java-version: 8

- name: 3. Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1 # https://github.com/gradle/wrapper-validation-action

#
# Main build job
#
build:
needs: [verify]
runs-on: ubuntu-latest

# Definition of the build matrix
strategy:
matrix:
mock-maker: ['mock-maker-default', 'mock-maker-inline']
kotlin: ['1.3.50', '1.4.21']
# Note that the old Travis CI referenced other Kotlin versions: '1.0.7', '1.1.61', '1.2.50'
# However, those versions of Kotlin don't work with latest Gradle

steps:

- name: 1. Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout

- name: 2. Set up Java 8
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
with:
java-version: 8

- name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
run: |
ops/mockMakerInline.sh
./gradlew build bintrayUpload -PbintrayDryRun
env:
KOTLIN_VERSION: ${{ matrix.kotlin }}
MOCK_MAKER: ${{ matrix.mock-maker }}

#
# Release job, only for pushes to the main development branch
#
release:
runs-on: ubuntu-latest
needs: [build] # build job must pass before we can release

if: github.event_name == 'push'
&& github.ref == 'refs/heads/main'
&& github.repository == 'mockito/mockito-kotlin'
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')

steps:

- 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

- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Build and publish to Bintray/MavenCentral
run: ./gradlew tasks # TODO, in progress: bintrayUpload githubRelease
env:
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}}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.gradle
build/
out/
repo

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

29 changes: 16 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.spring.gradle:spring-bintray-plugin:0.11.1"
}
plugins {
id "org.shipkit.shipkit-auto-version" version "1.1.1"
id "org.shipkit.shipkit-changelog" version "1.1.1"
id "org.shipkit.shipkit-github-release" version "1.1.1"
}

plugins {
id 'com.github.ben-manes.versions' version '0.20.0'
tasks.named("generateChangelog") {
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
githubToken = System.getenv("GITHUB_TOKEN")
repository = "mockito/mockito-kotlin"
}

apply from: 'gradle/scripts/tagging.gradle'
tasks.named("githubRelease") {
def genTask = tasks.named("generateChangelog").get()
dependsOn genTask
repository = genTask.repository
changelog = genTask.outputFile
githubToken = System.getenv("GITHUB_TOKEN")
newTagRevision = System.getenv("GITHUB_SHA")
}

println ext.versionName
101 changes: 101 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
apply plugin: 'maven-publish'

//TODO: update the group to 'org.mockito' ***AND*** change java packages
group = 'com.nhaarman.mockitokotlin2'

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/javadoc'
}

task sourceJar(type: Jar) {
from sourceSets.main.allSource
}

publishing {
publications {
javaLibrary(MavenPublication) {
artifactId 'mockito-kotlin'

from components.java

artifact sourceJar {
classifier "sources"
}

artifact javadocJar

pom.withXml {
def root = asNode()
root.appendNode('name', 'Mockito-Kotlin')
root.appendNode('description', 'Using Mockito with Kotlin.')
root.appendNode('url', 'https://github.com/mockito/mockito-kotlin')

def scm = root.appendNode('scm')
scm.appendNode('url', 'scm:[email protected]:mockito/mockito-kotlin.git')

def licenses = root.appendNode('licenses')
def mitLicense = licenses.appendNode('license')
mitLicense.appendNode('name', 'MIT')

def developers = root.appendNode('developers')
def nhaarman = developers.appendNode('developer')
nhaarman.appendNode('id', 'nhaarman')
nhaarman.appendNode('name', 'Niek Haarman')
}
}
}

//useful for testing - running "publish" will create artifacts/pom in a local dir
repositories { maven { url = "$rootProject.buildDir/repo" } }
}

clean {
delete "$rootProject.buildDir/repo"
}

// Avoid generation of the module metadata so that we don't have to publish an additional file
// and keep the build logic simple.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}

//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 = false //can be changed to 'false' for testing
dryRun = project.hasProperty('bintrayDryRun')

publications = ['javaLibrary']

pkg {
repo = 'test' //https://bintray.com/mockito/maven // TODO change to 'maaven' when CI ready
userOrg = 'mockito' //https://bintray.com/mockito

name = 'mockito-kotlin'

licenses = ['MIT']
labels = ['kotlin', 'mockito']
vcsUrl = 'https://github.com/mockito/mockito-kotlin.git'

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

mavenCentralSync {
sync = false // TODO enable after CI+bintray integration is ready
user = System.getenv('NEXUS_TOKEN_USER')
password = System.getenv('NEXUS_TOKEN_PWD')
}
}
}
}
22 changes: 0 additions & 22 deletions gradle/scripts/tagging.gradle

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Oct 29 21:53:52 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
Copy link

@bohsen bohsen Jan 25, 2021

Choose a reason for hiding this comment

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

Great work.

Minor: Gradle 6.8.1 was released last week.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
5 changes: 2 additions & 3 deletions mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'kotlin'
apply from: '../publishing.gradle'
apply from: '../gradle/publishing.gradle'
apply plugin: 'org.jetbrains.dokka'

buildscript {
Expand All @@ -13,8 +13,7 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5"
}
}

Expand Down
Loading