Skip to content

Commit

Permalink
update build to fix publish
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornregnell committed Jun 20, 2024
1 parent 8d4d0a6 commit 0afe773
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
41 changes: 39 additions & 2 deletions PUBLISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,51 @@ openpgp-revocs.d pubring.asc trustdb.gpg

4. In `sbt>` run `publishSigned` - a plus sign is not used since we only publish for Scala 3 from 1.2.0.

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

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

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

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`

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

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

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

Expand All @@ -109,3 +145,4 @@ openpgp-revocs.d pubring.asc trustdb.gpg
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

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

6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ publishConfiguration := publishConfiguration.value.withOverwrite(true)
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
//pushRemoteCacheConfiguration := pushRemoteCacheConfiguration.value.withOverwrite(true)

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

//https://oss.sonatype.org/#stagingRepositories
//https://oss.sonatype.org/#nexus-search;quick~se.lth.cs
//https://repo1.maven.org/maven2/se/lth/cs/introprog_2.12/

//usePgpKeyHex("E7232FE8B8357EEC786315FE821738D92B63C95F")

//https://github.com/sbt/sbt-pgp
//https://github.com/sbt/sbt-pgp

6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Add these magic comment lines starting with `//>` in the beginning of your Scala

```
//> using scala 3
//> using lib "se.lth.cs::introprog:1.4.0"
//> using dep "se.lth.cs::introprog:1.4.0"
```
You can choose the latest stable Scala version, or any version from at least Scala 3.3.3.

Expand All @@ -38,7 +38,7 @@ If your program looks like this:

```
//> using scala 3
//> using lib "se.lth.cs::introprog:1.4.0"
//> using dep "se.lth.cs::introprog:1.4.0"
@main def MyMain =
val w = introprog.PixelWindow()
Expand All @@ -52,7 +52,7 @@ See: [api documentation for PixelWindow](https://fileadmin.cs.lth.se/pgk/api/api

### Using sbt

If you have [sbt](https://www.scala-sbt.org/) installed then you can put this text in a file called `build.sbt`
If you have [sbt](https://www.scala-sbt.org/) installed at least version 1.10.0 then you can put this text in a file called `build.sbt`

```
scalaVersion := "3.4.2" // or any Scala version from at least 3.3.3
Expand Down

0 comments on commit 0afe773

Please sign in to comment.