Skip to content

Commit c506ec4

Browse files
authored
Create releases on tags (#566)
Instead of releasing on every commit (in case of Dependabot, every dependency update is a new commit), we now use GitHub tags instead. This is similar to mockito-core, which also uses tags to determine when to release.
1 parent 425b3ed commit c506ec4

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ name: CI
1010
on:
1111
push:
1212
branches: ['release/2.x']
13-
tags-ignore: [v*] # release tags are automatically generated after a successful CI build, no need to run CI against them
13+
tags: [v*]
1414
pull_request:
1515
branches: ['**']
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821

1922
#
@@ -34,8 +37,6 @@ jobs:
3437

3538
- name: 1. Check out code
3639
uses: actions/checkout@v2 # https://github.com/actions/checkout
37-
with:
38-
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
3940

4041
- name: 2. Set up Java ${{ matrix.java }}
4142
uses: actions/setup-java@v2
@@ -57,11 +58,13 @@ jobs:
5758
# Release job, only for pushes to the main development branch
5859
#
5960
release:
61+
permissions:
62+
contents: write
6063
runs-on: ubuntu-latest
6164
needs: [build] # build job must pass before we can release
6265

6366
if: github.event_name == 'push'
64-
&& github.ref == 'refs/heads/release/2.x'
67+
&& (github.ref == 'refs/heads/release/2.x' || startsWith(github.ref, 'refs/tags/v'))
6568
&& github.repository == 'mockito/mockito-scala'
6669
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
6770

@@ -79,9 +82,7 @@ jobs:
7982
java-version: 17
8083

8184
- name: Build and publish to Bintray/MavenCentral
82-
run: ./gradlew writeActualVersion
83-
&& export PROJECT_VERSION=`cat version.actual`
84-
&& ./build.sh
85+
run: ./build.sh
8586
&& ./gradlew publishToSonatype githubRelease closeAndReleaseStagingRepository releaseSummary
8687
env:
8788
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ nexusPublishing {
8585
}
8686
}
8787

88-
task writeActualVersion {
89-
doLast {
90-
file("version.actual") << "$version"
91-
}
92-
}
93-
9488
def isSnapshot = version.endsWith("-SNAPSHOT")
9589

9690
if (isSnapshot) {

build.sbt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ val currentScalaVersion = "2.13.16"
77
inThisBuild(
88
Seq(
99
scalaVersion := currentScalaVersion,
10-
// Load version from the file so that Gradle/Shipkit and SBT use the same version
11-
version := sys.env
12-
.get("PROJECT_VERSION")
13-
.filter(_.trim.nonEmpty)
14-
.orElse {
15-
lazy val VersionRE = """^version=(.+)$""".r
16-
Using.file(Source.fromFile)(baseDirectory.value / "version.properties") {
17-
_.getLines.collectFirst { case VersionRE(v) => v }
18-
}
19-
}
20-
.map(_.replace(".*", "-SNAPSHOT"))
21-
.get
2210
)
2311
)
2412

version.properties

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

0 commit comments

Comments
 (0)