Skip to content

Commit

Permalink
Merge pull request #4548 from KnVerey/improve-logs
Browse files Browse the repository at this point in the history
Improve logging for changelong builder
  • Loading branch information
k8s-ci-robot committed Mar 28, 2022
2 parents 4b64f1e + 6348ea9 commit cd0f9b0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
32 changes: 28 additions & 4 deletions releasing/README.md
Expand Up @@ -118,7 +118,13 @@ refreshMaster &&
testKustomizeRepo
```

While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].
While you're waiting for the tests, review the commit log:

```
releasing/compile-changelog.sh kyaml HEAD
```

Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].

kyaml has no intra-repo deps, so if the tests pass,
it can just be released.
Expand Down Expand Up @@ -185,7 +191,13 @@ refreshMaster &&
testKustomizeRepo
```

While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].
While you're waiting for the tests, review the commit log:

```
releasing/compile-changelog.sh cmd/config HEAD
```

Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].

#### Release it

Expand Down Expand Up @@ -243,7 +255,13 @@ refreshMaster &&
testKustomizeRepo
```

While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].
While you're waiting for the tests, review the commit log:

```
releasing/compile-changelog.sh api HEAD
```

Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].

#### Release it

Expand Down Expand Up @@ -298,7 +316,13 @@ refreshMaster &&
testKustomizeRepo
```

While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].
While you're waiting for the tests, review the commit log:

```
releasing/compile-changelog.sh kustomize HEAD
```

Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review].

#### Release it

Expand Down
19 changes: 15 additions & 4 deletions releasing/compile-changelog.sh
Expand Up @@ -18,24 +18,27 @@ set -o errexit
set -o nounset
set -o pipefail

if [[ -z "${1-}" ]] || [[ -z "${2-}" ]] || [[ -z "${3-}" ]]; then
if [[ -z "${1-}" ]] || [[ -z "${2-}" ]]; then
echo "Usage: $0 <module> <fullTag> <changeLogFile>"
echo "Example: $0 kyaml kyaml/v0.13.4 changelog.txt"
exit 1
fi

module=$1
fullTag=$2
changeLogFile=$3
changeLogFile="${3:-}"

# Find previous tag that matches the tags module
prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains="$fullTag" | head -n 1)
echo "Compiling $module changes from $prevTag to $fullTag"

commits=( $(git log "$prevTag".."$fullTag" \
--pretty=format:'%H' \
--abbrev-commit --no-decorate --no-color --no-merges \
-- "$module") )

echo "Gathering PRs for commits: ${commits[*]}"

# There is a 256 character limit on the query parameter for the GitHub API, so split into batches then deduplicate results
batchSize=5
results=""
Expand All @@ -45,9 +48,17 @@ do
if newResults=$(curl -sSL "https://api.github.com/search/issues?q=$commitList+repo%3Akubernetes-sigs%2Fkustomize" | jq -r '[ .items[] | { number, title } ]'); then
results=$(echo "$results" "$newResults" | jq -s '.[0] + .[1] | unique')
else
echo "Failed to fetch results for commits: $commitList"
echo "Failed to fetch results for commits (exit code $?): $commitList"
exit 1
fi
done

echo "${results}" | jq -r '.[] | select( .title | startswith("Back to development mode") | not) | "#\(.number): \(.title)" ' > "$changeLogFile"
changelog=$(echo "${results}" | jq -r '.[] | select( .title | startswith("Back to development mode") | not) | "#\(.number): \(.title)" ')

if [[ -n "$changeLogFile" ]]; then
echo "$changelog" > "$changeLogFile"
else
echo
echo "----CHANGE LOG----"
echo "$changelog"
fi

0 comments on commit cd0f9b0

Please sign in to comment.