From 4399c4932d7b0565932a667e051f6861b8293157 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 15 May 2024 23:56:52 +0200 Subject: [PATCH] build(release.sh): use git cliff, drop old script --- MAINTAIN.md | 4 +-- scripts/cliff.toml | 22 +++++++------- scripts/git-log-pretty-since.sh | 52 --------------------------------- scripts/release.sh | 12 ++++---- 4 files changed, 17 insertions(+), 73 deletions(-) delete mode 100755 scripts/git-log-pretty-since.sh diff --git a/MAINTAIN.md b/MAINTAIN.md index dc2bdaf1f1..f7f0c5769c 100644 --- a/MAINTAIN.md +++ b/MAINTAIN.md @@ -50,9 +50,7 @@ has a major bug: 1. Fix the bug on `master`. 2. Cherry-pick the fix to `release-x.y`. 3. Cut a release from `release-x.y`. - * Run `git cliff --config scripts/cliff.toml --unreleased -o CHANGELOG.md` - * Run `./scripts/release.sh` - * Paste `CHANGELOG.md` into the release commit message. + * Run `./scripts/release.sh` (requires [git cliff](https://github.com/orhun/git-cliff)) * The [CI job](https://github.com/neovim/neovim/blob/3d45706478cd030c3ee05b4f336164bb96138095/.github/workflows/release.yml#L11-L13) will update the release assets and [force-push to the "stable" tag](https://github.com/neovim/neovim/blob/cdd87222c86c5b2274a13d36f23de0637462e317/.github/workflows/release.yml#L229). diff --git a/scripts/cliff.toml b/scripts/cliff.toml index ead7d2b821..51725cacfc 100644 --- a/scripts/cliff.toml +++ b/scripts/cliff.toml @@ -47,18 +47,18 @@ commit_preprocessors = [ ] # regex for parsing and grouping commits commit_parsers = [ - { message = "!:", group = "Breaking"}, - { message = "^feat", group = "Features"}, - { message = "^fix", group = "Bug Fixes"}, - { message = "^perf", group = "Performance"}, - { message = "^build", group = "Build System"}, - { message = "^vim-patch", group = "Vim patches"}, - { message = "^refactor", group = "Refactor" }, + { message = "!:", group = "BREAKING"}, + { message = "^feat", group = "FEATURES"}, + { message = "^fix", group = "FIXES"}, + { message = "^perf", group = "PERFORMANCE"}, + { message = "^build", group = "BUILD"}, + { message = "^vim-patch", group = "VIM PATCHES"}, + { message = "^refactor", group = "REFACTOR" }, { message = "^ci", group = "CI" }, - { message = "^test", group = "Testing" }, - { message = "^docs", group = "Documentation" }, - { message = "^revert", group = "Reverted Changes" }, - { message = ".*", group = "Other"}, + { message = "^test", group = "TESTING" }, + { message = "^docs", group = "DOCUMENTATION" }, + { message = "^revert", group = "REVERTED CHANGES" }, + { message = ".*", group = "OTHER"}, ] # filter out the commits that are not matched by commit parsers filter_commits = true diff --git a/scripts/git-log-pretty-since.sh b/scripts/git-log-pretty-since.sh deleted file mode 100755 index 95dcee23f5..0000000000 --- a/scripts/git-log-pretty-since.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash - -# Prints a nicely-formatted commit history. -# - Commits are grouped below their merge-commit. -# - Issue numbers are moved next to the commit-id. -# -# Parameters: -# $1 "since" commit -# $2 "inverse match" regex pattern - -set -e -set -u -set -o pipefail - -__SINCE=$1 -__INVMATCH=$2 - -is_merge_commit() { - git rev-parse "$1" >/dev/null 2>&1 \ - || { echo "ERROR: invalid commit: $1"; exit 1; } - git log "$1"^2 >/dev/null 2>&1 && return 0 || return 1 -} - -# Removes parens from issue/ticket/PR numbers. -# -# Example: -# in: 3340e08becbf foo (#9423) -# out: 3340e08becbf foo #9423 -_deparen() { - sed 's/(\(\#[0-9]\{3,\}\))/\1/g' -} - -# Cleans up issue/ticket/PR numbers in the commit descriptions. -# -# Example: -# in: 3340e08becbf foo (#9423) -# out: 3340e08becbf #9423 foo -_format_ticketnums() { - nvim -Es +'g/\v(#[0-9]{3,})/norm! ngEldE0ep' +'%p' | _deparen -} - -for commit in $(git log --format='%H' --first-parent "$__SINCE"..HEAD); do - if is_merge_commit "${commit}" ; then - if [ -z "$__INVMATCH" ] || ! git log --oneline "${commit}^1..${commit}^2" \ - | >/dev/null 2>&1 grep -E "$__INVMATCH" ; then - git log -1 --oneline "${commit}" - git log --format=' %h %s' "${commit}^1..${commit}^2" - fi - else - git log -1 --oneline "${commit}" - fi -done | _format_ticketnums diff --git a/scripts/release.sh b/scripts/release.sh index f63c199fc9..8e26ecb244 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -43,18 +43,16 @@ __API_LEVEL=$(grep 'set(NVIM_API_LEVEL ' CMakeLists.txt\ && { echo "ERROR: version parse failed: '${__VERSION}'"; exit 1; } __RELEASE_MSG="NVIM v${__VERSION} -FEATURES: - -FIXES: - -CHANGES: - " __BUMP_MSG="version bump" echo "Most recent tag: ${__LAST_TAG}" echo "Release version: ${__VERSION}" +_git_log_pretty() { + git cliff --config scripts/cliff.toml --unreleased || echo 'git cliff failed' +} + _do_release_commit() { $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt if grep '(NVIM_API_PRERELEASE true)' CMakeLists.txt > /dev/null; then @@ -73,7 +71,7 @@ _do_release_commit() { echo "Building changelog since ${__LAST_TAG}..." git add CMakeLists.txt - (echo "${__RELEASE_MSG}"; ./scripts/git-log-pretty-since.sh "$__LAST_TAG" 'vim-patch:[^[:space:]]') | git commit --edit -F - + (echo "${__RELEASE_MSG}"; _git_log_pretty) | git commit --edit -F - fi git tag --sign -a v"${__VERSION}" -m "NVIM v${__VERSION}"