diff --git a/build/conventi/Dockerfile b/build/conventi/Dockerfile new file mode 100644 index 0000000..c01d12f --- /dev/null +++ b/build/conventi/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:3.16.0 + +RUN apk --no-cache add \ + git \ + jq + +COPY conventi.sh /usr/local/bin/ + +VOLUME /conventi +WORKDIR /conventi + +ENTRYPOINT ["/usr/local/bin/conventi.sh"] +CMD [""] \ No newline at end of file diff --git a/build/conventi/conventi.sh b/build/conventi/conventi.sh index 10170e6..b5fcc05 100755 --- a/build/conventi/conventi.sh +++ b/build/conventi/conventi.sh @@ -230,39 +230,39 @@ add_changelog_entry_line() { ;; build) - build_lines="$build_lines\n* $2\n" + build_lines=$(printf '%s\n* %s\n' "$build_lines" "$2") ;; chore) - chore_lines="$chore_lines\n* $2\n" + chore_lines=$(printf '%s\n* %s\n' "$chore_lines" "$2") ;; ci) - ci_lines="$ci_lines\n* $2\n" + ci_lines=$(printf '%s\n* %s\n' "$ci_lines" "$2") ;; doc_lines) - doc_lines="$doc_lines\n* $2\n" + doc_lines=$(printf '%s\n* %s\n' "$doc_lines" "$2") ;; style) - style_lines="$style_lines\n* $2\n" + style_lines=$(printf '%s\n* %s\n' "$style_lines" "$2") ;; refactor) - refactor_lines="$refactor_lines\n* $2\n" + refactor_lines=$(printf '%s\n* %s\n' "$refactor_lines" "$2") ;; perf) - perf_lines="$perf_lines\n* $2\n" + perf_lines=$(printf '%s\n* %s\n' "$perf_lines" "$2") ;; test) - test_lines="$test_lines\n* $2\n" + test_lines=$(printf '%s\n* %s\n' "$test_lines" "$2") ;; revert) - revert_lines="$revert_lines\n* $2\n" + revert_lines=$(printf '%s\n* %s\n' "$revert_lines" "$2") ;; esac } @@ -270,44 +270,43 @@ add_changelog_entry_line() { format_entry() { entry="" if [ -n "$breaking_change_lines" ]; then - entry="$entry### BREAKING CHANGES\n$breaking_change_lines\n\n" + entry=$(printf '%s### BREAKING CHANGES\n%s\n\n' "$entry" "$breaking_change_lines") fi if [ -n "$bugfix_lines" ]; then - entry="$entry### Bug fixes\n$bugfix_lines\n\n" + entry=$(printf '%s### Bug fixes\n%s\n\n' "$entry" "$bugfix_lines") fi if [ -n "$feature_lines" ]; then - #entry="$entry### Features\n$feature_lines\n\n" entry=$(printf '%s### Features\n%s\n\n' "$entry" "$feature_lines") fi if [ -n "$revert_lines" ]; then - entry="$entry### Reverts\n$revert_lines\n\n" + entry=$(printf '%s### Reverts\n%s\n\n' "$entry" "$revert_lines") fi if [ -n "$build_lines" ]; then - entry="$entry### Build System\n$build_lines\n\n" + entry=$(printf '%s### Build System\n%s\n\n' "$entry" "$build_lines") fi if [ -n "$chore_lines" ]; then - entry="$entry### Chores\n$chore_lines\n\n" + entry=$(printf '%s### Chores\n%s\n\n' "$entry" "$chore_lines") fi if [ -n "$ci_lines" ]; then - entry="$entry### CIs\n$ci_lines\n\n" + entry=$(printf '%s### CIs\n%s\n\n' "$entry" "$ci_lines") fi if [ -n "$doc_lines" ]; then - entry="$entry### Docs\n$doc_lines\n\n" + entry=$(printf '%s### Docs\n%s\n\n' "$entry" "$doc_lines") fi if [ -n "$test_lines" ]; then - entry="$entry### Tests\n$test_lines\n\n" + entry=$(printf '%s### Tests\n%s\n\n' "$entry" "$test_lines") fi if [ -n "$style_lines" ]; then - entry="$entry### Styles\n$style_lines\n\n" + entry=$(printf '%s### Styles\n%s\n\n' "$entry" "$style_lines") fi if [ -n "$refactor_lines" ]; then - entry="$entry### Refactors\n$refactor_lines\n\n" + entry=$(printf '%s### Refactors\n%s\n\n' "$entry" "$refactor_lines") fi if [ -n "$perf_lines" ]; then - entry="$entry### Perfs\n$perf_lines\n\n" + entry=$(printf '%s### Performance\n%s\n\n' "$entry" "$perf_lines") fi if [ -n "$entry" ]; then - entry="## [$version]($(get_config_url)/compare/$from_hash...$to_hash) ($(date '+%Y-%m-%d'))\n\n\n$entry" + entry=$(printf '## [%s](%s/compare/%s...%s) (%s)\n\n\n%s' "$version" "$(get_config_url)" "$from_hash" "$to_hash" "$(date '+%Y-%m-%d')" "$entry") fi echo "$entry" } @@ -345,7 +344,7 @@ generate_changelog_entry() { if [ "$is_breaking" -eq 1 ]; then is_major=1 breaking_change=$(echo "$breaking_change" | sed -e '2,$s/^[ ]*/ /') - breaking_change_lines="$breaking_change_lines\n* $breaking_change\n" + breaking_change_lines=$(printf '%s\n* %s\n' "$breaking_change_lines" "$breaking_change") fi case "$type" in @@ -386,9 +385,9 @@ new_changelog_entry() { changelog=$(sed -n '/^----/,//{/^----/!p;}' <$changelog_file) if [ -n "$changelog" ]; then - changelog="$changelog_header\n$entry\n$changelog" + changelog=$(printf '%s\n%s\n%s' "$changelog_header" "$entry" "$changelog") else - changelog="$changelog_header\n$entry" + changelog=$(printf '%s\n%s' "$changelog_header" "$entry") fi echo "$changelog" >$changelog_file }