Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

\`\`\`
Expand All @@ -100,10 +106,4 @@ http_archive(
sha256 = "${SHA256}",
)
\`\`\`

## For Bazel MODULES.bazel

\`\`\`
bazel_dep(name = "${BAZELMOD_NAME}", version = "${TAG}")
\`\`\`
EOF
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 0.3.1

# 0.3.0

* Added `skip_build` parameter to control whether comparisons adhere to Semver-10.
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
43 changes: 40 additions & 3 deletions tools/trigger_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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