First two sections are preparations only done once for all or once per machine. Last comes what is done when actually publishing.
These instructions have already been followed for this repo by Bjorn Regnell who has claimed the name space se.lth.cs and the artefact id introprog:
-
https://www.scala-sbt.org/release/docs/Using-Sonatype.html#Sonatype+setup
-
Instruction videos: https://central.sonatype.org/pages/ossrh-guide.html
-
New project ticket (requires login to Jira): https://issues.sonatype.org/browse/OSSRH-42634?filter=-2
Read and adapt these instructions:
- https://www.scala-sbt.org/release/docs/Using-Sonatype.html
-
Be aware that step 1 was not used, instead the instructions from this link were used to create keys:
-
Step 2-4 from above was used. Then after key generation, step 5 should work according to "How to publish" below. See the last parts of this repo's
build.sbt
and these instructions:
-
Issue commands below one at a time to make files in ~/.sbt/
and key pair in ascii in ~/.sbt/gpg
and publish key in ~/ci-keys
and then copy to .sbt/gpg
tested on Ubuntu 18.04 using gpg --version
at 2.2.4.
cd ~
mkdir ci-keys
chmod -R go-rwx ci-keys
cd ci-keys
gpg --homedir . --gen-key
gpg --homedir . -a --export > pubring.asc
gpg --homedir . -a --export-secret-keys > secring.asc
gpg --homedir . --list-key
# <copy> the pub hex string e.g E7232FE8B8357EEC786315FE821738D92B63C95F
gpg --homedir . --keyserver hkp://pool.sks-keyservers.net --send-keys <paste>
gpg --homedir . --keyserver hkp://pgp.mit.edu --send-keys E7232FE8B8357EEC786315FE821738D92B63C95F
mkdir -p ~/.sbt/gpg
cd ~/.sbt/gpg
cp -R ~/ci-keys/* .
After this you should have this these files ~/.sbt/gpg
:
$ cat ~/.sbt/1.0/plugins/gpg.sbt
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
$ cat ~/.sbt/sonatype_credential
realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=<YOURUSERID>
password=<YOURPASSWORD>
$ cat ~/.sbt/1.0/sonatype.sbt
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential")
$ ls ~/.sbt/gpg
crls.d private-keys-v1.d pubring.kbx secring.asc
openpgp-revocs.d pubring.asc trustdb.gpg
- See more info here:
-
Build and test locally using
sbt "compile;test;doc"
-
Bump
lazy val Version
inbuild.sbt
, runpackage
in sbt. Note no plus before package as from 1.2.0 we only publish for Scala 3. We also want a release on github and the course home page aligned with the release on Sonatype Central. Therefore You should also:
- Don't forget to update the
doc/index.md
file with current version information and package contents etc. Read more on scaladoc here: https://docs.scala-lang.org/scala3/scaladoc.html - commit all changes and push and then create a github release with the packaged jar uploaded to https://github.com/lunduniversity/introprog-scalalib/releases
- Publish the jar to the course home page at http://cs.lth.se/lib using
sh publish-jar.sh
- Publish updated docs to the course home page at http://cs.lth.se/api using script
sh publish-doc.sh
- 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 runsbt eclipse
IN THAT repo andsh package.sh
to createworkspace.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. - 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_3-x.y.z.jar
-
In build.sbt set the key
ThisBuild / versionPolicyIntention :=
to one ofCompatibility.None
,Compatibility.BinaryAndSourceCompatible
orCompatibility.BinaryCompatible
depending on what is intended. Then run these checks in the sbt shell:sbt> versionCheck sbt> versionPolicyCheck
More information here:
-
In
sbt>
runpublishSigned
- a plus sign is not used since we only publish for Scala 3 from 1.2.0.
Note: It is falsely said to be sbt publish
according to https://www.scala-sbt.org/1.x/docs/Publishing.html but you need to use sbt publishSigned
after creating a .credentials file in ~/.sbt including below where xxx and yyy is replaced with secret values that is access according to https://central.sonatype.org/publish/generate-token/ If you do just publish
you will get an error later in the process after closing below that complains that .asc files are missing etc.
Put .credentials in ~/.sbt
realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=xxx
password=yyy
When I did publishSIgend last time I got these errors but the publishing went through anyway with the above .credentials in ~/.sbt:
sbt:introprog> publishSigned
[info] Wrote /home/bjornr/git/hub/lunduniversity/introprog-scalalib/target/scala-3.3.3/introprog_3-1.4.0.pom
[warn] multiple main classes detected: run 'show discoveredMainClasses' to see the list
[error] gpg: Warning: not using 'E7232FE8B8357EEC786315FE821738D92B63C95F' as default key: No secret key
[error] gpg: all values passed to '--default-key' ignored
[error] gpg: Warning: not using 'E7232FE8B8357EEC786315FE821738D92B63C95F' as default key: No secret key
[error] gpg: all values passed to '--default-key' ignored
[error] gpg: Warning: not using 'E7232FE8B8357EEC786315FE821738D92B63C95F' as default key: No secret key
[error] gpg: all values passed to '--default-key' ignored
[error] gpg: Warning: not using 'E7232FE8B8357EEC786315FE821738D92B63C95F' as default key: No secret key
[error] gpg: all values passed to '--default-key' ignored
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0.pom.asc
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0-javadoc.jar
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0.pom
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0.jar.asc
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0.jar
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0-javadoc.jar.asc
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0-sources.jar
[info] published introprog_3 to https://oss.sonatype.org/service/local/staging/deploy/maven2/se/lth/cs/introprog_3/1.4.0/introprog_3-1.4.0-sources.jar.asc
OOOPS! TODO: I already had this file: cat ~/.sbt/sonatype_credential
pulled in by cat ~/.sbt/1.0/sonatype.sbt
so I should remove the last of them as Credentials is now included in the build.sbt
-
After you have done
sbt publishSigned
then 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 -
Click on Staging Repositories in the Build Promotion list to the left. Click "Refresh" if list is empty. https://oss.sonatype.org/#stagingRepositories
-
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 theintroprog_3-x.y.z.jar
-
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
. -
Verify that the staged jar downloaded from sonatype works by running something similar to
scala-cli repl . -S 3.4.2 --jar introprog_3-1.4.0.jar
and in REPL e.g.val w = new introprog.PixelWindow
orintroprog.examples.TestPixelWindow.main(Array())
. 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. -
Click the Close icon with a diskette 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...
-
Click the green arrow "Refresh" icon. Mark the Repository in the list by clicking the check-mark square to the left of th repo name similar to "selthcs-1015". After a while (typically a couple of minutes) the Release icon with a chain above the repository list is enabled. If it is not enabled the wait some minutes and click "Refresh" again. Click "Release" when enabled. In the dialog that appears 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.
-
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
-
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.