Skip to content

Commit

Permalink
improvements for role-make-version-changelog.sh
Browse files Browse the repository at this point in the history
Do not clone repo unless necessary.  This means you can use without
LSR_BASE_DIR.  It will create a tempdir for the cloned repo.

Clean up output a little for readability.

Do not prompt to release role unless AUTOSKIP=false.

Add new feature - AUTOSKIP_PR_TYPES - by default, if the only
changes to the role are `ci` related changes, the script will
skip that role.  If you really want to do a release of a role
which has only `ci` changes, set `AUTOSKIP_PR_TYPES=none`
  • Loading branch information
richm committed Aug 16, 2024
1 parent 30890a4 commit b6ac58f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions manage-role-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ for repo in $repos; do
fi
if [ -n "${1:-}" ]; then
if [ -f "$1" ]; then
# shellcheck disable=SC1090
if ! source "$@"; then
echo ERROR: command "$1" in "$(pwd)" failed
fi
Expand Down
28 changes: 17 additions & 11 deletions role-make-version-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ gh api graphql -f query="$prs_query" -q .data.search > "$prs_file"
count=$(jq '.issueCount' "$prs_file")
if [ "${count:-0}" = 0 ]; then
echo There are no merged PRs since latest tag "$latest_tag"
echo ""
if [ "$AUTOSKIP" = true ]; then
echo Autoskip enabled - skipping tag/release for role "$repo"
echo ""
skip=true
else
echo ""
fi
else
echo Pull requests since latest tag "$latest_tag":
Expand Down Expand Up @@ -174,6 +176,7 @@ else
elif [ "$skip" = true ]; then
echo Autoskip enabled - the role has only PRs of type "$AUTOSKIP_PR_TYPES"
echo If you want to this role, set AUTOSKIP_PR_TYPES=none and re-run this command
echo ""
fi
fi
if [ "$skip" = false ]; then
Expand All @@ -182,7 +185,7 @@ if [ "$skip" = false ]; then
gh api /repos/"$owner"/"$repo"/contents/.commitlintrc.js -q .content | \
base64 --decode > "$workdir/.commitlintrc.js"
echo ""
echo Verifying if all PR titles comply with the conventional commits format
echo Verifying if all PR titles comply with the conventional commits format ...
: > "$commitlint_errors_file"
while read -r pr_title; do
echo "$pr_title" | npx commitlint >> "$commitlint_errors_file" 2>&1 || :
Expand Down Expand Up @@ -223,7 +226,7 @@ if [ "$skip" = false ]; then
echo ERROR: unexpected tag "$latest_tag"
exit 1
fi
if grep -q '^.*!:.*' $pr_titles_file; then
if grep -q '^.*!:.*' "$pr_titles_file"; then
# Don't bump ver_major for prerelease versions (when ver_major=0)
if [[ "$ver_major" != 0 ]]; then
ver_major=$((ver_major+=1))
Expand All @@ -234,7 +237,7 @@ if [ "$skip" = false ]; then
ver_minor=$((ver_minor+=1))
ver_patch=0
fi
elif grep -q '^feat.*' $pr_titles_file; then
elif grep -q '^feat.*' "$pr_titles_file"; then
ver_minor=$((ver_minor+=1))
ver_patch=0
else
Expand All @@ -245,11 +248,11 @@ if [ "$skip" = false ]; then
read -r -p "The script calculates the new tag based on PR titles types.
The previous tag is ${latest_tag:-EMPTY}.
The new tag is $new_tag.
You have three options:
1. To continue with the suggested new tag $new_tag and edit CHANGELOG.md, enter 'y',
2. To provide a different tag, and edit CHANGELOG.md enter the new tag in the following format:
Here are your options:
* To continue with the suggested new tag $new_tag and edit CHANGELOG.md, enter 'y',
* To provide a different tag, and edit CHANGELOG.md enter the new tag in the following format:
${allow_v}X.Y.Z, where X, Y, and Z are integers,
3. To skip this role and go to the next role just press Enter. " new_tag_in
* To skip this role and go to the next role just press Enter. " new_tag_in
if [ -z "$new_tag_in" ]; then
break
elif [[ "$new_tag_in" =~ ^"$allow_v"[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
Expand All @@ -258,6 +261,7 @@ You have three options:
elif [ "$new_tag_in" == y ]; then
break
else
echo ""
echo ERROR: invalid input "$new_tag_in"
echo You must either input y or provide a new tag.
echo Tag must be in format "$allow_v"X.Y.Z
Expand Down Expand Up @@ -289,21 +293,21 @@ You have three options:
if [ -f "$new_features_file" ]; then
{ echo "### New Features"
echo ""
cat --squeeze-blank $new_features_file
cat --squeeze-blank "$new_features_file"
echo ""
} >> "$rel_notes_file"
fi
if [ -f "$bug_fixes_file" ]; then
{ echo "### Bug Fixes"
echo ""
cat --squeeze-blank $bug_fixes_file
cat --squeeze-blank "$bug_fixes_file"
echo ""
} >> "$rel_notes_file"
fi
if [ -f "$other_changes_file" ]; then
{ echo "### Other Changes"
echo ""
cat --squeeze-blank $other_changes_file
cat --squeeze-blank "$other_changes_file"
echo ""
} >> "$rel_notes_file"
fi
Expand Down Expand Up @@ -352,6 +356,8 @@ You have three options:
fi
popd > /dev/null 2>&1 # clone_repo does a pushd to repo dir
fi
echo ""
echo ""
fi

trap - EXIT
Expand Down

0 comments on commit b6ac58f

Please sign in to comment.