From 13c1b8962d64735627894cf0666e25c523ee7f37 Mon Sep 17 00:00:00 2001 From: Efstathios Chouliaris Date: Thu, 19 Dec 2024 14:22:59 -0600 Subject: [PATCH] ensure we dont keep trying to create PRs --- .github/workflows/pre_release.yml | 1 - scripts/latest_version.sh | 4 ++-- scripts/update_app_version.sh | 15 ++++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pre_release.yml b/.github/workflows/pre_release.yml index 46c3b817..87dceaf4 100644 --- a/.github/workflows/pre_release.yml +++ b/.github/workflows/pre_release.yml @@ -26,7 +26,6 @@ jobs: run: sudo apt install jq - name: Update App Version run: | - echo "Doing it as: $GITHUB_ACTOR" if [[ "${{ github.event.inputs.debug }}" == "true" ]]; then echo "Debug mode enabled" ./scripts/update_app_version.sh 2>&1 | tee -a debug.log diff --git a/scripts/latest_version.sh b/scripts/latest_version.sh index 6d84d8f8..d97dd4b1 100755 --- a/scripts/latest_version.sh +++ b/scripts/latest_version.sh @@ -112,9 +112,9 @@ fi git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" -EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME") +EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false") -if [[ -n $EXISTS ]]; then +if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then echo "A PR already exists on branch $BRANCH_NAME for the latest Go version(s) (${LATEST_GO_VERSIONS[@]})" exit 0 fi diff --git a/scripts/update_app_version.sh b/scripts/update_app_version.sh index e5f8fe57..e4655b64 100755 --- a/scripts/update_app_version.sh +++ b/scripts/update_app_version.sh @@ -5,6 +5,8 @@ if [[ $DEBUG == "true" ]]; then set -x # Print commands and their arguments as they are executed fi +APP_VERSION_FILE="APP_VERSION" + # This script is used to update the version of the app. LATEST_DRAFT_VERSION=$(gh release list -L 1 | awk -F '\t' '{if (match($3, "^[0-9]+\\.[0-9]+\\.[0-9]+")) print $3}') @@ -13,6 +15,9 @@ LATEST_VERSION=$(gh release view --json tagName -q .tagName) if [[ $LATEST_DRAFT_VERSION == $LATEST_VERSION ]]; then echo "latest draft version ($LATEST_DRAFT_VERSION) matches latest version ($LATEST_VERSION)" exit 0 +elif [[ $LATEST_DRAFT_VERSION == $(cat $APP_VERSION_FILE) ]]; then + echo "latest draft version ($LATEST_DRAFT_VERSION) matches current version in $APP_VERSION_FILE" + exit 0 fi if [[ -n $GITHUB_ACTOR ]]; then @@ -24,7 +29,7 @@ BRANCH_NAME_PREFIX="update-app-version" BRANCH_NAME="$BRANCH_NAME_PREFIX-$LATEST_DRAFT_VERSION" -EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME") || echo "false" +EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false") if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then echo "A PR already exists on branch $BRANCH_NAME for App Version update: $LATET_DRAFT_VERSION" @@ -37,15 +42,15 @@ git switch -c $BRANCH_NAME master printf " done\n" -echo "Updating APP_VERSION..." +echo "Updating $APP_VERSION_FILE..." -echo $LATEST_DRAFT_VERSION >APP_VERSION +echo $LATEST_DRAFT_VERSION >$APP_VERSION_FILE echo "Committing changes..." -COMMIT_MSG="Update APP_VERSION to $LATEST_DRAFT_VERSION" +COMMIT_MSG="Update $APP_VERSION_FILE to $LATEST_DRAFT_VERSION" -git add APP_VERSION +git add $APP_VERSION_FILE git commit -m "$COMMIT_MSG"