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

Add bash assert_valid_rc script #4096

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
28 changes: 28 additions & 0 deletions scripts/release/assert_valid_rc.sh
Original file line number Diff line number Diff line change
@@ -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"