Skip to content

Commit 8ed4e34

Browse files
committed
fix(bash): enhance update-repo-tags to detect annotated tags
and support prerel versions Signed-off-by: Kevin O'Donnell <kevin@blockchaintp.com>
1 parent 19789ad commit 8ed4e34

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ default_language_version:
44
python: python3
55
repos:
66
- repo: https://github.com/commitizen-tools/commitizen
7-
rev: v2.17.6
7+
rev: v2.19.0
88
hooks:
99
- id: commitizen
1010
stages: [commit-msg]
1111
- repo: https://github.com/gruntwork-io/pre-commit
12-
rev: v0.1.12
12+
rev: v0.1.15
1313
hooks:
1414
- id: helmlint
1515
- repo: https://github.com/gherynos/pre-commit-java
@@ -44,11 +44,11 @@ repos:
4444
- "2"
4545
- -ci
4646
- repo: https://github.com/markdownlint/markdownlint
47-
rev: master
47+
rev: v0.11.0
4848
hooks:
49-
- id: markdownlint_docker
49+
- id: markdownlint
5050
- repo: https://github.com/pre-commit/mirrors-eslint
51-
rev: v7.26.0
51+
rev: v8.0.0-rc.0
5252
hooks:
5353
- id: eslint
5454
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -89,12 +89,12 @@ repos:
8989
- id: fmt
9090
- id: cargo-check
9191
- repo: https://github.com/adrienverge/yamllint
92-
rev: v1.26.1
92+
rev: v1.26.3
9393
hooks:
9494
- id: yamllint
9595
exclude: ".*/templates/.*"
9696
- repo: https://github.com/IamTheFij/docker-pre-commit
97-
rev: v2.0.0
97+
rev: v2.0.1
9898
hooks:
9999
- id: docker-compose-check
100100
- id: docker-compose-check

bash/update-repo-tags

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ options::add -o t -d "target directory to examine and update" -a -m \
2929
-e TARGET_DIR
3030
options::add -o p -d "Patch tag" \
3131
-x PATCH_TAG
32-
options::add -o n -d "Don't annotate tag" \
33-
-x DONT_ANNOTATE_TAG
3432
options::add -o b -d "proceed to bump minor version if breaking changes are found" \
3533
-x ALLOW_BREAKING
3634
options::add -o c -d "generate and commit change before tagging" \
@@ -40,11 +38,23 @@ options::parse "$@"
4038
pushd "$TARGET_DIR" >/dev/null || exit 1
4139

4240
LATEST_TAG=$(git::cmd describe --tags --match 'v*' --abbrev=0) || exit 1
41+
DONT_ANNOTATE_TAG=false
42+
if ! LATEST_ANNOTATED_TAG=$(git::cmd describe --match 'v*' --abbrev=0 2>/dev/null); then
43+
log::notice "No prior tag was annotated"
44+
DONT_ANNOTATE_TAG=true
45+
else
46+
if [ "$LATEST_TAG" != "$LATEST_ANNOTATED_TAG" ] || [ -z "$LATEST_ANNOTATED_TAG" ]; then
47+
DONT_ANNOTATE_TAG=true
48+
else
49+
DONT_ANNOTATE_TAG=false
50+
fi
51+
fi
52+
4353
LATEST_VERSION=$(echo "$LATEST_TAG" | cut -c2-)
4454
BREAKING_CHANGES=$(git::cmd log "$LATEST_TAG"..HEAD | grep -c "BREAKING CHANGE")
4555
CHANGES=$(git::cmd log "$LATEST_TAG"..HEAD | grep -c "^commit")
4656

47-
log::notice "$LATEST_VERSION $CHANGES changes $BREAKING_CHANGES breaks"
57+
log::notice "Since $LATEST_VERSION $CHANGES changes $BREAKING_CHANGES breaks"
4858

4959
skip="true"
5060
if [ "$BREAKING_CHANGES" -gt 0 ]; then
@@ -56,9 +66,18 @@ if [ "$BREAKING_CHANGES" -gt 0 ]; then
5666
exit 1
5767
fi
5868
elif [ "$CHANGES" -gt 0 ]; then
59-
TAG=$("$(dirs::of)/semver" bump patch "$LATEST_VERSION")
69+
# if we can't annotate tag then we must do a prerel bump
70+
if [ "${DONT_ANNOTATE_TAG}" = "true" ]; then
71+
PREREL=$("$(dirs::of)/semver" get prerel "$LATEST_VERSION")
72+
((PREREL++))
73+
TAG=$("$(dirs::of)/semver" bump prerel "$PREREL" "$LATEST_VERSION")
74+
TAG=${TAG/"-$PREREL"/"p$PREREL"}
75+
else
76+
TAG=$("$(dirs::of)/semver" bump patch "$LATEST_VERSION")
77+
fi
6078
skip="false"
6179
else
80+
log::notice "No changes since $LATEST_VERSION"
6281
TAG="$LATEST_VERSION"
6382
skip="true"
6483
fi
@@ -68,12 +87,17 @@ TAG="v${TAG}"
6887
if [ "$skip" = "false" ]; then
6988
log::notice "Will tag as $TAG"
7089
if [ "$DONT_ANNOTATE_TAG" = "true" ]; then
90+
log::notice "No changelog updates for prerel builds"
7191
git::cmd tag "$TAG"
7292
else
7393
if [ "$GENERATE_CHANGELOG" = "true" ]; then
74-
"$(dirs::of)"/changelog -l | sed -e "s/Unreleased/$TAG/" >CHANGELOG.md
75-
git add CHANGELOG.md
76-
git commit --no-verify -m "ci: Update CHANGELOG releasing $TAG" CHANGELOG.md
94+
if [ -r "CHANGELOG.md" ]; then
95+
"$(dirs::of)"/changelog -l | sed -e "s/Unreleased/$TAG/" >CHANGELOG.md
96+
git add CHANGELOG.md
97+
git commit --no-verify -m "ci: Update CHANGELOG releasing $TAG" CHANGELOG.md
98+
else
99+
log::notice "No prior changelog found. Will not generate a new one."
100+
fi
77101
fi
78102
git::cmd tag -a -s "$TAG" -m "Auto Tagging $TAG"
79103
fi

0 commit comments

Comments
 (0)