From a7c3dbab44778350eca6fa1c7010bb6339e63fe6 Mon Sep 17 00:00:00 2001 From: XinRan Zhang Date: Tue, 9 Apr 2024 22:22:56 +0000 Subject: [PATCH] manual input for branch --- .github/workflows/pre_release_prepare.yml | 35 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pre_release_prepare.yml b/.github/workflows/pre_release_prepare.yml index f80dc46..d9706b7 100644 --- a/.github/workflows/pre_release_prepare.yml +++ b/.github/workflows/pre_release_prepare.yml @@ -6,6 +6,10 @@ on: version: description: 'Version number (e.g., 1.0.1)' required: true + is_patch: + description: 'Is this a patch? (true or false)' + required: true + default: 'false' permissions: contents: write @@ -33,14 +37,33 @@ jobs: - name: Create branches run: | + IS_PATCH=${{ github.event.inputs.is_patch }} + if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then + echo "Invalid input for IS_PATCH. Must be 'true' or 'false'." + exit 1 + fi + + if git ls-remote --heads origin release/${MAJOR_MINOR}.x | grep -q "release/${MAJOR_MINOR}.x"; then - git fetch origin release/${MAJOR_MINOR}.x - echo "Branch release/${MAJOR_MINOR}.x already exists, checking out." - git checkout "release/${MAJOR_MINOR}.x" + if [ "$IS_PATCH" = "true" ]; then + git fetch origin release/${MAJOR_MINOR}.x + echo "Branch release/${MAJOR_MINOR}.x already exists, checking out." + git checkout "release/${MAJOR_MINOR}.x" + else + echo "Error, release series branch release/${MAJOR_MINOR}.x exist for non-patch release" + echo "Check your input or branch" + exit 1 + fi else - echo "Creating branch release/${MAJOR_MINOR}.x." - git checkout -b "release/${MAJOR_MINOR}.x" - git push origin "release/${MAJOR_MINOR}.x" + if [ "$IS_PATCH" = "true" ]; then + echo "Error, release series branch release/${MAJOR_MINOR}.x NOT exist for patch release" + echo "Check your input or branch" + exit 1 + else + echo "Creating branch release/${MAJOR_MINOR}.x." + git checkout -b "release/${MAJOR_MINOR}.x" + git push origin "release/${MAJOR_MINOR}.x" + fi fi git checkout -b "${VERSION}_release"