Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETCM-[165, 166]: Publish the RLP and Crypto libraries to Sonatype. #933

Merged
merged 11 commits into from
Apr 13, 2021

Conversation

aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Mar 1, 2021

Description

Add steps to the CI pipeline to publish the mantis-rlp and mantis-crypto artifacts to Sonatype so they can be reused in other projects.

On the develop branch, the version is expected to be -SNAPSHOT, so it can overwrite previous versions.
On the master branch the version is set to release by removing -SNAPSHOT, so it can only be released once.

After that it's expected that develop should have a bump in version, but that's currently not part of the automation.

Proposed Solution

This is based of what we're currently doing in scalanet: instead of a version file I added a version.sbt file which could be used by sbt-release to bump and commit a new version, as described here, but currently it's just updated from the publish.sh script for the release, it's not committed and pushed back to Github. See the SBT guide for the Sonatype settings.

Ended up using this plugin: https://github.com/olafurpg/sbt-ci-release
What needs to be published is set int the publish.sh script using environment variables used by the plugin.

Its default assumption is that it will do a release if the build is tagged in git, and push a snapshot if it's just a normal commit. Tagging is faked in the publish script at the moment, but if the release strategy were to change, it would be easy to modify it that way.

To make it work we added the following environment variables to the build:

  • GPG_KEY: GPG key used to sign the published artifacts, in Base64 format (see the sbt-ci-release plugin for the command to produce it)
  • GPG_KEY_ID: ID of the GPG key, to tell the SBT plugin which key to use
  • GPG_PASSPHRASE: Pass phrase to import the GPG key
  • OSS_USERNAME: Sonatype username
  • OSS_PASSWORD: Sonatype password

Important Changes Introduced

Added -SNAPSHOT to the version, which is stored in version.sbt.

Testing

I temporarily left the name of this branch as a conditional, which resulted in the SNAPSHOT versions being published.

See the logs on Buildkite.

@aakoshh aakoshh requested a review from KonradStaniec March 1, 2021 12:15
@aakoshh aakoshh force-pushed the ETCM-165-publish branch from 3b8eabd to cd00d63 Compare March 1, 2021 12:18
@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 1, 2021

@KonradStaniec can you add the required credentials to the build? I don't know the values.

@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 1, 2021

It would be nice if the pipeline.nix could use wait steps so publishing only happens if everything worked fine. I should see if that works.

@aakoshh aakoshh requested a review from dzajkowski March 1, 2021 16:07
@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 1, 2021

Apparently we should try to get a Mantis specific Sonatype account and PGP key.

@aakoshh aakoshh added the blocked label Mar 2, 2021
@aakoshh aakoshh added blocked and removed blocked labels Mar 19, 2021
@aakoshh aakoshh force-pushed the ETCM-165-publish branch 4 times, most recently from 9498ccb to 036bbab Compare March 22, 2021 15:56
@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 22, 2021

@dzajkowski @KonradStaniec this should be ready for approval now.

@aakoshh aakoshh force-pushed the ETCM-165-publish branch 2 times, most recently from 315c36d to 3c65f87 Compare March 22, 2021 16:19
@aakoshh aakoshh requested a review from jvdp March 22, 2021 17:08
@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 24, 2021

@KonradStaniec kindly reminded me that we'd need this published for Scala 2.13 as well as 2.12, which I completely forgot.

aakoshh added 3 commits March 24, 2021 21:53
ETCM-165: Accept SNAPSHOT in version number sent in Hello.
ETCM-165: Wait for unit tests before publishing.
ETCM-165: Check if the GPG key already exists.
ETCM-165: Update GPG.
ETCM-165: Try restarting the gpg agent.
@aakoshh
Copy link
Contributor Author

aakoshh commented Mar 24, 2021

I wonder how nix likes cross building. In any case I noticed that my PR has a ./nix/pkgs/mantis.nix which looks like it's currently missing on develop (there's one at ./nix/mantis.nix instead); I just did what the README told me to update the dependencies, not sure if it's still correct.

if [[ "$GPG_EXISTS" == "no" ]]; then
echo "$GPG_KEY" | base64 --decode | gpg --batch --import
fi
# Local testing showed that without this the SBT plugin got "Bad passphrase".
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out it's because without this the --pinentry-mode loopback doesn't work. When I removed that from the command the plugin printed, and tried it in the console, it worked with the --passphrase flag, so it's not an issue of surrounding with ' or having a bad password.

@aakoshh aakoshh removed the blocked label Mar 26, 2021

function releaseAll {
release 2.12.10 1.4.5
release 2.13.4 1.4.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this duplication with build.sbt will come back to bite us....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be too hard to move more of this logic into sbt.

Copy link
Contributor Author

@aakoshh aakoshh Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd think so, right! I spent hours trying to figure out with a code like this:

scapegoatVersion in ThisBuild := (scalaBinaryVersion.value match {
  case "2.12" => "1.4.5"
  case "2.13" => println("Still 2.13"); "1.4.7"
})

I start sbt, type ++ 2.12.10 and see "Still 2.13" printed every time, then I type scalaBinaryVersion and it says 2.12.10, really frustrating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to give it a go, you should be able to try wit sbt +compile for example (or at least sbt +publishLocal), the + should trigger cross building, and then it fails because it tries to grab the 1.4.7 version for 2.12.10, even when I moved the scapegoatVersion under node.

If I removed in ThisBuild then it wants to grab 1.0.0. No idea what I'm missing, this should work.

nix/pkgs/mantis.nix Outdated Show resolved Hide resolved
@aakoshh aakoshh requested a review from dzajkowski April 12, 2021 13:00
Copy link
Contributor

@dzajkowski dzajkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for aligning with build changes!

@aakoshh aakoshh merged commit be884b1 into develop Apr 13, 2021
@aakoshh aakoshh deleted the ETCM-165-publish branch April 13, 2021 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants