Skip to content

Commit 6232b43

Browse files
authored
Merge pull request #402 from mockito/sf
Added CI + Bintray releases
2 parents b8f480f + bc9618f commit 6232b43

File tree

14 files changed

+289
-182
lines changed

14 files changed

+289
-182
lines changed

.github/workflows/ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#
2+
# CI build that assembles artifacts and runs tests.
3+
# If validation is successful this workflow releases from the main dev branch.
4+
#
5+
# - skipping CI: add [skip ci] to the commit message
6+
# - skipping release: add [skip release] to the commit message
7+
#
8+
name: CI
9+
10+
on:
11+
push:
12+
branches:
13+
- main
14+
tags-ignore:
15+
- v* # release tags are automatically generated after a successful CI build, no need to run CI against them
16+
pull_request:
17+
branches:
18+
- main
19+
20+
jobs:
21+
22+
#
23+
# SINGLE-JOB
24+
#
25+
verify:
26+
runs-on: ubuntu-latest
27+
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
28+
29+
steps:
30+
31+
- name: 1. Check out code
32+
uses: actions/checkout@v2 # https://github.com/actions/checkout
33+
34+
- name: 2. Set up Java 8
35+
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
36+
with:
37+
java-version: 8
38+
39+
- name: 3. Validate Gradle wrapper
40+
uses: gradle/wrapper-validation-action@v1 # https://github.com/gradle/wrapper-validation-action
41+
42+
#
43+
# Main build job
44+
#
45+
build:
46+
needs: [verify]
47+
runs-on: ubuntu-latest
48+
49+
# Definition of the build matrix
50+
strategy:
51+
matrix:
52+
mock-maker: ['mock-maker-default', 'mock-maker-inline']
53+
kotlin: ['1.3.50', '1.4.21']
54+
# Note that the old Travis CI referenced other Kotlin versions: '1.0.7', '1.1.61', '1.2.50'
55+
# However, those versions of Kotlin don't work with latest Gradle
56+
57+
steps:
58+
59+
- name: 1. Check out code
60+
uses: actions/checkout@v2 # https://github.com/actions/checkout
61+
62+
- name: 2. Set up Java 8
63+
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
64+
with:
65+
java-version: 8
66+
67+
- name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
68+
run: |
69+
ops/mockMakerInline.sh
70+
./gradlew build bintrayUpload -PbintrayDryRun
71+
env:
72+
KOTLIN_VERSION: ${{ matrix.kotlin }}
73+
MOCK_MAKER: ${{ matrix.mock-maker }}
74+
75+
#
76+
# Release job, only for pushes to the main development branch
77+
#
78+
release:
79+
runs-on: ubuntu-latest
80+
needs: [build] # build job must pass before we can release
81+
82+
if: github.event_name == 'push'
83+
&& github.ref == 'refs/heads/main'
84+
&& github.repository == 'mockito/mockito-kotlin'
85+
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
86+
87+
steps:
88+
89+
- name: Check out code
90+
uses: actions/checkout@v2 # https://github.com/actions/checkout
91+
with:
92+
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
93+
94+
- name: Set up Java 8
95+
uses: actions/setup-java@v1
96+
with:
97+
java-version: 8
98+
99+
- name: Build and publish to Bintray/MavenCentral
100+
run: ./gradlew tasks # TODO, in progress: bintrayUpload githubRelease
101+
env:
102+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
103+
# BINTRAY_API_KEY: ${{secrets.BINTRAY_API_KEY}}
104+
# NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
105+
# NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
106+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.gradle
22
build/
33
out/
4+
repo
45

56
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
67
!gradle-wrapper.jar

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

build.gradle

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "io.spring.gradle:spring-bintray-plugin:0.11.1"
9-
}
1+
plugins {
2+
id "org.shipkit.shipkit-auto-version" version "1.1.1"
3+
id "org.shipkit.shipkit-changelog" version "1.1.1"
4+
id "org.shipkit.shipkit-github-release" version "1.1.1"
105
}
116

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

16-
apply from: 'gradle/scripts/tagging.gradle'
13+
tasks.named("githubRelease") {
14+
def genTask = tasks.named("generateChangelog").get()
15+
dependsOn genTask
16+
repository = genTask.repository
17+
changelog = genTask.outputFile
18+
githubToken = System.getenv("GITHUB_TOKEN")
19+
newTagRevision = System.getenv("GITHUB_SHA")
20+
}
1721

