Skip to content

Commit e7a2ff2

Browse files
committed
update build+publishing add semVer plugin fix #16
1 parent 0446c26 commit e7a2ff2

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

PUBLISH.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,42 @@ openpgp-revocs.d pubring.asc trustdb.gpg
7070

7171
1. Build and test locally.
7272

73-
2. Bump version in `build.sbt`, run `sbt package`. We also want a release on github and the course home page aligned with the release on Sonatype Central. Therefore You should also:
73+
2. Bump `lazy val Version` in `build.sbt`, run `+ package` in sbt. We also want a release on github and the course home page aligned with the release on Sonatype Central. Therefore You should also:
7474
- Don't forget to update the `rootdoc.txt` file with current version information and package contents etc.: https://github.com/lunduniversity/introprog-scalalib/blob/master/src/rootdoc.txt
7575
- commit all changes and push and *then* create a github release with the packaged jar uploaded to https://github.com/lunduniversity/introprog-scalalib/releases
7676
- Publish the jar to the course home page at http://cs.lth.se/lib using `sh publish-jar.sh`
7777
- Publish updated docs to the course home page at http://cs.lth.se/api using script `sh publish-doc.sh`
7878
- Copy the introprog-scalalib/src the workspace subdir at https://github.com/lunduniversity/introprog to enable eclipse project generation with internal dependency of projects using `sh publish-workspace.sh`. Then run `sbt eclipse` IN THAT repo and `sh package.sh` to create `workspace.zip` etc. TODO: For the future it would be **nice** to have another repo introprog-workspace and factor out code to that repo and solve the problem of dependency between latex code and the workspace.
7979
- Update the link http://www.cs.lth.se/pgk/lib in typo3 so that it links to the right http://fileadmin.cs.lth.se/pgk/introprog_2.12-x.y.z.jar
8080

81-
3. In `sbt` run `publishSigned`
81+
3. In build.sbt set the key `ThisBuild / versionPolicyIntention := ` to one of `Compatibility.None`, `Compatibility.BinaryAndSourceCompatible` or `Compatibility.BinaryCompatible` depending on what is intended. Then run these checks in the sbt shell:
82+
```
83+
sbt> versionCheck
84+
sbt> versionPolicyCheck
85+
```
86+
More information here:
87+
* https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html
88+
* https://www.youtube.com/watch?v=0T3vBnYCXn4
89+
* https://www.scala-sbt.org/1.x/docs/Publishing.html#Version+scheme
90+
* https://eed3si9n.com/enforcing-semver-with-sbt-strict-update
8291

