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 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..4b60324 100755 --- a/tools/trigger_release.sh +++ b/tools/trigger_release.sh @@ -19,22 +19,59 @@ set -euo pipefail 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 + +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 checkout -b "${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 +if which gh; then + gh pr create --title "Bump version to ${NEXT_VERSION}" -b "Created by ${0}." +fi