Skip to content

Commit

Permalink
Allow tag-release to be idempotent (#182)
Browse files Browse the repository at this point in the history
Add --abbrev=0 to any git-describe so we always get the unadorned tag.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Jul 17, 2024
1 parent 1df3e3d commit 3e906b1
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tools/release-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ check_repo_release_vX() {

clone_checkout_fresh_workarea "$repo_name" "$repo_url" "$branch" "$indent"

latest_release=$(git describe --match="v*" HEAD) || do_fail "${indent}Failure getting latest release tag."
latest_release=$(git describe --match="v*" --abbrev=0 HEAD) || do_fail "${indent}Failure getting latest release tag."
new_release=$(semver_bump "$latest_release")

echo
Expand Down Expand Up @@ -721,7 +721,7 @@ create_pr_release_vX() {

clone_checkout_fresh_workarea "$repo_name" "$repo_url" "$branch" "$indent"

latest_release=$(git describe --match="v*" HEAD) || do_fail "${indent}Failure getting latest release tag."
latest_release=$(git describe --match="v*" --abbrev=0 HEAD) || do_fail "${indent}Failure getting latest release tag."
new_release=$(semver_bump "$latest_release")

verify_clean_workarea "$indent"
Expand Down Expand Up @@ -757,7 +757,7 @@ merge_pr_release_vX() {

clone_checkout_fresh_workarea "$repo_name" "$repo_url" "$branch" "$indent"

latest_release=$(git describe --match="v*" HEAD) || do_fail "${indent}Failure getting latest release tag."
latest_release=$(git describe --match="v*" --abbrev=0 HEAD) || do_fail "${indent}Failure getting latest release tag."
new_release=$(semver_bump "$latest_release")
new_branch="release-$new_release"

Expand Down Expand Up @@ -785,26 +785,29 @@ tag_release_vX() {

clone_checkout_fresh_workarea "$repo_name" "$repo_url" "$branch" "$indent"

latest_release=$(git describe --match="v*" HEAD) || do_fail "${indent}Failure getting latest release tag."
latest_release=$(git describe --match="v*" --abbrev=0 HEAD) || do_fail "${indent}Failure getting latest release tag."

merge_release=$(git log --oneline -1 | sed 's/^.* Merge release \(.*\)/\1/')
msg "${indent}Expecting to tag as release $merge_release"

# Is it already tagged?
if git show "$merge_release" 2>/dev/null 1>&2; then
msg "${indent}Already tagged as $merge_release"
cd ..
return
else
msg "${indent}Tagging as $merge_release"
git tag -a "$merge_release" -m "Release $merge_release" || do_fail "${indent}Failed tagging as $merge_release"
git push origin --tags || do_fail "${indent}Failed to push tags"
fi

msg "${indent}Tagging as $merge_release"
git tag -a "$merge_release" -m "Release $merge_release" || do_fail "${indent}Failed tagging as $merge_release"
git push origin --tags || do_fail "${indent}Failed to push tags"

if [[ $repo_short_name == nnf_doc ]]; then
msg "${indent}Creating $repo_short_name release."
msg "${indent}Generating notes from $latest_release to $merge_release."
gh release create --generate-notes --verify-tag --notes-start-tag "$latest_release" "$merge_release" || do_fail "${indent}Failed to generate release for $repo_short_name"
# Is the doc's release already created?
if gh release view "$merge_release" > /dev/null 2>&1; then
msg "${indent}Already created release doc"
else
msg "${indent}Creating release doc."
msg "${indent}Generating notes from $latest_release to $merge_release."
gh release create --generate-notes --verify-tag --notes-start-tag "$latest_release" "$merge_release" || do_fail "${indent}Failed to generate release for $repo_short_name"
fi
fi

echo
Expand Down

0 comments on commit 3e906b1

Please sign in to comment.