Skip to content

Commit

Permalink
Added publishing to sonatype
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Sep 21, 2021
1 parent 16ed849 commit 95a3c70
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 12 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]

Expand Down Expand Up @@ -35,22 +37,14 @@ jobs:
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/**/*.scala') }}
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt', 'project/**/*.scala') }}

- name: Cache Node
- name: Cache node_modules
uses: actions/cache@v2
with:
path: |
~/.npm
~/.nvm
key: ${{ runner.os }}-node-cache-v2-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-cache-v2-
- name: Cache node_modules
uses: actions/cache@v2
with:
path: |
~/work/scommons-material-ui/scommons-material-ui/codegen/target/scala-2.13/scalajs-bundler/test/node_modules
~/work/scommons-material-ui/scommons-material-ui/codegen/target/scala-2.13/scalajs-bundler/test/package-lock.json
~/work/scommons-material-ui/scommons-material-ui/core/target/scala-2.13/scalajs-bundler/test/node_modules
Expand All @@ -59,11 +53,29 @@ jobs:
~/work/scommons-material-ui/scommons-material-ui/test/target/scala-2.13/scalajs-bundler/test/package-lock.json
~/work/scommons-material-ui/scommons-material-ui/showcase/target/scala-2.13/scalajs-bundler/test/node_modules
~/work/scommons-material-ui/scommons-material-ui/showcase/target/scala-2.13/scalajs-bundler/test/package-lock.json
key: ${{ runner.os }}-node_modules-cache-v2-${{ hashFiles('project/**/*.scala') }}
key: ${{ runner.os }}-node_modules-cache-v2-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node_modules-cache-v2-
- name: Run tests
run: sbt coverage test && sbt coverageAggregate coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Extract Tag Name
run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV && echo "TAG_NAME=$TAG_NAME"
if: startsWith(github.ref, 'refs/tags')

- name: Publish SNAPSHOT
run: sbt clean publish
if: ${{ !github.event.pull_request && env.TAG_NAME == '' }}
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

- name: Publish RELEASE
run: echo "TAG_NAME=$TAG_NAME"
if: env.TAG_NAME != ''
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,63 @@

## Scala Commons Material UI

Scala.js facades for [Material-UI (v4)](https://v4.mui.com/getting-started/usage/) components and APIs.

It uses common [scalajs-reactjs](https://github.com/shogowada/scalajs-reactjs) binding/facade library.

### How to add it to your project

```scala
val scommonsMaterialUiVer = "1.0.0-SNAPSHOT"

libraryDependencies ++= Seq(
"org.scommons.material-ui" %%% "scommons-material-ui-core" % scommonsMaterialUiVer,

// mocks of native Components and APIs
"org.scommons.material-ui" %%% "scommons-material-ui-test" % scommonsMaterialUiVer % "test"
)
```

Latest `SNAPSHOT` version is published to [Sonatype Repo](https://oss.sonatype.org/content/repositories/snapshots/org/scommons/), just make sure you added
the proper dependency resolver to your `build.sbt` settings:
```scala
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
```

### Quick Start

```scala
import io.github.shogowada.scalajs.reactjs.ReactDOM
import org.scalajs.dom
import scommons.materialui._
import scommons.materialui.styles._
import scommons.react._

object App extends FunctionComponent[Unit] {

protected def render(compProps: Props): ReactElement = {
<.Button(^.variant := "contained", ^.color := "primary")(
"Hello World"
)
}
}

object AppMain {

def main(args: Array[String]): Unit = {
val mountNode = dom.document.getElementById("root")

dom.document.title = "Demo material-ui app"

ReactDOM.render(<(App()).empty, mountNode)
}
}
```

### Components Demos

Please, see [README.md in showcase](showcase/README.md) sub-folder
for how to build and run showcase app locally.

* [Button](https://v4.mui.com/components/buttons/) => [demos](showcase/src/main/scala/scommons/materialui/showcase/button) => [tests](showcase/src/test/scala/scommons/materialui/showcase/button)
* ...TBD
12 changes: 12 additions & 0 deletions project/sonatype.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

val maybeCredentials = for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)

credentials ++= maybeCredentials.toSeq
1 change: 1 addition & 0 deletions project/src/main/scala/definitions/MaterialUiModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object MaterialUiModule {
//
// publish/release related settings:
//
sonatypeProfileName := "org.scommons",
publishMavenStyle := true,
publishArtifact in Test := false,
publishTo := sonatypePublishToBundle.value,
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := sys.env.getOrElse("version", default = "0.1.0-SNAPSHOT").stripPrefix("v")
version in ThisBuild := sys.env.getOrElse("version", default = "1.0.0-SNAPSHOT").stripPrefix("v")

0 comments on commit 95a3c70

Please sign in to comment.