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

Take 2: fix CI release/snapshot race condition #45

Merged
merged 3 commits into from
Jan 7, 2022

Conversation

armanbilge
Copy link
Member

@armanbilge armanbilge commented Jan 4, 2022

Fixes #42.

For context, this is the "race condition" where if a commit is pushed to GH with a tag and CI release is enabled for both tags and snapshots, two publish jobs will start simultaneously and both will have the identical (tagged) version. The workaround is to first push the commit and wait for its (snapshot) publish job to complete, then push the tag separately to trigger the second publish job.

Fixing this problem is also important for projects that may want CI release for snapshots but don't want CI release for tags, such as CE—there needs to be a way for the snapshot publish job to ignore the tags.

The solution here definitely makes me feel a bit queasy: it changes our versioning algorithm depending on the presence/value of an GITHUB_REF_TYPE environment variable, that indicates we are:

  1. running in GH actions
  2. running in a job that was not triggered by a tag push

When both these conditions are true, the versioning algorithm ignores any "v" tags and adopts a hash version.

One of the nice things about this approach is that we still get one snapshot per push, in addition to any proper release. My previous solution was attempting to disable the snapshot publish job completely.

Thoughts?

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

Is this the first time versioning turns GitHub-specific? That's gross, but I don't yet see a better way.

@armanbilge
Copy link
Member Author

Yep, until now versioning didn't know about GitHub at all. I considered pushing this further down the plugin stack to once of the ci plugins that are GitHub-only. But considering #21 not everyone who does GitHub CI release is using our ci plugin with sbt-gh-actions. So this is the only way to make the fix broadly applicable.

@armanbilge armanbilge merged commit 326b28b into typelevel:main Jan 7, 2022
@armanbilge armanbilge mentioned this pull request Jan 8, 2022
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.

Still have race-conditions / double-release problem for simultaneous push+tag push
2 participants