Skip to content

Commit

Permalink
Add changelogs for crates (#1075)
Browse files Browse the repository at this point in the history
Add `CHANGELOG.md` for each crate.

Closes #915
  • Loading branch information
juhaku authored Oct 2, 2024
1 parent abd3572 commit 61c98bb
Show file tree
Hide file tree
Showing 13 changed files with 1,393 additions and 55 deletions.
132 changes: 77 additions & 55 deletions .github/actions/gitlog/gitlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,97 +4,119 @@

output_file=""
crate=""
range=""
auth=""
while true; do
case $1 in
"--output-file")
shift
output_file="$1"
shift
;;
"--crate")
shift
crate="$1"
shift
;;
*)
break
;;
esac
case $1 in
"--output-file")
shift
output_file="$1"
shift
;;
"--crate")
shift
crate="$1"
shift
;;
"--range")
shift
range="$1"
shift
;;
"--auth")
shift
auth="$1"
shift
;;
*)
break
;;
esac
done

if [[ "$output_file" == "" ]]; then
echo "Missing --output-file <file> option argument, define path to file or - for stdout" && exit 1
echo "Missing --output-file <file> option argument, define path to file or - for stdout" && exit 1
fi
if [[ "$crate" == "" ]]; then
echo "Missing --crate <crate> option argument, need an explisit crate to get git log for" && exit 1
fi

from_commit=HEAD
last_release=$(git tag --sort=-committerdate | grep -E "$crate-[0-9]*\.[0-9]*\.[0-9]*" | head -1)
echo "Found tag: $last_release"
if [[ "$last_release" == "" ]]; then
last_release=$(git tag --sort=-committerdate | head -1) # get last tag
echo "Using latest tag: $last_release"
echo "Missing --crate <crate> option argument, need an explisit crate to get git log for" && exit 1
fi

commit_range=""
if [[ $last_release != "" ]]; then
commit_range="$from_commit...$last_release"
if [ -z "$range" ]; then
from_commit=HEAD
last_release=$(git tag --sort=-committerdate | grep -E "$crate-[0-9]*\.[0-9]*\.[0-9]*" | head -1)
echo "Found tag: $last_release"
if [[ "$last_release" == "" ]]; then
last_release=$(git tag --sort=-committerdate | head -1) # get last tag
echo "Using latest tag: $last_release"
fi

if [[ $last_release != "" ]]; then
commit_range="$from_commit...$last_release"
else
commit_range="$from_commit"
fi
else
commit_range="$from_commit"
commit_range="$range"
fi

ancestry_path=""
if [[ "$last_release" != "" ]]; then
ancestry_path="--ancestry-path"
ancestry_path="--ancestry-path"
fi

mapfile -t log_lines < <(git log --pretty=format:'(%h) %s' $ancestry_path "$commit_range")

function is_crate_related {
commit="$1"
changes="$(git diff --name-only "$commit"~ "$commit" | awk -F / '{print $1}' | xargs)"
commit="$1"
changes="$(git diff --name-only "$commit"~ "$commit" | awk -F / '{print $1}' | xargs)"

is_related=false
if [[ "$changes" == *"$crate"* ]]; then
is_related=true
fi
is_related=false
if [[ "$changes" == *"$crate"* ]]; then
is_related=true
fi

echo $is_related
echo $is_related
}

get_username() {
commit=$1
curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/juhaku/utoipa/commits/"$commit" | jq -r .author.login
commit=$1

args=()
if [ -n "$auth" ]; then
args=("${args[@]}" "-H" "Authorization: Bearer $auth")
fi

curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${args[@]}" \
https://api.github.com/repos/juhaku/utoipa/commits/"$commit" | jq -r .author.login
}

