Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support passing relevant release tags to update-4x-branch.sh as arguments #4400

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions dev-utils/update-4x-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# just-tagged release. The 4.x branch needs to be updated for the current docs
# build.
#
# Usage:
# ./dev-utils/update-4x-branch.sh [TARGTAG [LASTTAG]]

if [ "$TRACE" != "" ]; then
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
Expand All @@ -27,24 +29,37 @@ cd $WRKDIR
git clone git@github.com:elastic/apm-agent-nodejs.git
cd apm-agent-nodejs

TARGTAG=$(git tag --points-at HEAD)
# Allow passing in target tag (first arg), in case the latest commit is no
# longer the tagged release commit.
TARGTAG="$1"
if [[ -z "$TARGTAG" ]]; then
TARGTAG=$(git tag --points-at HEAD)
fi
if [[ ! ("$TARGTAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]$) ]]; then
fatal "the tag on HEAD, '${TARGTAG}', does not look like a release tag"
fatal "the target tag, '${TARGTAG}', does not look like a release tag"
fi
# echo "TARGTAG=$TARGTAG"

readonly NUM_COMMITS_SANITY_GUARD=200
LASTTAG=$(
git log --pretty=format:%h -$NUM_COMMITS_SANITY_GUARD | tail -n +2 | while read sha; do
possible=$(git tag --points-at $sha)
if [[ "$possible" =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]; then
echo $possible
break
fi
done
)
# Allow passing in last tag (second arg), in case the 4.x branch wasn't updated
# for some previous releases.
LASTTAG="$2"
if [[ -z "$LASTTAG" ]]; then
fatal "could not find previous release tag in last $NUM_COMMITS_SANITY_GUARD commits"
readonly NUM_COMMITS_SANITY_GUARD=200
LASTTAG=$(
git log --pretty=format:%h -$NUM_COMMITS_SANITY_GUARD | tail -n +2 | while read sha; do
possible=$(git tag --points-at $sha)
if [[ "$possible" =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]; then
echo $possible
break
fi
done
)
if [[ -z "$LASTTAG" ]]; then
fatal "could not find previous release tag in last $NUM_COMMITS_SANITY_GUARD commits"
fi
fi
if [[ ! ("$LASTTAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]$) ]]; then
fatal "the last tag, '${LASTTAG}', does not look like a release tag"
fi
# echo "LASTTAG=$LASTTAG"

Expand Down
Loading