Skip to content

Commit

Permalink
Manual versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Dec 3, 2023
1 parent 133d58a commit 46dd312
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
- scala-http4s
- scala-support
- cli
version:
type: input
description: 'What version to use (default: derive from git)'

jobs:
publish:
Expand Down Expand Up @@ -58,6 +61,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [java-async-http]'
if: ${{ steps.set-project-from-tag.outputs.module == 'java-async-http' }}
run: sbt 'show version' "project guardrail-java-async-http" clean compile versionCheck test ci-release
Expand All @@ -67,6 +71,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [java-dropwizard]'
if: ${{ steps.set-project-from-tag.outputs.module == 'java-dropwizard' }}
run: sbt 'show version' "project guardrail-java-dropwizard" clean compile versionCheck test ci-release
Expand All @@ -76,6 +81,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [java-spring-mvc]'
if: ${{ steps.set-project-from-tag.outputs.module == 'java-spring-mvc' }}
run: sbt 'show version' "project guardrail-java-spring-mvc" clean compile versionCheck test ci-release
Expand All @@ -85,6 +91,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [java-support]'
if: ${{ steps.set-project-from-tag.outputs.module == 'java-support' }}
run: sbt 'show version' "project guardrail-java-support" clean compile versionCheck test ci-release
Expand All @@ -94,6 +101,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [scala-akka-http]'
if: ${{ steps.set-project-from-tag.outputs.module == 'scala-akka-http' }}
run: sbt 'show version' "project guardrail-scala-akka-http" clean compile versionCheck test ci-release
Expand All @@ -103,6 +111,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [scala-dropwizard]'
if: ${{ steps.set-project-from-tag.outputs.module == 'scala-dropwizard' }}
run: sbt 'show version' "project guardrail-scala-dropwizard" clean compile versionCheck test ci-release
Expand All @@ -112,6 +121,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [scala-http4s]'
if: ${{ steps.set-project-from-tag.outputs.module == 'scala-http4s' }}
run: sbt 'show version' "project guardrail-scala-http4s" clean compile versionCheck test ci-release
Expand All @@ -121,6 +131,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [scala-support]'
if: ${{ steps.set-project-from-tag.outputs.module == 'scala-support' }}
run: sbt 'show version' "project guardrail-scala-support" clean compile versionCheck test ci-release
Expand All @@ -130,6 +141,7 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: 'Publish artifacts [cli]'
if: ${{ steps.set-project-from-tag.outputs.module == 'cli' }}
run: sbt 'show version' "project guardrail-cli" clean compile versionCheck test ci-release
Expand All @@ -139,3 +151,4 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GUARDRAIL_RELEASE_MODULE: ${{ steps.set-project-from-tag.outputs.module }}
GUARDRAIL_RELEASE_VERSION: ${{ github.event.inputs.version }}
28 changes: 22 additions & 6 deletions project/src/main/scala/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ object Build {
// git.gitDescribedVersion := gitReader.value.withGit(_.describedVersion(gitDescribePatterns.value)).map(v => customTagToVersionNumber(moduleSegment)(v).getOrElse(v)),
git.useGitDescribe := true,
version := {
val manualVersion = sys.env.get("GUARDRAIL_RELEASE_VERSION").filter(_.nonEmpty)
val isRelease = sys.env.contains("GUARDRAIL_RELEASE_MODULE")
val overrideVersion =
git.overrideVersion(git.versionProperty.value)
Expand All @@ -140,12 +141,27 @@ object Build {
val datedVersion = git.formattedDateVersion.value
val commitVersion = git.formattedShaVersion.value
//Now we fall through the potential version numbers...
git.makeVersion(Seq(
overrideVersion,
releaseVersion,
describedVersion,
commitVersion
)) getOrElse datedVersion // For when git isn't there at all.
manualVersion
.orElse(
git.makeVersion(Seq(
overrideVersion,
releaseVersion,
describedVersion,
commitVersion
))
).getOrElse(datedVersion) // For when git isn't there at all.
},
isSnapshot := {
// sbt-git sets isSnapshot to `true` if there's no tag. If we're manually releasing,
// we should be able to control this as well.
val manualVersion = sys.env.get("GUARDRAIL_RELEASE_VERSION").filter(_.nonEmpty)
if (manualVersion.nonEmpty) {
// Important to have the nonEmpty _and_ exists/forall, since
// we want to be able to release both snapshots and real releases
manualVersion.exists(_.endsWith("-SNAPSHOT"))
} else {
isSnapshot.value
}
},
stableVersion := {
// Pull the tag(s) matching the tag scheme, defaulting to 0.0.0
Expand Down

0 comments on commit 46dd312

Please sign in to comment.