diff --git a/.github/workflows/cut-release.yml b/.github/workflows/cut-release.yml index de85581e6..9b6ef2658 100644 --- a/.github/workflows/cut-release.yml +++ b/.github/workflows/cut-release.yml @@ -29,17 +29,25 @@ jobs: git config --global user.name "glow-release[bot]" git config --global user.email "glow-release-bot@noreply.projectglow.io" - - name: Cut release with SBT + - name: Update version files for release run: | - sbt 'set releaseType := "cutRelease"' 'release release-version ${{ inputs.release-version }} next-version ${{ inputs.next-version }}' + echo "${{ inputs.release-version }}" > stable-version.txt + sed -i "s/^VERSION =.*/VERSION = '${{ inputs.release-version }}'/" python/version.py + echo 'ThisBuild / version := "${{ inputs.release-version }}"' > version.sbt + git add stable-version.txt python/version.py version.sbt + git commit -m "Update version for release ${{ inputs.release-version }}" -s - - name: Update Python version file - run: | - sed -i "s/^VERSION =.*/VERSION = '${{ inputs.release-version }}'/" python/version.py + - name: Create release tag + run: git tag v${{ inputs.release-version }} - name: Push release tag run: git push origin v${{ inputs.release-version }} + - name: Update versions for next release + run: | + sed -i "s/^VERSION =.*/VERSION = '${{ inputs.next-version }}-SNAPSHOT'/" python/version.py + echo 'ThisBuild / version := "${{ inputs.next-version }}-SNAPSHOT"' > version.sbt + - name: Open pull request for next version uses: peter-evans/create-pull-request@v6 with: @@ -47,3 +55,4 @@ jobs: branch: releases/${{ inputs.release-version }} title: Update development version to ${{ inputs.next-version }} body: Automatically created by the "Cut release" workflow + commit-message: Update development versions diff --git a/build.sbt b/build.sbt index 559fbf936..35653c6bb 100644 --- a/build.sbt +++ b/build.sbt @@ -391,37 +391,12 @@ def sonatypeSteps(): Seq[ReleaseStep] = Seq( releaseStepCommandAndRemaining("sonatypeBundleUpload") ) -val cutRelease = Seq[ReleaseStep]( +releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, setReleaseVersion, - updateStableVersion, - commitReleaseVersion, - commitStableVersion, - tagRelease, - setNextVersion, - commitNextVersion -) - -val doRelease = Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - setReleaseVersion, - updateStableVersion, - checkRepoClean, runClean, runTest, ) ++ crossReleaseStep(releaseStepCommandAndRemaining("publishSigned"), requiresPySpark = false) ++ sonatypeSteps ++ crossReleaseStep(releaseStepCommandAndRemaining("stagedRelease/test"), requiresPySpark = false) - -lazy val releaseType = settingKey[String]("releaseType") -ThisBuild / releaseType := "cutRelease" - -releaseProcess := { - (ThisBuild / releaseType).value match { - case "cutRelease" => cutRelease - case "doRelease" => doRelease - case _ => throw new RuntimeException("Invalid release type") - } -} diff --git a/project/StableVersionPlugin.scala b/project/StableVersionPlugin.scala deleted file mode 100644 index aff97086a..000000000 --- a/project/StableVersionPlugin.scala +++ /dev/null @@ -1,106 +0,0 @@ -import sbt._ -import sbt.Keys.baseDirectory -import sbtrelease.{ReleasePlugin, Vcs, Versions} -import sbtrelease.ReleasePlugin.runtimeVersion -import sbtrelease.ReleasePlugin.autoImport._ -import sbtrelease.ReleasePlugin.autoImport.ReleaseKeys.versions - -import scala.sys.process._ - -/** - * Changes the version in stable-version.txt during a release. - */ -object StableVersionPlugin extends AutoPlugin { - - override def requires: Plugins = ReleasePlugin - - override def trigger: PluginTrigger = AllRequirements - - object autoImport { - - val stableVersionFile = settingKey[File]("Stable release version file") - val stableCommitMessage = - taskKey[String]("The commit message to use when setting the stable version") - - /** - * Update the stable version file during a release. - */ - val updateStableVersion: ReleaseStep = updateStableVersionStep(_._1, stableVersionFile) - - /** - * Commits the stable version file changes. - */ - val commitStableVersion: ReleaseStep = commitFileStep(stableCommitMessage, stableVersionFile) - - val checkRepoClean: ReleaseStep = { st: State => - if ("git update-index --really-refresh".! != 0 || "git diff-index --quiet HEAD".! != 0) { - sys.error("Repo was not clean. Make sure the provided version matches the committed version files.") - } - st - } - } - - import autoImport._ - - override def projectSettings: Seq[Setting[_]] = { - Seq( - stableVersionFile := baseDirectory.value / "stable-version.txt", - stableCommitMessage := s"Setting stable version to ${runtimeVersion.value}" - ) - } - - private def updateStableVersionStep( - selectVersion: Versions => String, - fileSettingKey: SettingKey[File]): ReleaseStep = { st: State => - val vs = st - .get(versions) - .getOrElse( - sys.error("No versions are set! Was this release part executed before inquireVersions?")) - val selected = selectVersion(vs) - - st.log.info("Writing stable version '%s'." format selected) - IO.writeLines(Project.extract(st).get(fileSettingKey), Seq(selected)) - st - } - - private def commitFileStep( - commitMessage: TaskKey[String], - fileSettingKey: SettingKey[File]): ReleaseStep = { st: State => - val log = toProcessLogger(st) - val file = Project.extract(st).get(fileSettingKey).getCanonicalFile - val base = vcs(st).baseDir.getCanonicalFile - val sign = Project.extract(st).get(releaseVcsSign) - val signOff = Project.extract(st).get(releaseVcsSignOff) - val relativePath = IO - .relativize(base, file) - .getOrElse( - "Version file [%s] is outside of this VCS repository with base directory [%s]!" format (file, base)) - - vcs(st).add(relativePath) !! log - val status = vcs(st).status.!!.trim - - val newState = if (status.nonEmpty) { - val (state, msg) = Project.extract(st).runTask(commitMessage, st) - vcs(state).commit(msg, sign, signOff) ! log - state - } else { - // nothing to commit. this happens if the file hasn't changed. - st - } - newState - } - - private def toProcessLogger(st: State): ProcessLogger = new ProcessLogger { - override def err(s: => String): Unit = st.log.info(s) - override def out(s: => String): Unit = st.log.info(s) - override def buffer[T](f: => T): T = st.log.buffer(f) - } - - private def vcs(st: State): Vcs = { - Project - .extract(st) - .get(releaseVcs) - .getOrElse( - sys.error("Aborting release. Working directory is not a repository of a recognized VCS.")) - } -}