Skip to content

Commit

Permalink
Simplify releasing of cross-Scala.js projects (#97)
Browse files Browse the repository at this point in the history
Simplify releasing of cross-Scala.js projects
  • Loading branch information
olafurpg authored Jan 19, 2020
2 parents 9f793fd + 0951137 commit b0db066
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "2.3.2"
project.git = true
9 changes: 6 additions & 3 deletions plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object CiReleasePlugin extends AutoPlugin {
System.getenv("PGP_SECRET") != null
def isTag: Boolean =
Option(System.getenv("TRAVIS_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("CIRCLE_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("CIRCLE_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("BUILD_SOURCEBRANCH"))
.orElse(Option(System.getenv("GITHUB_REF")))
.exists(_.startsWith("refs/tags"))
Expand Down Expand Up @@ -62,7 +62,7 @@ object CiReleasePlugin extends AutoPlugin {
System.getenv("TF_BUILD") == "True"
def isGithub: Boolean =
System.getenv("GITHUB_ACTION") != null
def isCircleCi: Boolean =
def isCircleCi: Boolean =
System.getenv("CIRCLECI") == true

def setupGpg(): Unit = {
Expand Down Expand Up @@ -141,7 +141,10 @@ object CiReleasePlugin extends AutoPlugin {
println("Tag push detected, publishing a stable release")
reloadKeyFiles ::
sys.env.getOrElse("CI_RELEASE", "+publishSigned") ::
sys.env.getOrElse("CI_SONATYPE_RELEASE", "sonatypeBundleRelease") ::
sys.env.getOrElse(
"CI_SONATYPE_RELEASE",
"; sonatypeBundleClean ; sonatypeBundleRelease"
) ::
currentState
}
}
Expand Down
46 changes: 38 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ and post the signature to a keyserver: http://keyserver.ubuntu.com:11371/

1. Select "Submit Key"
2. Paste in the exported public key
3. Click on "Submit
Public Key".
3. Click on "Submit Public Key".

![Ubuntu Keyserver](https://i.imgur.com/njvOpmq.png)

Expand Down Expand Up @@ -262,10 +261,10 @@ git push origin v0.1.0

Note that the tag version MUST start with `v`.

It is normal that something fails on the first attempt to publish from CI.
Even if it takes 10 attempts to get it right, it's still worth it because it's
so nice to have automatic CI releases. If all is correctly setup, your Travis
jobs page will look like this:
It is normal that something fails on the first attempt to publish from CI. Even
if it takes 10 attempts to get it right, it's still worth it because it's so
nice to have automatic CI releases. If all is correctly setup, your Travis jobs
page will look like this:

<img width="1058" alt="screen shot 2018-06-23 at 15 48 43" src="https://user-images.githubusercontent.com/1408093/41810386-b8c11198-76fd-11e8-8be1-54b84181e60d.png">

Expand Down Expand Up @@ -296,6 +295,32 @@ lazy val core = project.settings(
The command `+publishSigned` (default value for `CI_RELEASE`) will then publish
that project for 2.11, 2.12 and 2.13.

### How do I publish cross-built Scala.js projects?

If you publish for multiple Scala.js versions, start by disabling publishing of
the non-JS projects when the `SCALAJS_VERSION` environment variable is defined.

```diff
// build.sbt
+ val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))
lazy val myLibrary = crossProject(JSPlatform, JVMPlatform)
.settings(
// ...
)
+ .jvmSettings(
+ skip.in(publish) := customScalaJSVersion.isDefined
+ )
```

Next, add an additional `ci-release` step in your CI config to publish the
custom Scala.js version

```diff
// .travis.yml
sbt ci-release
+ SCALAJS_VERSION=0.6.31 sbt ci-release
```

### Can I depend on Maven Central releases immediately?

Yes! As soon as CI "closes" the staging repository you can depend on those
Expand Down Expand Up @@ -329,7 +354,8 @@ coursier fetch com.geirsson:scalafmt-cli_2.12:1.5.0-SNAPSHOT -r sonatype:snapsho

### What about other CIs environments than Travis?

- This project uses a github workflow, [which you can review here](https://github.com/olafurpg/sbt-ci-release/tree/master/.github/workflows)
- This project uses a github workflow,
[which you can review here](https://github.com/olafurpg/sbt-ci-release/tree/master/.github/workflows)
- [CircleCI](https://circleci.com/) is supported

You can try
Expand Down Expand Up @@ -381,7 +407,11 @@ and drop the failing repository from the web UI. Alternatively, you can run
`sonatypeDrop <staging-repo-id>` from the sbt shell instead of using the web UI.

### How do I create release notes? Can they be automatically generated?
We think that the creation of release notes should not be fully automated because commit messages don't often communicate the end user impact well. You can use [Release Drafter](https://github.com/apps/release-drafter) github app (or the Github Action) to help you craft release notes.

We think that the creation of release notes should not be fully automated
because commit messages don't often communicate the end user impact well. You
can use [Release Drafter](https://github.com/apps/release-drafter) github app
(or the Github Action) to help you craft release notes.

## Adopters

Expand Down

0 comments on commit b0db066

Please sign in to comment.