18-
println ext.versionName

gradle/publishing.gradle

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
apply plugin: 'maven-publish'
2+
3+
//TODO: update the group to 'org.mockito' ***AND*** change java packages
4+
group = 'com.nhaarman.mockitokotlin2'
5+
6+
task javadocJar(type: Jar, dependsOn: javadoc) {
7+
classifier = 'javadoc'
8+
from 'build/javadoc'
9+
}
10+
11+
task sourceJar(type: Jar) {
12+
from sourceSets.main.allSource
13+
}
14+
15+
publishing {
16+
publications {
17+
javaLibrary(MavenPublication) {
18+
artifactId 'mockito-kotlin'
19+
20+
from components.java
21+
22+
artifact sourceJar {
23+
classifier "sources"
24+
}
25+
26+
artifact javadocJar
27+
28+
pom.withXml {
29+
def root = asNode()
30+
root.appendNode('name', 'Mockito-Kotlin')
31+
root.appendNode('description', 'Using Mockito with Kotlin.')
32+
root.appendNode('url', 'https://github.com/mockito/mockito-kotlin')
33+
34+
def scm = root.appendNode('scm')
35+
scm.appendNode('url', 'scm:git@github.com:mockito/mockito-kotlin.git')
36+
37+
def licenses = root.appendNode('licenses')
38+
def mitLicense = licenses.appendNode('license')
39+
mitLicense.appendNode('name', 'MIT')
40+
41+
def developers = root.appendNode('developers')
42+
def nhaarman = developers.appendNode('developer')
43+
nhaarman.appendNode('id', 'nhaarman')
44+
nhaarman.appendNode('name', 'Niek Haarman')
45+
}
46+
}
47+
}
48+
49+
//useful for testing - running "publish" will create artifacts/pom in a local dir
50+
repositories { maven { url = "$rootProject.buildDir/repo" } }
51+
}
52+
53+
clean {
54+
delete "$rootProject.buildDir/repo"
55+
}
56+
57+
// Avoid generation of the module metadata so that we don't have to publish an additional file
58+
// and keep the build logic simple.
59+
tasks.withType(GenerateModuleMetadata) {
60+
enabled = false
61+
}
62+
63+
//fleshes out problems with Maven pom generation when building
64+
tasks.build.dependsOn('publishJavaLibraryPublicationToMavenLocal')
65+
66+
//Bintray Gradle plugin configuration (https://github.com/bintray/gradle-bintray-plugin)
67+
//Plugin jars are added to the buildscript classpath in the root build.gradle file
68+
apply plugin: 'com.jfrog.bintray'
69+
70+
bintray {
71+
//We need to use some user id here, because the Bintray key is associated with the user
72+
//However, any user id is good, so longer the user has necessary privileges to the repository
73+
user = 'szczepiq' //https://bintray.com/szczepiq
74+
key = System.getenv('BINTRAY_API_KEY')
75+
publish = false //can be changed to 'false' for testing
76+
dryRun = project.hasProperty('bintrayDryRun')
77+
78+
publications = ['javaLibrary']
79+
80+
pkg {
81+
repo = 'test' //https://bintray.com/mockito/maven // TODO change to 'maaven' when CI ready
82+
userOrg = 'mockito' //https://bintray.com/mockito
83+
84+
name = 'mockito-kotlin'
85+
86+
licenses = ['MIT']
87+
labels = ['kotlin', 'mockito']
88+
vcsUrl = 'https://github.com/mockito/mockito-kotlin.git'
89+
90+
version {
91+
name = project.version
92+
vcsTag = "v$project.version"
93+
94+
mavenCentralSync {
95+
sync = false // TODO enable after CI+bintray integration is ready
96+
user = System.getenv('NEXUS_TOKEN_USER')
97+
password = System.getenv('NEXUS_TOKEN_PWD')
98+
}
99+
}
100+
}
101+
}

gradle/scripts/tagging.gradle

Lines changed: 0 additions & 22 deletions
This file was deleted.

gradle/wrapper/gradle-wrapper.jar

4.37 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Mon Oct 29 21:53:52 CET 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

0 commit comments

Comments
 (0)