build: automate changelog (#22522)
parent
d2199efcd7
commit
380dade9b3
|
@ -6,6 +6,15 @@ parameters:
|
|||
type: string
|
||||
default: go1.15.10-ec819fab057e2efdcf478fec05bb5533957721ec
|
||||
|
||||
commands:
|
||||
install_rust:
|
||||
steps:
|
||||
- run:
|
||||
name: Install Rust toolchain
|
||||
command: |
|
||||
./scripts/ci/install-rust.sh
|
||||
echo 'export PATH=${HOME}/.cargo/bin:${PATH}' >> $BASH_ENV
|
||||
|
||||
jobs:
|
||||
build_binaries:
|
||||
docker:
|
||||
|
@ -158,6 +167,53 @@ jobs:
|
|||
name: Execute test
|
||||
command: ./test-flux.sh || exit 1
|
||||
no_output_timeout: 1500s
|
||||
changelog:
|
||||
machine:
|
||||
image: ubuntu-2004:202010-01
|
||||
steps:
|
||||
- checkout
|
||||
- install_rust
|
||||
- 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 ..
|
||||
|
||||
S3_PATH="https://s3.amazonaws.com/dl.influxdata.com/platform/nightlies/master-1.x"
|
||||
curl -o CHANGELOG.md ${S3_PATH}/CHANGELOG.md
|
||||
curl -o scripts/ci/changelog-commit.txt ${S3_PATH}/changelog-commit.txt
|
||||
|
||||
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
|
||||
|
||||
mkdir changelog_artifacts
|
||||
cp CHANGELOG.md changelog_artifacts
|
||||
cp $COMMIT_FILE_PATH changelog_artifacts
|
||||
- store_artifacts:
|
||||
path: changelog_artifacts/
|
||||
- aws-s3/copy:
|
||||
arguments: |
|
||||
--acl public-read
|
||||
aws-region: AWS_S3_REGION
|
||||
from: changelog_artifacts/changelog-commit.txt
|
||||
to: s3://dl.influxdata.com/platform/nightlies/master-1.x/changelog-commit.txt
|
||||
- aws-s3/copy:
|
||||
arguments: |
|
||||
--acl public-read
|
||||
aws-region: AWS_S3_REGION
|
||||
from: changelog_artifacts/CHANGELOG.md
|
||||
to: s3://dl.influxdata.com/platform/nightlies/master-1.x/CHANGELOG.md
|
||||
|
||||
workflows:
|
||||
version: 2.1
|
||||
|
@ -180,6 +236,7 @@ workflows:
|
|||
- "master-1.x"
|
||||
- "1.9"
|
||||
jobs:
|
||||
- changelog
|
||||
- static_code_checks
|
||||
- fluxtest
|
||||
- unit_test
|
||||
|
@ -187,6 +244,7 @@ workflows:
|
|||
- unit_test_race
|
||||
- build_binaries:
|
||||
requires:
|
||||
- changelog
|
||||
- static_code_checks
|
||||
- fluxtest
|
||||
- unit_test
|
||||
|
|
3468
CHANGELOG.md
3468
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -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]*"
|
|
@ -0,0 +1 @@
|
|||
f71ab14888cb1c5bd192557314e213ca2332df57
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
flux_dir=$(go list -m -f '{{.Dir}}' github.com/influxdata/flux)
|
||||
FLUX_RUST_VERSION=$(cat ${flux_dir}/Dockerfile_build | grep 'FROM rust:' | cut -d ' ' -f2 | cut -d ':' -f2)
|
||||
RUST_LATEST_VERSION=${FLUX_RUST_VERSION:-1.53}
|
||||
cd ..
|
||||
rm -rf flux-repo
|
||||
|
||||
# For security, we specify a particular rustup version and a SHA256 hash, computed
|
||||
# ourselves and hardcoded here. When updating `RUSTUP_LATEST_VERSION`:
|
||||
# 1. Download the new rustup script from https://github.com/rust-lang/rustup/releases.
|
||||
# 2. Audit the script and changes to it. You might want to grep for strange URLs...
|
||||
# 3. Update `OUR_RUSTUP_SHA` with the result of running `sha256sum rustup-init.sh`.
|
||||
RUSTUP_LATEST_VERSION=1.24.2
|
||||
OUR_RUSTUP_SHA="40229562d4fa60e102646644e473575bae22ff56c3a706898a47d7241c9c031e"
|
||||
|
||||
|
||||
# Download rustup script
|
||||
curl --proto '=https' --tlsv1.2 -sSf \
|
||||
https://raw.githubusercontent.com/rust-lang/rustup/${RUSTUP_LATEST_VERSION}/rustup-init.sh -O
|
||||
|
||||
# Verify checksum of rustup script. Exit with error if check fails.
|
||||
echo "${OUR_RUSTUP_SHA} rustup-init.sh" | sha256sum --check -- \
|
||||
|| { echo "Checksum problem!"; exit 1; }
|
||||
|
||||
# Run rustup.
|
||||
sh rustup-init.sh --default-toolchain "$RUST_LATEST_VERSION" -y
|
||||
export PATH="${HOME}/.cargo/bin:${PATH}"
|
|
@ -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="f71ab14888cb1c5bd192557314e213ca2332df57"
|
||||
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
|
Loading…
Reference in New Issue