Skip to content

Commit

Permalink
ensure we dont keep trying to create PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronosMasterOfAllTime committed Dec 19, 2024
1 parent b4e5b71 commit 13c1b89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/latest_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions scripts/update_app_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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"

Expand Down

0 comments on commit 13c1b89

Please sign in to comment.