diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..06e387f --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,31 @@ +name: Check + +on: + pull_request: + + push: + branches: + - main # Check branch after merge + +concurrency: + # Only run once for latest commit per ref and cancel other (previous) runs. + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Tests + uses: playframework/.github/.github/workflows/cmd.yml@v3 + with: + java: 21, 17, 11 + scala: 2.13.x, 3.x + cmd: | + sudo apt-get install -y memcached + sbt ++$MATRIX_SCALA test + + finish: + name: Finish + if: github.event_name == 'pull_request' + needs: # Should be last + - "tests" + uses: playframework/.github/.github/workflows/rtm.yml@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..bada8b1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +name: Publish + +on: + push: + branches: # Snapshots + - main + tags: ["**"] # Releases + +jobs: + publish-artifacts: + name: JDK 11 + runs-on: ubuntu-20.04 + if: ${{ github.repository_owner == 'mumoshu' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + id: coursier-cache + uses: coursier/cache-action@v6 + + - name: Install memcached + run: sudo apt-get install -y memcached + + - name: Install Adoptium Temurin OpenJDK + uses: coursier/setup-action@v1 + with: + jvm: adoptium:8 + + - name: Publish artifacts + run: sbt ci-release + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + + - name: Cleanup before cache + shell: bash + run: | + find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true + find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b6dfb93..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: scala -scala: - - 2.13.12 - - 3.3.1 -services: - - memcache -env: - - PLAY_VERSION=2.9.0 TRAVIS_JDK=11 -# see https://github.com/travis-ci/travis-ci/issues/5227#issuecomment-165131913 -before_install: - - curl -Ls https://git.io/jabba | bash && . ~/.jabba/jabba.sh - - cat /etc/hosts - - sudo hostname "$(hostname | cut -c1-63)" - - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts - - sudo mv /tmp/hosts /etc/hosts - - cat /etc/hosts -install: jabba install "adopt@~1.$TRAVIS_JDK.0-0" && jabba use "$_" && java -Xmx32m -version -# see https://docs.travis-ci.com/user/languages/scala#Default-Test-Command about $TRAVIS_SCALA_VERSION -script: - - sbt ++$TRAVIS_SCALA_VERSION test diff --git a/README.md b/README.md index 96c2978..496e5bd 100644 --- a/README.md +++ b/README.md @@ -360,28 +360,14 @@ Configure your configuration endpoint in `application.conf`: 0.12.0 Built for Play 2.9.0 and Scala 2.13.12 and 3.3.1. Artifact ID for this build is `play2-memcached-play29_[2.13|3]` -### Publishing to the central +### Releasing play2-memcached / Publishing to the maven central -``` -# Play 2.5 -PLAY_VERSION=2.5.0 sbt ++2.11.12 publishSigned sonatypeRelease - -# Play 2.6 -PLAY_VERSION=2.6.0 sbt ++2.12.8 publishSigned sonatypeRelease - -# Play 2.7 -PLAY_VERSION=2.7.3 sbt ++2.11.12 publishSigned sonatypeRelease -PLAY_VERSION=2.7.3 sbt ++2.12.8 publishSigned sonatypeRelease -PLAY_VERSION=2.7.3 sbt ++2.13.0 publishSigned sonatypeRelease +1. Tag the release: `git tag -s 1.2.3` +1. Push tag: `git push upstream 1.2.3` +1. GitHub action workflow does the rest: https://github.com/mumoshu/play2-memcached/actions/workflows/publish.yml + - Snapshots are published to https://oss.sonatype.org/content/repositories/snapshots/com/github/mumoshu/ + - Releases are published to https://repo1.maven.org/maven2/com/github/mumoshu/ (takes up to 1 hour) -# Play 2.8 -PLAY_VERSION=2.8.0 sbt ++2.12.10 publishSigned sonatypeRelease -PLAY_VERSION=2.8.0 sbt ++2.13.1 publishSigned sonatypeRelease - -# Play 2.9 -PLAY_VERSION=2.9.0 sbt ++2.13.12 publishSigned sonatypeRelease -PLAY_VERSION=2.9.0 sbt ++3.3.1 publishSigned sonatypeRelease -``` ### Acknowledgement diff --git a/build.sbt b/build.sbt index f96e932..dd218a2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,4 @@ val appName = "play2-memcached-" + playShortName -val appVersion = "0.12.0-SNAPSHOT" val spymemcached = "net.spy" % "spymemcached" % "2.12.3" val h2databaseTest = "com.h2database" % "h2" % "2.2.224" % Test @@ -15,11 +14,20 @@ def playShortName: String = { s"play$majorMinor" } +// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed +ThisBuild / dynverVTagPrefix := true + +// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone) +// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version +Global / onLoad := (Global / onLoad).value.andThen { s => + dynverAssertTagVersion.value + s +} + lazy val root = Project("root", base = file(".")) .settings(baseSettings: _*) .settings( - publishLocal := {}, - publish := {} + publish / skip := true, ).aggregate(plugin, scalaSample, javaSample) lazy val plugin = Project(appName, base = file("plugin")) @@ -31,38 +39,16 @@ lazy val plugin = Project(appName, base = file("plugin")) libraryDependencies += cacheApi % Provided, libraryDependencies += specs2 % Test, organization := "com.github.mumoshu", - version := appVersion, //scalacOptions += "-deprecation", - publishTo := { - val v = version.value - val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots") - else Some("releases" at nexus + "service/local/staging/deploy/maven2") - }, - publishMavenStyle := true, Test / publishArtifact := false, pomIncludeRepository := { _ => false }, - pomExtra := ( - https://github.com/mumoshu/play2-memcached - - - BSD-style - http://www.opensource.org/licenses/bsd-license.php - repo - - - - git@github.com:mumoshu/play2-memcached.git - scm:git:git@github.com:mumoshu/play2-memcached.git - - - - you - KUOKA Yusuke - https://github.com/mumoshu - - - ), + licenses := Seq("Apache License" -> url("https://github.com/mumoshu/play2-memcached/blob/main/LICENSE")), + developers += Developer( + "you", + "KUOKA Yusuke", + "you", + url("https://github.com/mumoshu") + ), Compile/ unmanagedSourceDirectories := { (Compile / unmanagedSourceDirectories).value ++ Seq((Compile / sourceDirectory).value) }, @@ -79,8 +65,7 @@ lazy val scalaSample = Project( .settings( libraryDependencies += cacheApi, libraryDependencies += h2databaseTest, - publishLocal := {}, - publish := {} + publish / skip := true, ).dependsOn(plugin) lazy val javaSample = Project( @@ -91,6 +76,5 @@ lazy val javaSample = Project( .settings( libraryDependencies += cacheApi, libraryDependencies += h2databaseTest, - publishLocal := {}, - publish := {} + publish / skip := true, ).dependsOn(plugin) diff --git a/project/plugins.sbt b/project/plugins.sbt index d86f12e..b845c70 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,5 @@ ivyLoggingLevel := UpdateLogging.Full -val playVersion = scala.util.Properties.envOrElse("PLAY_VERSION", "2.9.0") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % playVersion) - -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0") - -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") diff --git a/publish.sh b/publish.sh deleted file mode 100755 index d85041f..0000000 --- a/publish.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -PLAY_VERSION=2.8.0 sbt ++2.12.10 publishSigned sonatypeRelease -PLAY_VERSION=2.8.0 sbt ++2.13.1 publishSigned sonatypeRelease diff --git a/sonatype.sbt b/sonatype.sbt deleted file mode 100644 index 26603f3..0000000 --- a/sonatype.sbt +++ /dev/null @@ -1,3 +0,0 @@ -import xerial.sbt.Sonatype._ - -sonatypeProfileName := "com.github.mumoshu"