Take 2: fix CI release/snapshot race condition #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: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?