Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a autorelease workflow for patches (x.y.{z+1}) #675

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ on:
schedule:
- cron: '0 3 * * 1' # Every Monday at 3am UTC
workflow_dispatch: # For manual triggering
inputs:
version_type:
description: 'Version type: minor / patch'
required: true
default: 'minor'
type: choice
options:
- 'minor'
- 'patch'

env:
JAVA_VERSION: '11'
Expand Down Expand Up @@ -72,7 +81,12 @@ jobs:
- name: Bump Effekt version using sbt
id: set-version
run: |
full_output=$(sbt 'bumpMinorVersion' -error)
if [ "${{ github.event.inputs.version_type }}" = "patch" ]; then
full_output=$(sbt 'bumpPatchVersion' -error)
else
full_output=$(sbt 'bumpMinorVersion' -error)
fi

new_version=$(echo "$full_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1)
new_version=$(echo "$new_version" | xargs)
if [[ ! $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
Expand Down
22 changes: 22 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ lazy val assembleJS = taskKey[Unit]("Assemble the JS file in out/effekt.js")
lazy val assembleBinary = taskKey[Unit]("Assembles the effekt binary in bin/effekt")
lazy val generateDocumentation = taskKey[Unit]("Generates some documentation.")
lazy val bumpMinorVersion = taskKey[Unit]("Bumps the minor version number (used in CI).")
lazy val bumpPatchVersion = taskKey[Unit]("Bumps the patch version number (used in CI).")

lazy val noPublishSettings = Seq(
publish := {},
Expand Down Expand Up @@ -161,6 +162,7 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
Process(s"${mvn.value} versions:set -DnewVersion=${effektVersion} -DgenerateBackupPoms=false").!!
},

// TODO: reduce duplication between `bumpMinorVersion' and 'bumpPatchVersion'
bumpMinorVersion := {
val versionPattern = """(\d+)\.(\d+)\.(\d+)""".r
val newVersion = effektVersion match {
Expand All @@ -181,6 +183,26 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
println(newVersion)
},

bumpPatchVersion := {
val versionPattern = """(\d+)\.(\d+)\.(\d+)""".r
val newVersion = effektVersion match {
case versionPattern(major, minor, patch) =>
s"$major.$minor.${patch.toInt + 1}"
case _ =>
sys.error(s"Invalid version format: $effektVersion")
}

val versionFile = (ThisBuild / baseDirectory).value / "project" / "EffektVersion.scala"
IO.write(versionFile,
s"""// Don't change this file without changing the CI too!
|import sbt.*
|import sbt.Keys.*
|object EffektVersion { lazy val effektVersion = "$newVersion" }
|""".stripMargin)

println(newVersion)
},

generateDocumentation := TreeDocs.replacer.value,
Compile / sourceGenerators += versionGenerator.taskValue,
Compile / sourceGenerators += TreeDocs.generator.taskValue,
Expand Down