Skip to content

Commit

Permalink
publish
Browse files Browse the repository at this point in the history
  • Loading branch information
rafafrdz committed Feb 17, 2024
1 parent eee2806 commit 5860cc9
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish Artifact on Release
on:
release:
types: [ created ]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Publish
run: sbt publish
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
lazy val `criterial-dsl`: Project =
project
.in(file("."))
.disablePlugins(AssemblyPlugin)
.enablePlugins(NoPublish)
// .disablePlugins(AssemblyPlugin)
// .enablePlugins(NoPublish)
.dependsOn(core, examples)
.settings(
name := "criterial-dsl",
publish / skip := true
name := "criterial-dsl"
// publish / skip := true
)

lazy val core: Project =
(project in file("core"))
.settings(
name := "core"
name := "core",
publish / skip := false
)

lazy val examples: Project =
Expand Down
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.4.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.11.8")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.11.8")
addSbtPlugin("com.alejandrohdezma" % "sbt-remove-test-from-pom" % "0.1.0")
//addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.0")
//addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")

//addSbtPlugin("io.github.er1c" % "sbt-github" % "0.2.0")
77 changes: 77 additions & 0 deletions publish.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//ThisBuild / organization := "io.github.rafafrdz"
//ThisBuild / organizationName := "rafafrdz"
//ThisBuild / organizationHomepage := Some(url("https://github.com/rafafrdz"))
//
//ThisBuild / scmInfo := Some(
// ScmInfo(
// url("https://github.com/rafafrdz/criterial-dsl"),
// "scm:[email protected]/criterial-dsl.git"
// )
//)
//
//ThisBuild / developers := List(
// Developer(
// id = "rafafrdz",
// name = "Rafael Fernández Ortiz",
// email = "[email protected]",
// url = url("https://github.com/rafafrdz")
// )
//)
//
//ThisBuild / description := "A simple DSL to create criterias for filtering data in Scala."
//ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
//ThisBuild / homepage := Some(url("https://github.com/rafafrdz/criterial-dsl"))
//
//// Remove all additional repository other than Maven Central from POM
//ThisBuild / pomIncludeRepository := { _ => false }
//
//ThisBuild / publishTo := {
// val registry = "https://maven.pkg.github.com/rafafrdz/criterial-dsl"
// Option("GitHub Package Registry" at registry)
//}
//
//ThisBuild / publishMavenStyle := true
//
//ThisBuild / versionScheme := Some("early-semver")

val tagWithQualifier: String => String => String =
qualifier => tagVersion => s"%s.%s.%s-${qualifier}%s".format(tagVersion.split("\\."): _*)

val tagAlpha: String => String = tagWithQualifier("a")
val tagBeta: String => String = tagWithQualifier("b")
val tagMilestone: String => String = tagWithQualifier("m")
val tagRC: String => String = tagWithQualifier("rc")

val defaultVersion: String = "0.0.0-a0"
val versionFromTag: String = sys.env
.get("GITHUB_REF_TYPE")
.filter(_ == "tag")
.flatMap(_ => sys.env.get("GITHUB_REF_NAME"))
.flatMap { t =>
t.headOption.map {
case 'a' => tagAlpha(t.tail) // Alpha build, a1.2.3.4
case 'b' => tagBeta(t.tail) // Beta build, b1.2.3.4
case 'm' => tagMilestone(t.tail) // Milestone build, m1.2.3.4
case 'r' => tagRC(t.tail) // RC build, r1.2.3.4
case 'v' => t.tail // Production build, should be v1.2.3
case _ => defaultVersion
}
}
.getOrElse(defaultVersion)

ThisBuild / organization := "io.github.rafafrdz"
ThisBuild / organizationName := "rafafrdz"
ThisBuild / organizationHomepage := Some(url("https://github.com/rafafrdz"))
ThisBuild / version := versionFromTag
ThisBuild / publish / skip := true
ThisBuild / publishMavenStyle := true
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / publishTo := Some(
"GitHub Package Registry " at "https://maven.pkg.github.com/rafafrdz/criterial-dsl"
)
ThisBuild / credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"rafafrdz",
sys.env.getOrElse("GITHUB_TOKEN", "")
)

0 comments on commit 5860cc9

Please sign in to comment.