Skip to content

Commit

Permalink
Build: Convert to single project; set up release actions
Browse files Browse the repository at this point in the history
  • Loading branch information
raquo committed Dec 5, 2023
1 parent d231538 commit 6e9300f
Show file tree
Hide file tree
Showing 75 changed files with 146 additions and 4,314 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
branches: [publish]
tags: ["*"]

env:
CI: true

jobs:
publish:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JVM
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Tests
run: sbt +test
- name: Release
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

env:
CI: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Setup JVM
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Run tests
run: sbt +test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

target/
node_modules/
package-lock.json

.bloop/
.bsp/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The bindings offered here were produced using semi-automatic code generation. It

The project isn't yet fully set up to fulfill this vision. Some of it will need to be moved to Scala DOM Types and perhaps generalized some more, to enable reusability.

* `custom-elements.json`[Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) generated by Shoelace.js. It lists and describes the types of their elements, attributes, properties, methods, etc. This file is found neither in this project nor in the shoelace project. You need to `cd sljs; npm install` to obtain it.
* `custom-elements.json`[Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) generated by Shoelace.js. It lists and describes the types of their elements, attributes, properties, methods, etc. This file is found neither in this project nor in the shoelace project. You need to run `npm install` to obtain it.

* `project/CustomElementsManifest.scala` – Scala data structure describing Shoelace's `custom-elements.json` file. We deserialize the JSON file into this structure using uPickle.

Expand Down
74 changes: 17 additions & 57 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import VersionHelper.{versionFmt, fallbackVersion}

ThisBuild / version := "0.1.0"

ThisBuild / scalaVersion := Versions.Scala_3

// Lets me depend on Maven Central artifacts immediately without waiting
resolvers ++= Resolver.sonatypeOssRepos("public")

Expand All @@ -18,57 +14,43 @@ ThisBuild / dynver := {
.mkVersion(out => versionFmt(out, dynverSonatypeSnapshots.value), fallbackVersion(d))
}

ThisBuild / scalaVersion := Versions.Scala_3

lazy val generateShoelace = taskKey[Unit]("generates the component definitions")

lazy val root = project.in(file("."))
.aggregate(js, jvm)
.settings(noPublish)
lazy val sl = project
.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "Laminar Shoelace",
generateShoelace := {
new ShoelaceGenerator(
onlineSourceRoot = "https://https://github.com/raquo/laminar-shoelace-components/blob/master",
customElementsJsonPath = "sljs/node_modules/@shoelace-style/shoelace/dist/custom-elements.json",
baseOutputDirectoryPath = "sljs/src/main/scala/com/raquo/laminar/shoelace/sl",
customElementsJsonPath = "node_modules/@shoelace-style/shoelace/dist/custom-elements.json",
baseOutputDirectoryPath = "src/main/scala/com/raquo/laminar/shoelace/sl",
baseOutputPackagePath = "com.raquo.laminar.shoelace.sl"
).generate()
}
)

lazy val shared = crossProject(JSPlatform, JVMPlatform)
.in(file("shared"))
.settings(noPublish)
.settings(commonSettings)

lazy val jvm = project
.in(file("sljvm"))
.dependsOn(shared.jvm)
.settings(noPublish)
.settings(commonSettings)

lazy val js = project
.in(file("sljs"))
.enablePlugins(ScalaJSPlugin)
.dependsOn(shared.js)
.settings(commonSettings)
.settings(
libraryDependencies ++= List(
"com.raquo" %%% "laminar" % Versions.Laminar % "provided"
),
(Compile / doc / scalacOptions) ++= Seq(
"-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings
),
scalacOptions ++= {
val sourcesUrl = s"https://raw.githubusercontent.com/raquo/laminar-shoelace-components/${git.gitHeadCommit.value.get}"
scalacOptions ++= Seq(
"-deprecation"
),
scalacOptions ++= sys.env.get("CI").map { _ =>
val localSourcesPath = baseDirectory.value.toURI
val remoteSourcesPath = s"https://raw.githubusercontent.com/raquo/laminar-shoelace-components/${git.gitHeadCommit.value.get}/"
val sourcesOptionName = if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
Seq(
s"${sourcesOptionName}:${file("js").toURI}->$sourcesUrl/js/",
s"${sourcesOptionName}:${file("shared").toURI}->$sourcesUrl/shared/"
)
}

s"${sourcesOptionName}:$localSourcesPath->$remoteSourcesPath"
},
)
.settings(
//name := "Laminar Shoelace",
name := "Laminar Shoelace",
normalizedName := "laminar-shoelace",
organization := "com.raquo",
homepage := Some(url("https://github.com/raquo/laminar-shoelace-components")),
Expand All @@ -92,25 +74,3 @@ lazy val js = project
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)

lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-deprecation"
)
)

lazy val noPublish = Seq(
publishLocal / skip := true,
publish / skip := true
)

// -- Aliases

// Run the frontend development loop (also run vite: `cd frontend; npm run dev`)
addCommandAlias("cup", ";~client/fastLinkJS")
// Start the backend server, and make sure to stop it afterwards
addCommandAlias("sup", ";server/reStop ;~server/reStart ;server/reStop")
// Build frontend for production
addCommandAlias("cbuild", ";buildClient")
// Package the application into a jar. Run the jar with: `java -jar dist/app.jar`
addCommandAlias("jar", ";packageApplication")
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "laminar-shoelace-components",
"private": true,
"version": "0.1.0",
"type": "module",
"devDependencies": {
"@shoelace-style/shoelace": "~2.11.2"
}
}
Loading

0 comments on commit 6e9300f

Please sign in to comment.