From a6f6825270981ad47231e60b0d12badbbeb1991f Mon Sep 17 00:00:00 2001 From: Jonathan Rainer Date: Mon, 14 Oct 2024 10:10:04 +0100 Subject: [PATCH] Ensure we catch all semver pre-release versions (#2196) 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. --- .circleci/config.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 020042444..a6a5601f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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. @@ -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