Skip to content

Commit f796752

Browse files
authored
Merge pull request #156 from SpineEventEngine/increment-version-check
Increment version check
2 parents 3292791 + ef86896 commit f796752

File tree

7 files changed

+58
-23
lines changed

7 files changed

+58
-23
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Ensures that the current lib version is not yet published but executing the Gradle
2+
# `checkVersionIncrement` task.
3+
4+
name: Check version increment
5+
6+
on:
7+
push:
8+
branches: '**'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
17+
- uses: actions/setup-java@v1
18+
with:
19+
java-version: 1.8
20+
21+
- name: Pull config
22+
run: git submodule update --init --recursive
23+
24+
- name: Check version is not yet published
25+
shell: bash
26+
run: ./gradlew checkVersionIncrement

build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import io.spine.gradle.internal.DependencyResolution
2222
import io.spine.gradle.internal.Deps
23-
import io.spine.gradle.internal.IncrementGuard
2423
import io.spine.gradle.internal.PublishingRepos
2524

2625
buildscript {
@@ -211,5 +210,4 @@ apply {
211210
from(Deps.scripts.publish(project))
212211
from(Deps.scripts.repoLicenseReport(project))
213212
from(Deps.scripts.generatePom(project))
214-
plugin(IncrementGuard::class)
215213
}

buildSrc/src/main/kotlin/io/spine/gradle/internal/IncrementGuard.kt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class IncrementGuard : Plugin<Project> {
3939
*
4040
* Only adds the check if the project is built on Travis CI and the job is a pull request.
4141
*
42-
* The task will never run outside of Travis CI or when building individual branches. This is
43-
* done to prevent unexpected CI fails when re-building `master` multiple times, creating git
42+
* The task only runs on non-master branches on GitHub Actions. This is done
43+
* to prevent unexpected CI fails when re-building `master` multiple times, creating git
4444
* tags, and in other cases that go outside of the "usual" development cycle.
4545
*/
4646
override fun apply(target: Project) {
@@ -50,25 +50,33 @@ class IncrementGuard : Plugin<Project> {
5050
tasks.getByName("check").dependsOn(this)
5151

5252
shouldRunAfter("test")
53-
if (!isTravisPullRequest()) {
54-
logger.info("The build does not represent a Travis pull request job, the " +
55-
"`checkVersionIncrement` task is disabled.")
53+
if (!shouldCheckVersion()) {
54+
logger.info("The build does not represent a GitHub Actions feature branch job, " +
55+
"the `checkVersionIncrement` task is disabled.")
5656
this.enabled = false
5757
}
5858
}
5959
}
6060

6161
/**
62-
* Returns `true` if the current build is a Travis job which represents a GitHub pull request.
62+
* Returns `true` if the current build is a GitHub Actions build which represents a push
63+
* to a feature branch.
6364
*
64-
* Implementation note: the `TRAVIS_PULL_REQUEST` environment variable contains the pull
65-
* request number rather than `"true"` in positive case, hence the check.
65+
* Returns `false` if the associated reference is not a branch (e.g. a tag) or if it has
66+
* the name which ends with `master`. So, on branches such as `master` and `2.x-jdk8-master`
67+
* this method would return `false`.
6668
*
67-
* @see <a href="https://docs.travis-ci.com/user/environment-variables/#default-environment-variables">
68-
* List of default environment variables provided for Travis builds</a>
69+
* @see <a href="https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables">
70+
* List of default environment variables provided for GitHub Actions builds</a>
6971
*/
70-
private fun isTravisPullRequest(): Boolean {
71-
val isPullRequest = System.getenv("TRAVIS_PULL_REQUEST")
72-
return isPullRequest != null && isPullRequest != "false"
72+
private fun shouldCheckVersion(): Boolean {
73+
val eventName = System.getenv("GITHUB_EVENT_NAME")
74+
if ("push" != eventName) {
75+
return false
76+
}
77+
val reference = System.getenv("GITHUB_REF") ?: return false
78+
val matches = Regex("refs/heads/(.+)").matchEntire(reference) ?: return false
79+
val branch = matches.groupValues[1]
80+
return !branch.endsWith("master")
7381
}
7482
}

datastore/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
*/
2020

2121
import com.github.psxpaul.task.ExecFork
22+
import io.spine.gradle.internal.IncrementGuard
2223

2324
plugins {
2425
id("com.github.psxpaul.execfork").version("0.1.13")
2526
}
2627

28+
apply<IncrementGuard>()
29+
2730
val spineCoreVersion: String by extra
2831

2932
dependencies {

license-report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@
588588
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
589589

590590

591-
This report was generated on **Fri Nov 20 16:49:35 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
591+
This report was generated on **Mon Nov 23 15:05:20 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
592592

593593

594594

@@ -1005,7 +1005,7 @@ This report was generated on **Fri Nov 20 16:49:35 EET 2020** using [Gradle-Lice
10051005
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
10061006

10071007

1008-
This report was generated on **Fri Nov 20 16:49:50 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1008+
This report was generated on **Mon Nov 23 15:05:25 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
10091009

10101010

10111011

@@ -1596,7 +1596,7 @@ This report was generated on **Fri Nov 20 16:49:50 EET 2020** using [Gradle-Lice
15961596
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
15971597

15981598

1599-
This report was generated on **Fri Nov 20 16:50:09 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1599+
This report was generated on **Mon Nov 23 15:05:32 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
16001600

16011601

16021602

@@ -2189,4 +2189,4 @@ This report was generated on **Fri Nov 20 16:50:09 EET 2020** using [Gradle-Lice
21892189
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
21902190

21912191

2192-
This report was generated on **Fri Nov 20 16:50:22 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2192+
This report was generated on **Mon Nov 23 15:05:35 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).

version.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
* `.config/gradle/dependencies.gradle`.
2626
*/
2727

28-
val spineBaseVersion: String by extra("1.6.12")
29-
val spineCoreVersion: String by extra("1.6.13")
30-
val versionToPublish: String by extra("1.6.12")
28+
val spineBaseVersion: String by extra("1.6.13")
29+
val spineCoreVersion: String by extra("1.6.15")
30+
val versionToPublish: String by extra("1.6.15")

0 commit comments

Comments
 (0)