-
Notifications
You must be signed in to change notification settings - Fork 20
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
Publish snapshots by default and add an override for hash releases #86
base: main
Are you sure you want to change the base?
Conversation
The question remains, can this work out of the box with the CI release mode of sbt-spiewak, because that accesses PGP_SECRET and what not, and this is not strictly required for SNAPSHOT releases. |
That's a very good point. I forgot Some People™ don't use CI publishing for the real releases, and therefore probably won't have the - name: Import signing key
run: echo $PGP_SECRET | base64 -d | gpg --import I wonder if we could make that step conditional, but I don't know on what. In fact, I suspect that solving this problem is nearly equivalent to solving the current problem where you tag a release with snapshots enabled it will try to publish the release twice. Essentially, one of those CI runs is for the snapshot, and if it could somehow know that it could avoid both these issues. |
Conditional on the new override? If it's
|
Yes, this is a general problem, which is a CI run doesn't know whether it's for an ordinary push or for a tag. Actually here's one way to solve it. on:
pull_request:
branches: ['**']
push:
branches: ['**']
tags: [v*] These are the triggers for the workflow. So we could actually just duplicate the workflow, have one run on branch push, and the other one run on tag, and then it becomes possible to modify it for each case. It's really annoying to have duplicate workflows, but at least it's auto-generated. |
If we generate a separate workflow for on branch push and on tag push, the branch push workflow can remove the PGP step if that setting is false. |
Aha, here's something much easier than that.
https://docs.github.com/en/actions/learn-github-actions/environment-variables |
On |
This still doesn't cover the hash releases as snapshots. Or am I missing something? |
Assuming that the user wants publish:
name: Publish Artifacts
needs: [build] # vvvvvvvvvvvvv
if: github.event_name != 'pull_request' && env.GITHUB_REF_TYPE == 'branch' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/2.5.x') That way it skips the publish step for - name: Import signing key
if: env.GITHUB_REF_TYPE == 'tag'
run: echo $PGP_SECRET | base64 -d | gpg --import |
I guess that works. Btw, |
I just realized, if they want tag or hash releases, they need to set up the |
Ah but not really?
This wouldn't run for hash releases. |
Right, so we only add that conditional to the generated YAML if the user has indicated they want -SNAPSHOT releases. If they want stable hash releases, we don't add that. |
Which means that |
Don't think so, it's needed here: sbt-spiewak/sonatype/src/main/scala/sbtspiewak/SonatypeCiReleasePlugin.scala Lines 57 to 60 in d689a5b
|
So just for my own clarification, we have three release modes:
With these, there are 6 configurations for CI?
|
This seems a bit complicated. Would a separate workflow for snapshots and a separate workflow for releases be simpler? Especially this part, which I believe right now comes from
|
IDK, we might have to shave this yak first: Ooph you are right, this might be an sbt-gh-actions thing 😓 |
I mean, as a stopgap, the |
It'll be a bit confusing in the UI to see an empty publish job succeed, but otherwise a good idea! |
This is how https://github.com/djspiewak/sbt-github-actions/actions/runs/1531278166 |
Oh, interesting, I didn't know that. |
How does releasing snapshots without releasing tagged releases work currently? What's the discriminator? |
Actually, I don't think that capability exists as of now. You buy into CI release first, and then optionally into hash releases. |
@armanbilge Can you maybe take this for a spin? I will release a |
We should set this to true when the version is a -SNAPSHOT. |
Ok cool. Good find. |
@armanbilge Can you try the following snapshot please? |
Do you mind also testing a tagged release? |
The snapshot worked! https://s01.oss.sonatype.org/content/repositories/snapshots/com/armanbilge/schrodinger_3/0.3-2-3fc5aaf-SNAPSHOT/ Time for 0.3.0-M2 😆 |
0.3.0-M2 is on it's way to maven 🚀 nice work!!! |
I can publish a snapshot to get things rolling? |
What do you have in mind? 😁 |
I found another issue, with |
private def sonatypeBundleReleaseIfRelevant: Command =
Command.command("sonatypeBundleReleaseIfRelevant") { state =>
val isSnap = state.getSetting(isSnapshot).getOrElse(false)
if (!isSnap)
Command.process("sonatypeBundleRelease", state)
else
state
} |
|
Sorry, I couldn't understand what the problem is? |
From sonatypeBundleDirectory := {
(ThisBuild / baseDirectory).value / "target" / "sonatype-staging" / s"${(ThisBuild / version).value}"
}, and the error is the following:
|
Right, it seems like |
|
Ooh 😮 |
The problem is that |
Here's a hash release: addSbtPlugin("io.vasilev" % "sbt-spiewak-sonatype" % "0.23-12-4067672") No snapshot resolver necessary. |
@armanbilge Can you try releasing a hash with this version too? The steps are |
I've actually never released anything locally 😆 I'm not sure I know how. |
You need to have gpg set up. Don't bother if you haven't yet. I released the hash using the plugin, so it works. |
What I can do easily, is toggle the setting so CI can release a stable hash instead. Would that be helpful? |
Actually yes, that's a good scenario to try. Thanks. |
What we should discuss again though is, should we flip everything, keep the old |
I think that's a Daniel vs the world question 😅 IDK if anybody likes the current default. |
Forgot to followup, this worked for me 👍 |
@armanbilge and I worked on this after discussing SNAPSHOT releases with other maintainers on Discord. We think this is generally desired by people.
By combining both the
hash
and the-SNAPSHOT
suffix, we believe we can achieve a sensible middle ground where snapshots are mutable but not actually mutated (unless the user goes out of their way to make sure the hash matches a previous version), so this helps with the stability, maven central is not polluted (this doesn't at all affect tagged releases and they can still be done manually) and maintainers have a steady stream of stable snapshots to test stuff and look for regressions.