chore: `bump-status-go.sh` latest option (#13766)

* chore: enable `bump-status-go.sh` to upgrade to latest

* better pr link

* STATUS_DESKTOP_MAIN_BRANCH variable
This commit is contained in:
Igor Sirotin 2024-02-28 20:26:42 +00:00 committed by GitHub
parent 291e65816e
commit 95eb5fe71d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 58 additions and 40 deletions

View File

@ -25,6 +25,9 @@ STATUS_GO_REPO="${STATUS_GO_REPO:=status-go}"
STATUS_GO_OWNER="${STATUS_GO_OWNER:=status-im}" STATUS_GO_OWNER="${STATUS_GO_OWNER:=status-im}"
REPO_URL="https://github.com/${STATUS_GO_OWNER}/${STATUS_GO_REPO}" REPO_URL="https://github.com/${STATUS_GO_OWNER}/${STATUS_GO_REPO}"
STATUS_GO_VERSION=$1 STATUS_GO_VERSION=$1
COMMIT_MESSAGE="chore: bump status-go"
TIMESTAMP=$(date +%s)
STATUS_DESKTOP_MAIN_BRANCH="master"
HELP_MESSAGE=$(cat <<-END HELP_MESSAGE=$(cat <<-END
This is a tool to help creating PRs with specific status-go versions This is a tool to help creating PRs with specific status-go versions
@ -32,6 +35,8 @@ If the given name matches both a branch and a tag the tag is used.
Usage: Usage:
${SCRIPT_FILE} {version} ${SCRIPT_FILE} {version}
Examples: Examples:
# Latest develop
${SCRIPT_FILE} --latest
# Using branch name # Using branch name
${SCRIPT_FILE} feature-abc-xyz ${SCRIPT_FILE} feature-abc-xyz
# Using tag name # Using tag name
@ -60,60 +65,73 @@ if [[ "${STATUS_GO_VERSION}" = PR-* ]]; then
STATUS_GO_VERSION="refs/pull/${STATUS_GO_VERSION#"PR-"}/head" STATUS_GO_VERSION="refs/pull/${STATUS_GO_VERSION#"PR-"}/head"
fi fi
# ls-remote finds only tags, branches, and pull requests, but can't find commits if [ "$1" = "--latest" ]; then
STATUS_GO_MATCHING_REFS=$(git ls-remote ${REPO_URL} ${STATUS_GO_VERSION}) STATUS_GO_VERSION=""
BRANCH_NAME=bump/status-go/latest-develop/${TIMESTAMP}
else
# ls-remote finds only tags, branches, and pull requests, but can't find commits
STATUS_GO_MATCHING_REFS=$(git ls-remote ${REPO_URL} ${STATUS_GO_VERSION})
# It's possible that there's both a branch and a tag matching the given version # It's possible that there's both a branch and a tag matching the given version
STATUS_GO_TAG_SHA1=$(echo "${STATUS_GO_MATCHING_REFS}" | grep 'refs/tags' | cut -f1) STATUS_GO_TAG_SHA1=$(echo "${STATUS_GO_MATCHING_REFS}" | grep 'refs/tags' | cut -f1)
STATUS_GO_BRANCH_SHA1=$(echo "${STATUS_GO_MATCHING_REFS}" | grep 'refs/heads' | cut -f1) STATUS_GO_BRANCH_SHA1=$(echo "${STATUS_GO_MATCHING_REFS}" | grep 'refs/heads' | cut -f1)
REQUIRES_MSG=https://github.com/status-im/status-go/ REQUIRES_MSG=https://github.com/status-im/status-go/
# Prefer tag over branch if both are found # Prefer tag over branch if both are found
if [[ -n "${STATUS_GO_TAG_SHA1}" ]]; then if [[ -n "${STATUS_GO_TAG_SHA1}" ]]; then
STATUS_GO_COMMIT_SHA1="${STATUS_GO_TAG_SHA1}" STATUS_GO_COMMIT_SHA1="${STATUS_GO_TAG_SHA1}"
REQUIRES_MSG=${REQUIRES_MSG}/tree/${STATUS_GO_VERSION} REQUIRES_MSG=${REQUIRES_MSG}/tree/${STATUS_GO_VERSION}
elif [[ -n "${STATUS_GO_BRANCH_SHA1}" ]]; then elif [[ -n "${STATUS_GO_BRANCH_SHA1}" ]]; then
STATUS_GO_COMMIT_SHA1="${STATUS_GO_BRANCH_SHA1}" STATUS_GO_COMMIT_SHA1="${STATUS_GO_BRANCH_SHA1}"
REQUIRES_MSG=${REQUIRES_MSG}/tree/${STATUS_GO_VERSION} REQUIRES_MSG=${REQUIRES_MSG}/tree/${STATUS_GO_VERSION}
elif [[ "${#STATUS_GO_VERSION}" -gt 4 ]]; then elif [[ "${#STATUS_GO_VERSION}" -gt 4 ]]; then
STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}" STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}"
REQUIRES_MSG=${REQUIRES_MSG}/commit/${STATUS_GO_VERSION} REQUIRES_MSG=${REQUIRES_MSG}/commit/${STATUS_GO_VERSION}
else else
echo "ERROR: Input not a tag or branch, but too short to be a SHA1!" >&2 echo "ERROR: Input not a tag or branch, but too short to be a SHA1!" >&2
exit 1 exit 1
fi fi
echo "SHA-1 for ${STATUS_GO_VERSION} is ${STATUS_GO_COMMIT_SHA1}. echo "SHA-1 for ${STATUS_GO_VERSION} is ${STATUS_GO_COMMIT_SHA1}.
Owner is ${STATUS_GO_OWNER}" Owner is ${STATUS_GO_OWNER}"
BRANCH_NAME=bump/status-go/${STATUS_GO_VERSION}/${TIMESTAMP}
TIMESTAMP=$(date +%s) COMMIT_MESSAGE="${COMMIT_MESSAGE}
BRANCH_NAME=bump/status-go/${STATUS_GO_VERSION}/${TIMESTAMP}
git checkout master
git pull
git checkout -b ${BRANCH_NAME}
cd vendor/status-go
git checkout ${STATUS_GO_COMMIT_SHA1}
cd ../..
git add ./vendor/status-go
git commit -m "chore: bump status-go
### Requires ### Requires
- ${REQUIRES_MSG} - ${REQUIRES_MSG}
" "
fi
git checkout -q ${STATUS_DESKTOP_MAIN_BRANCH}
git pull
git checkout -b ${BRANCH_NAME}
cd vendor/status-go
if [ -z ${STATUS_GO_VERSION} ]; then
git fetch origin
git checkout develop
git pull
else
git checkout ${STATUS_GO_COMMIT_SHA1}
fi
cd ../..
git add ./vendor/status-go
git commit -m "${COMMIT_MESSAGE}"
git push --set-upstream origin ${BRANCH_NAME} git push --set-upstream origin ${BRANCH_NAME}
git push git push
git checkout master git checkout ${STATUS_DESKTOP_MAIN_BRANCH}
git branch -D ${BRANCH_NAME} git branch -D ${BRANCH_NAME}
cat << EOF STATUS_DESKTOP_PR_LINK="https://github.com/status-im/status-desktop/compare/$STATUS_DESKTOP_MAIN_BRANCH}...${BRANCH_NAME}"
DONE!!!!!!!!!!!!! STATUS_DESKTOP_PR_LINK="${STATUS_DESKTOP_PR_LINK}?quick_pull=1&title=chore:+bump+status-go&body=update+status+go"
Create a pull request at https://github.com/status-im/status-desktop/pull/new/${BRANCH_NAME} cat << EOF
✅ DONE!
Create a pull request at ${STATUS_DESKTOP_PR_LINK}
EOF EOF