Skip to content

Commit

Permalink
Update release and changelog scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyg committed Jan 30, 2024
1 parent f757236 commit 1a46fd6
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
uses: orhun/git-cliff-action@v2
with:
args: -vv --latest --strip all
- name: Create release
run: gh release create ${{ github.ref_name}} -F CHANGELOG.md
run: gh release create ${{ github.ref_name}} -F git-cliff/CHANGELOG.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ mvn clean install
mvn -q -pl examples exec:java -Dexec.mainClass=dev.andstuff.kraken.example.Examples
```


[1]: https://www.kraken.com/en-us/help/api
[1]: https://docs.kraken.com/rest/
7 changes: 0 additions & 7 deletions changelog.sh

This file was deleted.

68 changes: 29 additions & 39 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
# git-cliff ~ default configuration file
# git-cliff configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.


[changelog]

# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
# Changelog\n\n
"""

# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}](<REPO>/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
### {{ group | striptags | trim }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
- [`{{ commit.id | truncate(length=7, end="") }}`](<REPO>/commit/{{ commit.id }}) \
{% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}**[breaking]** {% endif %}\
{{ commit.message | split(pat="\n") | first | upper_first | trim }}\
{% endfor %}
{% endfor %}\n
"""

# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
footer = "<!-- generated by git-cliff -->"

# remove the leading and trailing s
# remove the leading and trailing whitespace from the templates
trim = true

# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
{ pattern = '<REPO>', replace = "https://github.com/nyg/kraken-api-java" }
]


Expand All @@ -58,29 +53,24 @@ split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Replace issue numbers
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" },
{ pattern = ' #([0-9]+) ', replace = " [#${1}](<REPO>/issues/${1}) " }
]

# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^(chore|ci)", group = "Miscellaneous Tasks" },
{ message = "^revert", group = "Revert" },
{ message = "^\\[maven-release-plugin\\]", skip = true },
{ message = ".*", group = "Other" },
{ message = "^security", group = "<!-- 0 -->🛡️ Security" },
{ message = "^feat", group = "<!-- 1 -->⛰️ Features" },
{ message = "^fix", group = "<!-- 2 -->🐛 Bug Fixes" },
{ message = "^refactor", group = "<!-- 3 -->🚜 Refactor" },
{ message = "^doc", group = "<!-- 4 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 5 -->⚡ Performance" },
{ message = "^style", group = "<!-- 6 -->🎨 Styling" },
{ message = "^test", group = "<!-- 7 -->🧪 Testing" },
{ message = "^chore\\(release\\):", skip = true },
{ message = "^(chore|ci|build)", group = "<!-- 8 -->⚙️ Miscellaneous" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
{ message = ".*", group = "Others" },
]

# protect breaking changes from being skipped due to matching a skipping commit_parser
Expand Down
3 changes: 1 addition & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
3 changes: 1 addition & 2 deletions library/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
11 changes: 5 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -85,7 +84,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<configuration>
<executable>./changelog.sh</executable>
<executable>./scripts/generate-changelog.sh</executable>
</configuration>
</plugin>
<plugin>
Expand All @@ -95,10 +94,10 @@
<configuration>
<!-- release:prepare -->
<autoVersionSubmodules>true</autoVersionSubmodules>
<tagNameFormat>v@{version}</tagNameFormat>
<signTag>true</signTag>
<preparationGoals>clean verify exec:exec</preparationGoals>
<pushChanges>false</pushChanges>
<scmCommentPrefix>chore(release):&#32;</scmCommentPrefix>
<signTag>true</signTag>
<tagNameFormat>v@{version}</tagNameFormat>
<!-- release:perform -->
<releaseProfiles>maven-central</releaseProfiles>
</configuration>
Expand Down
2 changes: 0 additions & 2 deletions release.sh

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mvn -Dtag=v1.0.0 -DreleaseVersion=1.0.0 -DdevelopmentVersion=1.0.1-SNAPSHOT release:prepare release:perform
git fetch
12 changes: 12 additions & 0 deletions scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

CURRENT_DIR=$(basename $PWD)

if [ "$CURRENT_DIR" = "kraken-api-java" ]
then
VERSION=$(grep scm.tag= release.properties | awk -Fv '{print $2}')
echo Generating changelog for version $VERSION

git cliff -o CHANGELOG.md --tag $VERSION
git add CHANGELOG.md
fi

0 comments on commit 1a46fd6

Please sign in to comment.