Skip to content

modernize publishing #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
publish / skip := true // root project

lazy val scalaTestVersion = "3.2.3"

lazy val commonSettings = Seq(
crossScalaVersions := Seq("3.0.0-M1", "2.13.3", "2.12.12", "2.11.12"),
scalaVersion := "2.13.3",
scalacOptions ++= Seq("-deprecation", "-feature"),
)

Expand All @@ -13,7 +13,7 @@ lazy val swing = project.in(file("."))
.settings(
name := "scala-swing",
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}"),
scalaModuleMimaPreviousVersion := Some("2.1.0"),
// scalaModuleMimaPreviousVersion := Some("2.1.0"), TODO re-enable after we have a 3.0 release
// set the prompt (for this build) to include the project id.
ThisBuild / shellPrompt := { state => Project.extract(state).currentRef.project + "> " },
libraryDependencies ++= Seq(
Expand All @@ -38,7 +38,8 @@ lazy val examples = project.in(file("examples"))
.settings(
scalaVersion := (swing / scalaVersion).value,
run / fork := true,
fork := true
fork := true,
publish / skip := true,
)

lazy val uitest = project.in(file("uitest"))
Expand All @@ -47,5 +48,6 @@ lazy val uitest = project.in(file("uitest"))
.settings(
scalaVersion := (swing / scalaVersion).value,
run / fork := true,
fork := true
fork := true,
publish / skip := true,
)
47 changes: 18 additions & 29 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ set -e
# sbt-dynver sets the version number from the tag
# sbt-travisci sets the Scala version from the travis job matrix

# When a new binary incompatible Scala version becomes available, a previously released version
# can be released using that new Scala version by creating a new tag containing the Scala version
# after a hash, e.g., v1.2.3#2.13.0-M3.
# To back-publish an existing release for a new Scala / Scala.js / Scala Native version:
# - check out the tag for the version that needs to be published
# - change `.travis.yml` to adjust the version numbers and trim down the build matrix as necessary
# - commit the changes and tag this new revision with an arbitrary suffix after a hash, e.g.,
# `v1.2.3#dotty-0.27` (the suffix is ignored, the version will be `1.2.3`)

# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
# We release on JDK 8 (for Scala 2.x and 3.x)
isReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" ]]; then
true
Expand All @@ -23,43 +25,30 @@ isReleaseJob() {
fi
}

# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases
isTagScalaReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
true
else
false
fi
}
if [[ "$SCALAJS_VERSION" == "" ]]; then
projectPrefix=""
else
projectPrefix=""
fi

verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
tagPat="^v$verPat(#$verPat)?$"
tagPat="^v$verPat(#.*)?$"

if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
releaseTask="ci-release"
tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
if [[ "$tagScalaVer" == "" ]]; then
if ! isReleaseJob; then
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
exit 0
fi
else
if isTagScalaReleaseJob; then
setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"'
else
echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix"
exit 0
fi
if ! isReleaseJob; then
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
exit 0
fi
fi

# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions
export CI_RELEASE="publishSigned"
export CI_SNAPSHOT_RELEASE="publish"
export CI_RELEASE="${projectPrefix}publishSigned"
export CI_SNAPSHOT_RELEASE="${projectPrefix}publish"

# default is sonatypeBundleRelease, which closes and releases the staging repo
# see https://github.com/xerial/sbt-sonatype#commands
# for now, until we're confident in the new release scripts, just close the staging repo.
export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose"

sbt "$setTagScalaVersion" clean test publishLocal $releaseTask
sbt clean ${projectPrefix}test ${projectPrefix}publishLocal $releaseTask