Skip to content

Commit 8031bd6

Browse files
authored
Automated releases directly to Sonatype (#421)
- Enabled axion plugin - Enabled safe snapshot releases - Enabled releases to Central on *tag push*
1 parent 37bbae4 commit 8031bd6

File tree

6 files changed

+42
-27
lines changed

6 files changed

+42
-27
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ on:
1111
push:
1212
branches:
1313
- main
14-
tags-ignore:
15-
- v* # release tags are automatically generated after a successful CI build, no need to run CI against them
1614
pull_request:
1715
branches:
1816
- main

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,21 @@ For more info and samples, see the [Wiki](https://github.com/mockito/mockito-kot
3939

4040
Mockito-Kotlin is built with Gradle.
4141

42-
- `./gradlew build` builds the project
42+
- `./gradlew build` builds and tests the project
4343
- `./gradlew publishToMavenLocal` installs the maven artifacts in your local repository
44-
- `./gradlew assemble && ./gradlew test` runs the test suite (See Testing below)
44+
- `./gradlew check` runs the test suite (See Testing below)
4545

4646
### Versioning
4747

48-
Mockito-Kotlin roughly follows SEMVER; version names are parsed from
49-
git tags using `git describe`.
48+
Mockito-Kotlin roughly follows SEMVER
5049

5150
### Testing
5251

5352
Mockito-Kotlin's test suite is located in a separate `tests` module,
5453
to allow running the tests using several Kotlin versions whilst still
55-
keeping the base module at a recent version.
54+
keeping the base module at a recent version.
5655

57-
Testing thus must be done in two stages: one to build the base artifact
58-
to test against, and the actual execution of the tests against the
59-
built artifact:
60-
61-
- `./gradlew assemble` builds the base artifact
62-
- `./gradlew test` runs the tests against the built artifact.
56+
- `./gradlew check` runs the checks including tests.
6357

6458
Usually it is enough to test only using the default Kotlin versions;
6559
CI will test against multiple versions.

RELEASING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
# Releasing
22

3-
Every change on the main development branch is released to Maven Central.
3+
1. Every change on the main development branch is released as -SNAPSHOT version
4+
to Sonatype snapshot repo at https://s01.oss.sonatype.org/content/repositories/snapshots.
5+
2. In order to release a non-snapshot version to Maven Central push an annotated tag, for example:
6+
```
7+
git tag -a -m "Release 3.4.5" 3.4.5
8+
git push
9+
```
10+
3. At the moment, you **may not create releases from GitHub Web UI**.
11+
Doing so will make the CI build fail because the CI creates the changelog and posts to GitHub releases.
12+
In the future supporting this would be nice but currently please make releases by pushing from CLI.

build.gradle

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,30 @@ buildscript {
44
maven { url "https://plugins.gradle.org/m2/" }
55
}
66
dependencies {
7-
classpath "org.shipkit:shipkit-changelog:1.+"
8-
classpath "org.shipkit:shipkit-auto-version:1.+"
7+
classpath "org.shipkit:shipkit-changelog:1.1.13"
8+
classpath "pl.allegro.tech.build:axion-release-plugin:1.13.0"
9+
classpath "io.github.gradle-nexus:publish-plugin:1.0.0"
910
}
1011
}
1112

12-
plugins {
13-
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
14-
}
15-
16-
apply plugin: "org.shipkit.shipkit-auto-version"
13+
apply plugin: "io.github.gradle-nexus.publish-plugin"
1714
apply plugin: "org.shipkit.shipkit-changelog"
1815
apply plugin: "org.shipkit.shipkit-github-release"
16+
apply plugin: "pl.allegro.tech.build.axion-release"
17+
18+
scmVersion {
19+
tag {
20+
prefix = ''
21+
}
22+
}
1923

2024
allprojects {
2125
group = 'org.mockito.kotlin'
26+
version = scmVersion.version
2227
}
2328

2429
tasks.named("generateChangelog") {
25-
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
30+
previousRevision = scmVersion.previousVersion
2631
githubToken = System.getenv("GITHUB_TOKEN")
2732
repository = "mockito/mockito-kotlin"
2833
releaseTag = project.version
@@ -42,7 +47,8 @@ tasks.named("githubRelease") {
4247
nexusPublishing {
4348
repositories {
4449
if (System.getenv("NEXUS_TOKEN_PWD")) {
45-
sonatype { // Publishing to: https://s01.oss.sonatype.org (faster instance)
50+
sonatype {
51+
// Publishing to: https://s01.oss.sonatype.org (faster instance)
4652
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
4753
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
4854

@@ -52,3 +58,14 @@ nexusPublishing {
5258
}
5359
}
5460
}
61+
62+
if (version.endsWith("-SNAPSHOT")) {
63+
tasks.named("githubRelease") {
64+
//snapshot versions do not produce changelog / GitHub releases
65+
enabled = false
66+
}
67+
tasks.named("closeAndReleaseStagingRepository") {
68+
//snapshot binaries are available in Sonatype without the need to close the staging repo
69+
enabled = false
70+
}
71+
}

gradle/publishing.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//Maven publication plugins & configuration
12
apply plugin: 'maven-publish'
23

34
task javadocJar(type: Jar, dependsOn: javadoc) {

version.properties

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

0 commit comments

Comments
 (0)