Skip to content

Commit 13c1b89

Browse files
ensure we dont keep trying to create PRs
1 parent b4e5b71 commit 13c1b89

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.github/workflows/pre_release.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
run: sudo apt install jq
2727
- name: Update App Version
2828
run: |
29-
echo "Doing it as: $GITHUB_ACTOR"
3029
if [[ "${{ github.event.inputs.debug }}" == "true" ]]; then
3130
echo "Debug mode enabled"
3231
./scripts/update_app_version.sh 2>&1 | tee -a debug.log

scripts/latest_version.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ fi
112112
git config --global user.name "${GITHUB_ACTOR}"
113113
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
114114

115-
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME")
115+
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false")
116116

117-
if [[ -n $EXISTS ]]; then
117+
if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then
118118
echo "A PR already exists on branch $BRANCH_NAME for the latest Go version(s) (${LATEST_GO_VERSIONS[@]})"
119119
exit 0
120120
fi

scripts/update_app_version.sh

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ if [[ $DEBUG == "true" ]]; then
55
set -x # Print commands and their arguments as they are executed
66
fi
77

8+
APP_VERSION_FILE="APP_VERSION"
9+
810
# This script is used to update the version of the app.
911

1012
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)
1315
if [[ $LATEST_DRAFT_VERSION == $LATEST_VERSION ]]; then
1416
echo "latest draft version ($LATEST_DRAFT_VERSION) matches latest version ($LATEST_VERSION)"
1517
exit 0
18+
elif [[ $LATEST_DRAFT_VERSION == $(cat $APP_VERSION_FILE) ]]; then
19+
echo "latest draft version ($LATEST_DRAFT_VERSION) matches current version in $APP_VERSION_FILE"
20+
exit 0
1621
fi
1722

1823
if [[ -n $GITHUB_ACTOR ]]; then
@@ -24,7 +29,7 @@ BRANCH_NAME_PREFIX="update-app-version"
2429

2530
BRANCH_NAME="$BRANCH_NAME_PREFIX-$LATEST_DRAFT_VERSION"
2631

27-
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME") || echo "false"
32+
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false")
2833

2934
if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then
3035
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
3742

3843
printf " done\n"
3944

40-
echo "Updating APP_VERSION..."
45+
echo "Updating $APP_VERSION_FILE..."
4146

42-
echo $LATEST_DRAFT_VERSION >APP_VERSION
47+
echo $LATEST_DRAFT_VERSION >$APP_VERSION_FILE
4348

4449
echo "Committing changes..."
4550

46-
COMMIT_MSG="Update APP_VERSION to $LATEST_DRAFT_VERSION"
51+
COMMIT_MSG="Update $APP_VERSION_FILE to $LATEST_DRAFT_VERSION"
4752

48-
git add APP_VERSION
53+
git add $APP_VERSION_FILE
4954

5055
git commit -m "$COMMIT_MSG"
5156

0 commit comments

Comments
 (0)