From 94bafed95a256ace57f674ed65ff02a4b5989b2f Mon Sep 17 00:00:00 2001 From: helly25 Date: Tue, 18 Mar 2025 20:28:24 +0000 Subject: [PATCH 1/5] Bump version to 0.3.1 --- .pre-commit-config.yaml | 38 +++++++++++++++++++++++++++++++ CHANGELOG.md | 2 ++ MODULE.bazel | 2 +- tools/trigger_release.sh | 49 +++++++++++++++++++++++++++++++++++----- 4 files changed, 84 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c41c483..1c9718c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,6 +45,44 @@ repos: entry: .pre-commit/check_version.sh pass_filenames: False types: [text] + - id: no-do-not-merge + name: No 'DO NOT MERGE' + description: | + * You can add 'DONOTMERGE', 'DONOTSUBMIT', 'DO NOT MERGE', 'DO NOT SUBMIT', 'DON'T MERGE', + 'DON'T SUBMIT' or the same with underscores instead of spaces to prevent merging. + * To run `pre-commit` without this hook, run `SKIP="no-do-not-merge" pre-commit`. + language: pygrep + args: [-i] + entry: DO([ _]?NOT|N'T)[ _]?(SUBMIT|MERGE) + exclude: ^.pre-commit-config.yaml$ + types: [text] + - id: no-todos-without-context + name: No TODOs without context + description: | + * Use descriptive, referenceable TODOs. Examples: + * `// TODO(nero.windstriker@helly25.com)` + * `# FIXME(https://github.com/helly25/bzl/issues/42)` + * From the google style guide: + Use FIXME/TODO comments for code that is temporary, a short-term solution. + FIXME/TODOs should include the string `FIXME` or `TODO` in all caps, followed by a person's + e-mail address, or url with the best context about the problem referenced by the FIXME/TODO. + * A bug or other URL reference is better than a person, as the person may become unavailable. + * If a developer is referenced then it does not need to be the one writing the FIXME/TODO. + * It is more important to note the most knowledgable person. + * If you add someone else, first clarify with them. + * Concretely, FIXMEs and TODOs without a context are rather pointless. That is, sooner or + later noone knows why they were introduced and they will simply get deleted. + * It is impossible to systematically find your own TODOs, someone else' or perform any other + kind of statictics on them. The issue is that the blame tool tracks the last change, so you + would need a tool that can follow the history to the actual introduction of the FIXME/TODOs. + * To run `pre-commit` without this hook, run `SKIP="no-todos-without-context" pre-commit` + language: pygrep + args: [-i] + exclude: ^[.]pre-commit-config.yaml$ + entry: (#|//|/[*]).*(FIXME|TODO)[(](?!(((\w|\w[.-]\w)+@(\w|-)+([.](\w|-)+)*)|(https?://[^)]+))(,[^)]+)?)[)] + # 1 1 1 1 1 234 4 4 4 4 5 5 4 3 3 322 2 1 + types: [text] + - repo: https://github.com/keith/pre-commit-buildifier rev: 8.0.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa33b0..3c763b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# 0.3.1 + # 0.3.0 * Added `skip_build` parameter to control whether comparisons adhere to Semver-10. diff --git a/MODULE.bazel b/MODULE.bazel index 73d6c72..0a858ad 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,7 +16,7 @@ module( name = "helly25_bzl", - version = "0.3.0", + version = "0.3.1", ) bazel_dep(name = "bazel_skylib", version = "1.7.1") diff --git a/tools/trigger_release.sh b/tools/trigger_release.sh index fa959e3..b80f2fc 100755 --- a/tools/trigger_release.sh +++ b/tools/trigger_release.sh @@ -17,24 +17,61 @@ set -euo pipefail -function die() { echo "ERROR: ${*}" 1>&2 ; exit 1; } +function die() { + echo "ERROR: ${*}" 1>&2 ; #exit 1; +} -[ ${#} == 1 ] || die "Must provide a version argument." +[[ ${#} == 1 ]] || die "Must provide a version argument." + +git fetch origin main # Make sure the below is relevant + +if [[ -n "$(git status --porcelain)" ]]; then + # Non empty output means non clean branch. + die "Must be run from clean 'main' branch." +fi +if [[ -n "$(git diff origin/main --numstat)" ]]; then + die "Must be run from clean 'main' branch." +fi +if [[ -n "$(git diff origin/main --cached --numstat)" ]]; then + die "Must be run from clean 'main' branch." +fi VERSION="${1}" BAZELMOD_VERSION="$(sed -rne 's,.*version = "([0-9]+([.][0-9]+)+.*)".*,\1,p' < MODULE.bazel|head -n1)" CHANGELOG_VERSION="$(sed -rne 's,^# ([0-9]+([.][0-9]+)+.*)$,\1,p' < CHANGELOG.md|head -n1)" +NEXT_VERSION="$(echo "${VERSION}"|awk -F. '/^(0|[1-9][0-9]*)([.](0|[1-9][0-9]*)){2,}([-+]|$)/{print $1"."$2"."(($3)+1)}')" -if [ "${BAZELMOD_VERSION}" != "${CHANGELOG_VERSION}" ]; then +if [[ "${BAZELMOD_VERSION}" != "${CHANGELOG_VERSION}" ]]; then die "MODULE.bazel (${BAZELMOD_VERSION}) != CHANGELOG.md (${CHANGELOG_VERSION})." fi -if [ "${VERSION}" != "${BAZELMOD_VERSION}" ]; then +if [[ "${VERSION}" != "${BAZELMOD_VERSION}" ]]; then die "Provided version argument (${VERSION}) different from merged version (${BAZELMOD_VERSION})." fi +if [[ -z "${NEXT_VERSION}" ]]; then + die "Could not determine next version from input (${VERSION)})." +fi + grep "${VERSION}" < <(git tag -l) && die "Version tag is already in use." -git tag -s -a "${VERSION}" -git push origin --tags +###git tag -s -a "${VERSION}" +###git push origin --tags + +echo "Next version: ${NEXT_VERSION}" + +sed -i "0,/version = \"${VERSION}\"/s/version = \"${VERSION}\"/version = \"${NEXT_VERSION}\"/" MODULE.bazel + +sed -i "1i\ + # ${NEXT_VERSION}\n" CHANGELOG.md + +NEXT_BRANCH="chore/bump_version_to_${NEXT_VERSION}" + +git branch "${NEXT_BRANCH}" +git checkout "${NEXT_BRANCH}" +git add MODULE.bazel +git add CHANGELOG.md +git commit -m "Bump version to ${NEXT_VERSION}" +git push -u origin "${NEXT_BRANCH}" +git push From 785524bcf5a46f89e2aff31a3900116f2bc5a292 Mon Sep 17 00:00:00 2001 From: helly25 Date: Tue, 18 Mar 2025 20:29:04 +0000 Subject: [PATCH 2/5] Remove debug stuff. --- tools/trigger_release.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/trigger_release.sh b/tools/trigger_release.sh index b80f2fc..6255651 100755 --- a/tools/trigger_release.sh +++ b/tools/trigger_release.sh @@ -17,9 +17,7 @@ set -euo pipefail -function die() { - echo "ERROR: ${*}" 1>&2 ; #exit 1; -} +function die() { echo "ERROR: ${*}" 1>&2 ; exit 1; } [[ ${#} == 1 ]] || die "Must provide a version argument." @@ -56,8 +54,8 @@ fi grep "${VERSION}" < <(git tag -l) && die "Version tag is already in use." -###git tag -s -a "${VERSION}" -###git push origin --tags +git tag -s -a "${VERSION}" +git push origin --tags echo "Next version: ${NEXT_VERSION}" @@ -68,8 +66,7 @@ sed -i "1i\ NEXT_BRANCH="chore/bump_version_to_${NEXT_VERSION}" -git branch "${NEXT_BRANCH}" -git checkout "${NEXT_BRANCH}" +git checkout -b "${NEXT_BRANCH}" git add MODULE.bazel git add CHANGELOG.md git commit -m "Bump version to ${NEXT_VERSION}" From 8a408b70eedfc54805da980b97c59fd1760509ea Mon Sep 17 00:00:00 2001 From: helly25 Date: Tue, 18 Mar 2025 20:31:41 +0000 Subject: [PATCH 3/5] Create PR --- tools/trigger_release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/trigger_release.sh b/tools/trigger_release.sh index 6255651..905e362 100755 --- a/tools/trigger_release.sh +++ b/tools/trigger_release.sh @@ -72,3 +72,6 @@ git add CHANGELOG.md git commit -m "Bump version to ${NEXT_VERSION}" git push -u origin "${NEXT_BRANCH}" git push +if which gh; then + gh pr create --title "Bump version to ${NEXT_VERSION}" +fi From 3a5e3c363582f3513e49c997fd162c3eed1b8e8d Mon Sep 17 00:00:00 2001 From: helly25 Date: Tue, 18 Mar 2025 20:33:14 +0000 Subject: [PATCH 4/5] MODULE.bazel goes first - it's simler and is the one that should be used. --- .github/workflows/release_prep.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 1842645..daaa769 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -89,6 +89,12 @@ echo "## [Changelog](https://github.com/helly25/${PACKAGE_NAME}/blob/${TAG}/CHAN awk '/^#/{f+=1;if(f>1)exit} !/^#/{print}' < CHANGELOG.md cat << EOF +## For Bazel MODULE.bazel + +\`\`\` +bazel_dep(name = "${BAZELMOD_NAME}", version = "${TAG}") +\`\`\` + ## For Bazel WORKSPACE \`\`\` @@ -100,10 +106,4 @@ http_archive( sha256 = "${SHA256}", ) \`\`\` - -## For Bazel MODULES.bazel - -\`\`\` -bazel_dep(name = "${BAZELMOD_NAME}", version = "${TAG}") -\`\`\` EOF From 3a33d61fbdbcf84e7166183c7cad1f12dda9606a Mon Sep 17 00:00:00 2001 From: helly25 Date: Tue, 18 Mar 2025 20:35:41 +0000 Subject: [PATCH 5/5] Add PR body. --- tools/trigger_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/trigger_release.sh b/tools/trigger_release.sh index 905e362..4b60324 100755 --- a/tools/trigger_release.sh +++ b/tools/trigger_release.sh @@ -73,5 +73,5 @@ git commit -m "Bump version to ${NEXT_VERSION}" git push -u origin "${NEXT_BRANCH}" git push if which gh; then - gh pr create --title "Bump version to ${NEXT_VERSION}" + gh pr create --title "Bump version to ${NEXT_VERSION}" -b "Created by ${0}." fi