83-
4. Log into Sonatype Nexus here: (if the page does not load, clear the browser's cache by pressing Ctrl+F5) https://oss.sonatype.org/#welcome
8492

85-
5. Click on *Staging Repositories* in the Build Promotion list to the left. Click "Refresh" if list is empty. https://oss.sonatype.org/#stagingRepositories
93+
4. In `sbt>` run `+ publishSigned` - the plus is needed to cross publish all versions. See https://www.scala-sbt.org/1.x/docs/Cross-Build.html
8694

87-
6. Scroll down and select selthcs-100X and select the *Contents* tab and expand until leaf level of the tree where you can see the `introprog_3-x.y.z.jar`
95+
5. Log into Sonatype Nexus here: (if the page does not load, clear the browser's cache by pressing Ctrl+F5) https://oss.sonatype.org/#welcome
8896

89-
7. Download the staged jar by clicking on it and selecting the *Artifact* tab to the right and click the Repository Path to download. Save it e.g. in `tmp`.
97+
6. Click on *Staging Repositories* in the Build Promotion list to the left. Click "Refresh" if list is empty. https://oss.sonatype.org/#stagingRepositories
9098

91-
8. Verify that the staged jar downloaded from sonatype works by running `scala -cp introprog_3-x.y.z.jar` and in REPL e.g. `val w = new introprog.PixelWindow`. The reason for this step is that there has been incidents where the uploading has failed and the jar was empty. A published jar can not be retracted even if corrupted according to Sonatype policies.
99+
7. Scroll down and select something similar to `selthcs-100X` and select the *Contents* tab and expand until leaf level of the tree where you can see the `introprog_3-x.y.z.jar`
92100

93-
9. Click the *Close* icon with a diskett above the repository list to "close" the staging repository. No need to write anything in the "Description" field in the popup. It has happened that the Close failed - then the repo is still "Open" so try to close it again and hope it works this time...
101+
8. Download the staged jar by clicking on it and selecting the *Artifact* tab to the right and click the Repository Path to download. Save it e.g. in `tmp`.
94102

95-
10. After a while (typically a couple of minutes) the *Release* icon with a chain above the repository list is enabled. Click it when enabled. You can keep the "Automatically Drop" checkbox checked, which means that when the repo is published on Central the staging repo is removed from the list.
103+
9. Verify that the staged jar downloaded from sonatype works by running `scala -cp introprog_3-x.y.z.jar` and in REPL e.g. `val w = new introprog.PixelWindow`. The reason for this step is that there has been incidents where the uploading has failed and the jar was empty. A published jar can not be retracted even if corrupted according to Sonatype policies.
96104

97-
11. By searching here you can see the repo in progress of being published but it takes a while before it is publicly visible on Central (typically 10-15 minutes). https://oss.sonatype.org/#nexus-search;quick~se.lth.cs
105+
10. Click the *Close* icon with a diskett above the repository list to "close" the staging repository. No need to write anything in the "Description" field in the popup. It has happened that the Close failed - then the repo is still "Open" so try to close it again and hope it works this time...
98106

99-
12. When visible on Central at https://repo1.maven.org/maven2/se/lth/cs/introprog_3/ verify with a simple sbt project that it works as shown in [README usage instructions for sbt](https://github.com/lunduniversity/introprog-scalalib/blob/master/README.md#using-sbt).
107+
11. After a while (typically a couple of minutes) the *Release* icon with a chain above the repository list is enabled. Click it when enabled. You can keep the "Automatically Drop" checkbox checked, which means that when the repo is published on Central the staging repo is removed from the list.
108+
109+
12. By searching here you can see the repo in progress of being published but it takes a while before it is publicly visible on Central (typically 10-15 minutes). https://oss.sonatype.org/#nexus-search;quick~se.lth.cs
110+
111+
13. When visible on Central at https://repo1.maven.org/maven2/se/lth/cs/introprog_3/ verify with a simple sbt project that it works as shown in [README usage instructions for sbt](https://github.com/lunduniversity/introprog-scalalib/blob/master/README.md#using-sbt).

build.sbt

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,32 @@ lazy val scala213 = "2.13.6"
44
lazy val scala3 = "3.0.0"
55
lazy val supportedScalaVersions = List(scala213, scala3)
66

7-
// to avoid strange warnings, these three lines are needed
7+
// to avoid strange warnings, these lines with excludeLintKeys are needed:
88
Global / excludeLintKeys += ThisBuild / Compile / console / fork
99
Global / excludeLintKeys += ThisBuild / Compile / doc / scalacOptions
10-
Global / excludeLintKeys += ThisBuild / name
1110

12-
ThisBuild / name := Name
13-
ThisBuild / version := Version
14-
ThisBuild / scalaVersion := scala3
11+
12+
lazy val introprog = (project in file("."))
13+
.settings(
14+
name := Name,
15+
version := Version,
16+
scalaVersion := scala3,
17+
crossScalaVersions := supportedScalaVersions,
18+
)
1519

1620
ThisBuild / Compile / console / fork := true
1721

18-
ThisBuild / crossScalaVersions := supportedScalaVersions
22+
//https://github.com/scalacenter/sbt-version-policy
23+
ThisBuild / versionScheme := Some("early-semver")
24+
ThisBuild / versionPolicyIntention := Compatibility.None
25+
//ThisBuild / versionPolicyIntention := Compatibility.BinaryAndSourceCompatible
26+
//ThisBuild / versionPolicyIntention := Compatibility.BinaryCompatible
27+
28+
//In the sbt shell check version using:
29+
//sbt> versionCheck
30+
//sbt> versionPolicyCheck
31+
//sbt> last versionPolicyFindDependencyIssues
32+
//sbt> last mimaPreviousClassfiles
1933

2034
ThisBuild / scalacOptions ++= Seq(
2135
"-encoding", "UTF-8",
@@ -44,8 +58,8 @@ ThisBuild / Compile / doc / scalacOptions ++= Seq(
4458

4559
// Below enables publishing to central.sonatype.org
4660
// see PUBLISH.md for instructions
47-
// usage inside sbt:
48-
// sbt> publishSigned
61+
// usage inside sbt: BUT READ PUBLISH.md FIRST - the plus is needed for cross building all versions
62+
// sbt> + publishSigned
4963
// DON'T PANIC: it takes looong time to run it
5064

5165
ThisBuild / organization := "se.lth.cs"
@@ -82,13 +96,7 @@ ThisBuild / publishMavenStyle := true
8296

8397
publishConfiguration := publishConfiguration.value.withOverwrite(true)
8498
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
85-
//pushRemoteCacheConfiguration := pushRemoteCacheConfiguration.value.withOverwrite(true)
86-
87-
88-
lazy val introprog = (project in file("."))
89-
.settings(
90-
name := Name,
91-
)
99+
//pushRemoteCacheConfiguration := pushRemoteCacheConfiguration.value.withOverwrite(true)
92100

93101
//https://oss.sonatype.org/#stagingRepositories
94102
//https://oss.sonatype.org/#nexus-search;quick~se.lth.cs

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// https://github.com/scalacenter/sbt-version-policy
2+
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "1.0.1")

0 commit comments

Comments
 (0)