log=""
for line in "${log_lines[@]}"; do
commit=$(echo "$line" | awk -F ' ' '{print $1}')
commit=${commit//[\(\)]/}
commit=$(echo "$line" | awk -F ' ' '{print $1}')
commit=${commit//[\(\)]/}

if [[ $(is_crate_related "$commit") == true ]]; then
user=$(get_username "$commit")
log=$log"* $line @$user\n"
fi
if [[ $(is_crate_related "$commit") == true ]]; then
user=$(get_username "$commit")
log=$log"* $line @$user\n"
fi
done

if [[ "$output_file" != "" ]]; then
if [[ "$output_file" == "-" ]]; then
echo -e "$log"
else
echo -e "$log" >"$output_file"
fi
if [[ "$output_file" == "-" ]]; then
echo -e "$log"
else
echo -e "$log" >"$output_file"
fi
fi

if [[ "$last_release" == "" ]]; then
last_release=$(git rev-list --reverse HEAD | head -1)
last_release=$(git rev-list --reverse HEAD | head -1)
fi

if [ -n "$GITHUB_OUTPUT" ]; then
echo "last_release=$last_release" >>"$GITHUB_OUTPUT"
echo "last_release=$last_release" >>"$GITHUB_OUTPUT"
fi

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

Changelogs are kept separately for each create in this repository.

* [utoipa changelog](./utoipa/CHANGELOG.md)
* [utoipa-gen changelog](./utoipa-gen/CHANGELOG.md)
* [utoipa-axum changelog](./utoipa-axum/CHANGELOG.md)
* [utoipa-config changelog](./utoipa-config/CHANGELOG.md)
* [utoipa-rapidoc changelog](./utoipa-rapidoc/CHANGELOG.md)
* [utoipa-redoc changelog](./utoipa-redoc/CHANGELOG.md)
* [utoipa-swagger-ui changelog](./utoipa-swagger-ui/CHANGELOG.md)
* [utoipa-swagger-ui-vendored changelog](./utoipa-swagger-ui-vendored/CHANGELOG.md)

28 changes: 28 additions & 0 deletions utoipa-axum/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog - utoipa-axum

## Unreleased

### Added

* [8a5bb72](https://github.com/juhaku/utoipa/commit/8a5bb72) Add auto collect schemas for utoipa-axum (https://github.com/juhaku/utoipa/pull/1072)
* [9d778b0](https://github.com/juhaku/utoipa/commit/9d778b0) Add typos to CI (https://github.com/juhaku/utoipa/pull/1036)
* [a85e3f4](https://github.com/juhaku/utoipa/commit/a85e3f4) Add paths support for routes! macro (https://github.com/juhaku/utoipa/pull/1023)
* [11c909b](https://github.com/juhaku/utoipa/commit/11c909b) Add macros feature flag (https://github.com/juhaku/utoipa/pull/1015)
* [908d279](https://github.com/juhaku/utoipa/commit/908d279) Add `utoipa-axum` binding example and update docs (https://github.com/juhaku/utoipa/pull/1007)
* [69dfbbc](https://github.com/juhaku/utoipa/commit/69dfbbc) Add support to define mulitple operation methods (https://github.com/juhaku/utoipa/pull/1006)
* [a0db8b9](https://github.com/juhaku/utoipa/commit/a0db8b9) Add utoipa axum bindings (https://github.com/juhaku/utoipa/pull/1004)

### Fixed

* [2d81c9b](https://github.com/juhaku/utoipa/commit/2d81c9b) Fix testing without explicit features (https://github.com/juhaku/utoipa/pull/1041)
* [fcdb5db](https://github.com/juhaku/utoipa/commit/fcdb5db) Fix building utoipa-axum & utoipa-swagger-ui (https://github.com/juhaku/utoipa/pull/1038)
* [11058c6](https://github.com/juhaku/utoipa/commit/11058c6) Fix utoipa-axum project description
* [bcc4fca](https://github.com/juhaku/utoipa/commit/bcc4fca) Fix some typos

### Changed

* [b0ae6ef](https://github.com/juhaku/utoipa/commit/b0ae6ef) Chore change the operations implementation. (https://github.com/juhaku/utoipa/pull/1026)
* [8d8ff6e](https://github.com/juhaku/utoipa/commit/8d8ff6e) Update utoipa-axum version
* [90ec7a6](https://github.com/juhaku/utoipa/commit/90ec7a6) Enhance `utoipa-axum` bindings (https://github.com/juhaku/utoipa/pull/1017)
* [57ba3ba](https://github.com/juhaku/utoipa/commit/57ba3ba) Update next beta versions

12 changes: 12 additions & 0 deletions utoipa-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog - utoipa-config

## Unreleased

### Added

* [e66b4ed](https://github.com/juhaku/utoipa/commit/e66b4ed) Add global config for `utiopa` (https://github.com/juhaku/utoipa/pull/1048)

### Changed

* [26d4084](https://github.com/juhaku/utoipa/commit/26d4084) Update README.md

1 change: 1 addition & 0 deletions utoipa-config/LICENSE-APACHE
1 change: 1 addition & 0 deletions utoipa-config/LICENSE-MIT
Loading

0 comments on commit 61c98bb

Please sign in to comment.