Created
August 5, 2024 09:32
-
-
Save shalomb/840a35606192a3a9f16c57bbb9b30a9d to your computer and use it in GitHub Desktop.
Patch release modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Add a patch release to a bunch of github repos | |
set -eu -o pipefail | |
git() { | |
( | |
set -xv | |
command git "$@" | |
) | |
set +xv | |
} | |
for bb_dir in terraform-aws-TakedaAPI*/; do | |
( | |
cd "$bb_dir" || exit 1 | |
echo | |
echo "---- Releasing ${bb_dir%/} ----" | |
echo | |
{ | |
git fetch --all | |
git checkout main | |
} &>/dev/null | |
remote=$(command git remote get-url origin) | |
git fetch --prune "${remote}" +refs/tags/*:refs/tags/* | |
command git pull --rebase | |
if command git log -1 | grep -i 'Update examples'; then # or whatever we titled our message | |
old_tag=$(command git describe --tags --abbrev=0) | |
gh release create "$old_tag" --generate-notes --verify-tag --target 'main' | |
exit $? | |
if [[ -z $old_tag ]]; then | |
old_tag='v0.0.0' | |
new_tag='v0.0.1' | |
else | |
new_tag=$(awk -F . '{OFS="."; $NF+=1; print}' <<<"$old_tag") # Increment last octet | |
fi | |
echo "old tag: $old_tag" | |
echo "new tag: $new_tag" | |
commit_msg="$(git log --format=%B -n 1 HEAD)" | |
if [[ $new_tag != "$old_tag" ]]; then | |
git tag "$new_tag" -s -a -m "$commit_msg" | |
# git show "$new_tag" --oneline --no-patch | cat - | |
git push --tags | |
# Create release | |
gh release create "$new_tag" --generate-notes --verify-tag --target 'main' | |
fi | |
fi | |
echo | |
) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment