Skip to content

Latest commit

 

History

History
148 lines (109 loc) · 10.1 KB

PUBLISH.md

File metadata and controls

148 lines (109 loc) · 10.1 KB

Instruction for repo maintainers

First two sections are preparations only done once for all or once per machine. Last comes what is done when actually publishing.

Already done once and for all: Setup publication to Sonatype

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:

Sbt config and GPG Key setup (done once per machine)

Read and adapt 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

How to publish

  1. Build and test locally using sbt "compile;test;doc"

  2. Bump lazy val Version in build.sbt, run package 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:

  1. 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:

    sbt> versionCheck
    sbt> versionPolicyCheck
    

    More information here:

  2. In sbt> run publishSigned - 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

  1. 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

  2. Click on Staging Repositories in the Build Promotion list to the left. Click "Refresh" if list is empty. https://oss.sonatype.org/#stagingRepositories

  3. 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

  4. 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.

  5. 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 or introprog.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.

  6. 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...

  7. 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.

  8. 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

  9. 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.