From 474507b2047218b7f38463676db6a6bc6ec9ad3f Mon Sep 17 00:00:00 2001 From: Cayman Date: Tue, 31 May 2022 22:20:18 -0500 Subject: [PATCH] Add bash assert_valid_rc script --- .github/workflows/publish-rc.yml | 2 +- scripts/release/assert_valid_rc.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 scripts/release/assert_valid_rc.sh diff --git a/.github/workflows/publish-rc.yml b/.github/workflows/publish-rc.yml index 5c81626ff734..06cd3e4ea02d 100644 --- a/.github/workflows/publish-rc.yml +++ b/.github/workflows/publish-rc.yml @@ -32,7 +32,7 @@ jobs: - name: Determine release type id: is_rc - run: node scripts/release/assert_valid_rc.mjs + run: scripts/release/assert_valid_rc.sh env: TAG: ${{ steps.get_tag.outputs.tag }} diff --git a/scripts/release/assert_valid_rc.sh b/scripts/release/assert_valid_rc.sh new file mode 100755 index 000000000000..917a1c9184a0 --- /dev/null +++ b/scripts/release/assert_valid_rc.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Asserts whether a tag is a valid release candidate or not +# This script is meant to be run by a github workflow +# The output of this script is to either set github variables or not + +set -e + +COMMIT=$TAG +echo "Tag: $TAG" + +# assert it matches proper format vX.X.X-rc.X +RC_REGEX="^v(([0-9]+\.[0-9]+\.[0-9]+)-rc\.[0-9])+$" + +if [[ $TAG =~ $RC_REGEX ]]; then + VERSION=${BASH_REMATCH[1]} + RC_BRANCH="rc/v${BASH_REMATCH[2]}" +else + exit +fi + +# assert it exists in branch +HEAD_COMMIT=$(git rev-parse refs/heads/$RC_BRANCH) +git merge-base --is-ancestor $COMMIT $HEAD_COMMIT + +# success +echo "::set-output name=is_rc::true" +echo "::set-output name=version::$VERSION"