Skip to content

Commit

Permalink
Ensure we catch all semver pre-release versions (#2196)
Browse files Browse the repository at this point in the history
At present we're only capturing pre-release versions with a specific set of names
encoded into the tags, which caused an incident when an unexpected
pre-release SemVer tag was used.

This regex should ensure we capture all pre-release tags. Furthermore we tighten up our definition of a releasable tag overall to include all SemVer tags, this way pushing random tags will not trigger releases unless they are valid semver.
  • Loading branch information
jonathanrainer authored and glasser committed Dec 12, 2024
1 parent da93b31 commit a6f6825
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ run_release: &run_release
branches:
ignore: /.*/
tags:
only: /v.*/
# This regex is taken verbatim from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string and
# ensures we only ever run our release pipeline for Semver tags
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/

# You can uncomment the following alias, and comment the above alias when testing,
# just make sure to update the branch name to the one you're testing on so they run.
Expand Down Expand Up @@ -118,7 +120,11 @@ executors:

tag_matches_prerelease: &tag_matches_prerelease
matches:
pattern: "^.*(beta|alpha|rc|prerelease|draft|test).*$"
# This regex is adapted from the official one provided by the Semver Standard:
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# There is a v appended in the first instance and further everything after the `-` we can ignore hence the
# simplification.
pattern: "^v(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)-.+$"
value: << parameters.release_tag >>

# reusable parameters that can be used across jobs and workflows
Expand Down

0 comments on commit a6f6825

Please sign in to comment.