forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: generate nightly changelog from commit history (influxdata#22377)
* build: generated nightly changelog from commit history * build: update goreleaser version
- Loading branch information
1 parent
7ad612b
commit 824e76c
Showing
8 changed files
with
3,088 additions
and
1,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,7 @@ workflows: | |
only: | ||
- master | ||
jobs: | ||
- changelog | ||
- godeps | ||
- gotest: | ||
requires: | ||
|
@@ -137,6 +138,7 @@ workflows: | |
- godeps | ||
- deploy_nightly: | ||
requires: | ||
- changelog | ||
- gotest | ||
- golint | ||
- tlstest | ||
|
@@ -809,3 +811,35 @@ jobs: | |
docker load < docker-image.tar | ||
docker tag quay.io/influxdb/oss-acceptance:${CIRCLE_SHA1} quay.io/influxdb/oss-acceptance:latest | ||
docker push quay.io/influxdb/oss-acceptance:latest | ||
changelog: | ||
machine: | ||
image: ubuntu-2004:202010-01 | ||
steps: | ||
- checkout | ||
- install_core_deps | ||
- run: | ||
name: Run script | ||
command: | | ||
set -x | ||
git clone --depth=1 --branch v0.2.5 https://github.com/orhun/git-cliff | ||
cd git-cliff | ||
cargo install git-cliff | ||
cd .. | ||
TIMESTAMP="$(date -u '+%Y%m%d')" | ||
COMMIT_FILE_PATH="scripts/ci/changelog-commit.txt" | ||
LAST_COMMIT=$(cat $COMMIT_FILE_PATH) | ||
NEWEST_COMMIT=${CIRCLE_SHA1} | ||
./scripts/ci/update-changelog.sh \ | ||
--commit-range "$LAST_COMMIT..$NEWEST_COMMIT" \ | ||
--prepend CHANGELOG.md \ | ||
-- \ | ||
--tag $TIMESTAMP | ||
echo ${CIRCLE_SHA1} > $COMMIT_FILE_PATH | ||
git add CHANGELOG.md $COMMIT_FILE_PATH | ||
git config user.email "[email protected]" | ||
git config user.name "Edge Team CircleCI Automation" | ||
git commit -m "changelog: update $TIMESTAMP [skip ci]" | ||
git push origin $CIRCLE_BRANCH | ||
- store_artifacts: | ||
path: CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[changelog] | ||
body = """ | ||
{%- if version %} | ||
## {{ version }} [{{ timestamp | date(format="%Y-%m-%d") }}] | ||
{%- else %} | ||
## [unreleased] | ||
{%- endif %} | ||
---------------------- | ||
{% set grouped_commits = commits | group_by(attribute="group") -%} | ||
{%- set_global groups_arr = [] -%} | ||
{%- for group, _commits in grouped_commits -%} | ||
{%- set_global groups_arr = groups_arr | concat(with=group) -%} | ||
{%- endfor -%} | ||
{% for group in groups_arr | sort | reverse %} | ||
{% set g_commits = grouped_commits[group] -%} | ||
### {{ group | upper_first }} | ||
{% for commit in g_commits -%} | ||
{%- set message = commit.message | split(pat="\n") | first | split(pat=": ") | slice(start=1) | join(sep=" ") | trim | capitalize -%} | ||
{% set pr_num = message | split(pat=" ") | last | trim_start_matches(pat="(") | trim_end_matches(pat=")") | trim_start_matches(pat="#") %} | ||
{%- set message = message | split(pat=" ") | slice(end=-1) | join(sep=" ") | trim %} | ||
1. [{{ pr_num }}](https://github.com/influxdata/influxdb/pull/{{ pr_num }}): {{ message }} | ||
{%- endfor %} | ||
{% endfor %} | ||
""" | ||
trim = true | ||
|
||
[git] | ||
conventional_commits = false | ||
commit_parsers = [ | ||
{ message = "^feat*", group = "Features"}, | ||
{ message = "^fix*", group = "Bug Fixes"}, | ||
] | ||
filter_commits = true | ||
tag_pattern = "v[12].[0-9].[0-9]*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
891e7d47827e99947e46c82f509e479aa13acf24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash -ex | ||
|
||
|
||
dependencies="cargo git git-cliff" | ||
|
||
for dependency in $dependencies | ||
do | ||
if ! command -v $dependency &>/dev/null | ||
then | ||
echo "error: $dependency was not found in PATH" >&2 | ||
exit 255 | ||
fi | ||
done | ||
|
||
# The default "starting" commit is a somewhat arbitrary starting point for | ||
# cataloging recent commits in a way that breaks from the old convention | ||
DEFAULT_START_COMMIT="891e7d47827e99947e46c82f509e479aa13acf24" | ||
DEFAULT_NEWEST_COMMIT="$(git rev-parse HEAD)" | ||
DEFAULT_COMMIT_RANGE="${DEFAULT_START_COMMIT}..${DEFAULT_NEWEST_COMMIT}" | ||
|
||
COMMIT_RANGE="${DEFAULT_COMMIT_RANGE}" | ||
|
||
DEFAULT_GIT_CLIFF_OPTIONS="" | ||
PREPEND_TARGET="" | ||
|
||
function print-usage { | ||
cat << EOF >&2 | ||
usage: $0 [<options>] -- [<git cliff flags>] [<git cliff options>] | ||
--commit-range <git commit range> The specific range of commits from which to generate the changelog. | ||
A hardcoded default sets a range that is contemporaneous with the | ||
addition of this script to influxdb CI. | ||
Value: $COMMIT_RANGE | ||
--prepend <file path> Target a file to which to prepend the git-cliff output. This is not | ||
the same as the git-cliff prepend option, which can only be used with | ||
the -l or -u flags in that tool. | ||
Value: $PREPEND_TARGET | ||
Options specified after '--' separator are used by git-cliff directly | ||
EOF | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--commit-range) | ||
COMMIT_RANGE="$2" | ||
shift | ||
;; | ||
--prepend) | ||
PREPEND_TARGET="$2" | ||
shift | ||
;; | ||
--help) | ||
print-usage | ||
exit 255 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
echo "error: unknown option '$1'" >&2 | ||
exit 255 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
output="$(git cliff ${@} ${DEFAULT_GIT_CLIFF_OPTIONS} ${COMMIT_RANGE})" | ||
|
||
if [ -n "$PREPEND_TARGET" ] && [ -n "$output" ]; then | ||
newline=$'\n\n' | ||
echo "${output}${newline}$(cat $PREPEND_TARGET)" > $PREPEND_TARGET | ||
else | ||
echo "$output" | ||
fi |