diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47a3754..2cf32cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,12 +4,12 @@ default_language_version: python: python3 repos: - repo: https://github.com/commitizen-tools/commitizen - rev: v2.17.6 + rev: v2.19.0 hooks: - id: commitizen stages: [commit-msg] - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.12 + rev: v0.1.15 hooks: - id: helmlint - repo: https://github.com/gherynos/pre-commit-java @@ -44,11 +44,11 @@ repos: - "2" - -ci - repo: https://github.com/markdownlint/markdownlint - rev: master + rev: v0.11.0 hooks: - - id: markdownlint_docker + - id: markdownlint - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.26.0 + rev: v8.0.0-rc.0 hooks: - id: eslint - repo: https://github.com/pre-commit/pre-commit-hooks @@ -89,12 +89,12 @@ repos: - id: fmt - id: cargo-check - repo: https://github.com/adrienverge/yamllint - rev: v1.26.1 + rev: v1.26.3 hooks: - id: yamllint exclude: ".*/templates/.*" - repo: https://github.com/IamTheFij/docker-pre-commit - rev: v2.0.0 + rev: v2.0.1 hooks: - id: docker-compose-check - id: docker-compose-check diff --git a/bash/update-repo-tags b/bash/update-repo-tags index 4288f59..6d7df17 100755 --- a/bash/update-repo-tags +++ b/bash/update-repo-tags @@ -29,8 +29,6 @@ options::add -o t -d "target directory to examine and update" -a -m \ -e TARGET_DIR options::add -o p -d "Patch tag" \ -x PATCH_TAG -options::add -o n -d "Don't annotate tag" \ - -x DONT_ANNOTATE_TAG options::add -o b -d "proceed to bump minor version if breaking changes are found" \ -x ALLOW_BREAKING options::add -o c -d "generate and commit change before tagging" \ @@ -40,11 +38,23 @@ options::parse "$@" pushd "$TARGET_DIR" >/dev/null || exit 1 LATEST_TAG=$(git::cmd describe --tags --match 'v*' --abbrev=0) || exit 1 +DONT_ANNOTATE_TAG=false +if ! LATEST_ANNOTATED_TAG=$(git::cmd describe --match 'v*' --abbrev=0 2>/dev/null); then + log::notice "No prior tag was annotated" + DONT_ANNOTATE_TAG=true +else + if [ "$LATEST_TAG" != "$LATEST_ANNOTATED_TAG" ] || [ -z "$LATEST_ANNOTATED_TAG" ]; then + DONT_ANNOTATE_TAG=true + else + DONT_ANNOTATE_TAG=false + fi +fi + LATEST_VERSION=$(echo "$LATEST_TAG" | cut -c2-) BREAKING_CHANGES=$(git::cmd log "$LATEST_TAG"..HEAD | grep -c "BREAKING CHANGE") CHANGES=$(git::cmd log "$LATEST_TAG"..HEAD | grep -c "^commit") -log::notice "$LATEST_VERSION $CHANGES changes $BREAKING_CHANGES breaks" +log::notice "Since $LATEST_VERSION $CHANGES changes $BREAKING_CHANGES breaks" skip="true" if [ "$BREAKING_CHANGES" -gt 0 ]; then @@ -56,9 +66,18 @@ if [ "$BREAKING_CHANGES" -gt 0 ]; then exit 1 fi elif [ "$CHANGES" -gt 0 ]; then - TAG=$("$(dirs::of)/semver" bump patch "$LATEST_VERSION") + # if we can't annotate tag then we must do a prerel bump + if [ "${DONT_ANNOTATE_TAG}" = "true" ]; then + PREREL=$("$(dirs::of)/semver" get prerel "$LATEST_VERSION") + ((PREREL++)) + TAG=$("$(dirs::of)/semver" bump prerel "$PREREL" "$LATEST_VERSION") + TAG=${TAG/"-$PREREL"/"p$PREREL"} + else + TAG=$("$(dirs::of)/semver" bump patch "$LATEST_VERSION") + fi skip="false" else + log::notice "No changes since $LATEST_VERSION" TAG="$LATEST_VERSION" skip="true" fi @@ -68,12 +87,17 @@ TAG="v${TAG}" if [ "$skip" = "false" ]; then log::notice "Will tag as $TAG" if [ "$DONT_ANNOTATE_TAG" = "true" ]; then + log::notice "No changelog updates for prerel builds" git::cmd tag "$TAG" else if [ "$GENERATE_CHANGELOG" = "true" ]; then - "$(dirs::of)"/changelog -l | sed -e "s/Unreleased/$TAG/" >CHANGELOG.md - git add CHANGELOG.md - git commit --no-verify -m "ci: Update CHANGELOG releasing $TAG" CHANGELOG.md + if [ -r "CHANGELOG.md" ]; then + "$(dirs::of)"/changelog -l | sed -e "s/Unreleased/$TAG/" >CHANGELOG.md + git add CHANGELOG.md + git commit --no-verify -m "ci: Update CHANGELOG releasing $TAG" CHANGELOG.md + else + log::notice "No prior changelog found. Will not generate a new one." + fi fi git::cmd tag -a -s "$TAG" -m "Auto Tagging $TAG" fi