From 342ba93ac6c93d0eaca1eb9534a3e95596902ff5 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Sat, 14 Jun 2025 11:42:02 +0200 Subject: [PATCH 1/5] Create releases on tags 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. --- .github/workflows/ci.yml | 14 +++++++------- build.gradle | 6 ------ version.properties | 3 --- 3 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 version.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd1bf161..99d5750a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ name: CI on: push: branches: ['release/2.x'] - tags-ignore: [v*] # release tags are automatically generated after a successful CI build, no need to run CI against them + tags: [v*] pull_request: branches: ['**'] @@ -34,14 +34,13 @@ jobs: - name: 1. 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: 2. Set up Java ${{ matrix.java }} uses: actions/setup-java@v2 with: distribution: 'zulu' java-version: ${{ matrix.java }} + cache: 'gradle' - name: 3. Build on Java ${{ matrix.java }} run: ./build.sh @@ -57,11 +56,13 @@ jobs: # Release job, only for pushes to the main development branch # release: + permissions: + contents: write runs-on: ubuntu-latest needs: [build] # build job must pass before we can release if: github.event_name == 'push' - && github.ref == 'refs/heads/release/2.x' + && (github.ref == 'refs/heads/release/2.x' || startsWith(github.ref, 'refs/tags/v')) && github.repository == 'mockito/mockito-scala' && !contains(toJSON(github.event.commits.*.message), '[skip release]') @@ -77,11 +78,10 @@ jobs: with: distribution: 'zulu' java-version: 17 + cache: 'gradle' - name: Build and publish to Bintray/MavenCentral - run: ./gradlew writeActualVersion - && export PROJECT_VERSION=`cat version.actual` - && ./build.sh + run: ./build.sh && ./gradlew publishToSonatype githubRelease closeAndReleaseStagingRepository releaseSummary env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/build.gradle b/build.gradle index 51a3dbd8..95a5e4b4 100644 --- a/build.gradle +++ b/build.gradle @@ -85,12 +85,6 @@ nexusPublishing { } } -task writeActualVersion { - doLast { - file("version.actual") << "$version" - } -} - def isSnapshot = version.endsWith("-SNAPSHOT") if (isSnapshot) { diff --git a/version.properties b/version.properties deleted file mode 100644 index bd7ddf43..00000000 --- a/version.properties +++ /dev/null @@ -1,3 +0,0 @@ -# The version is inferred by shipkit-auto-version Gradle plugin -# More: https://github.com/shipkit/shipkit-auto-version -version=2.0.* \ No newline at end of file From 1a61056ef49b2530332210a6922ca26747b3da35 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Sat, 14 Jun 2025 11:43:35 +0200 Subject: [PATCH 2/5] Add permission to read the cache --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99d5750a..a0a8c60a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ on: pull_request: branches: ['**'] +permissions: + contents: read + jobs: # From f7af498210a405a9a1e8b5848584dbce8fae5e6e Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Sat, 14 Jun 2025 11:48:16 +0200 Subject: [PATCH 3/5] Remove cache --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0a8c60a..89351e41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: with: distribution: 'zulu' java-version: ${{ matrix.java }} - cache: 'gradle' - name: 3. Build on Java ${{ matrix.java }} run: ./build.sh @@ -81,7 +80,6 @@ jobs: with: distribution: 'zulu' java-version: 17 - cache: 'gradle' - name: Build and publish to Bintray/MavenCentral run: ./build.sh From 293e339e21c4d3c45751a0d31d1a7b1efb1437fa Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Sat, 14 Jun 2025 11:58:13 +0200 Subject: [PATCH 4/5] Remove version property in build.sbt --- build.sbt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/build.sbt b/build.sbt index 95a026c0..c5c516ff 100644 --- a/build.sbt +++ b/build.sbt @@ -7,19 +7,6 @@ val currentScalaVersion = "2.13.16" inThisBuild( Seq( scalaVersion := currentScalaVersion, - // Load version from the file so that Gradle/Shipkit and SBT use the same version - version := sys.env - .get("PROJECT_VERSION") - .filter(_.trim.nonEmpty) - .orElse { - lazy val VersionRE = """^version=(.+)$""".r - Using.file(Source.fromFile)(baseDirectory.value / "version.properties") { - _.getLines.collectFirst { case VersionRE(v) => v } - } - } - .map(_.replace(".*", "-SNAPSHOT")) - .get - ) ) lazy val commonSettings = From 12f68e5c490f00ba37d7aa5e277c58272692cec1 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Sat, 14 Jun 2025 12:09:56 +0200 Subject: [PATCH 5/5] Fix syntax error --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index c5c516ff..e201a9b7 100644 --- a/build.sbt +++ b/build.sbt @@ -7,6 +7,7 @@ val currentScalaVersion = "2.13.16" inThisBuild( Seq( scalaVersion := currentScalaVersion, + ) ) lazy val commonSettings =