From 13ceed0b43c98fa10ea9a84c1db1f27f3574ba3c Mon Sep 17 00:00:00 2001 From: iHsin Date: Sat, 7 Sep 2024 13:10:18 +0800 Subject: [PATCH] ci: use git-cliff action (#582) --- .github/workflows/ci.yml | 48 +++++++++++++++++++----- Cargo.lock | 12 +++--- cliff.toml | 79 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 cliff.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 575f7c89..1ea11a44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: [ "master" ] concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha || github.ref }} cancel-in-progress: true env: @@ -251,8 +251,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true - + fetch-depth: 0 + fetch-tags: true - name: Merge binaries uses: actions/upload-artifact/merge@v4 with: @@ -266,26 +266,54 @@ jobs: name: binaries path: ./packages + - name: Delete previous latest tag + run: | + git tag -d latest || true + git push origin :refs/tags/latest || true + gh release list | grep Draft | awk '{print $1 " \t"}' | while read -r line; do gh release delete -y "$line"; done + env: + GH_TOKEN: ${{ github.token }} + + - name: Create new latest tag + if: startsWith(github.ref, 'refs/heads/master') + run: | + git tag latest + git push origin latest + + + - name: Generate a changelog + uses: orhun/git-cliff-action@main + id: git-cliff + with: + config: cliff.toml + args: --latest --strip header + env: + GITHUB_REPO: ${{ github.repository }} + - name: Github stable release - uses: "mathieucarbou/marvinpinto-action-automatic-releases@master" + uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/v') with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" + token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false + generate_release_notes: false + body: "${{ steps.git-cliff.outputs.content }}" files: | packages/* - LICENSE + LICENSE* - name: Github nightly release - uses: "mathieucarbou/marvinpinto-action-automatic-releases@master" + uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/heads/master') with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" + token: "${{ secrets.GITHUB_TOKEN }}" prerelease: true - automatic_release_tag: "latest" + tag_name: "latest" + generate_release_notes: false + body: "${{ steps.git-cliff.outputs.content }}" files: | packages/* - LICENSE + LICENSE* docker-image: needs: [ compile ] name: Docker Image diff --git a/Cargo.lock b/Cargo.lock index 95e5202b..de627a44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -736,9 +736,9 @@ checksum = "11aade7a05aa8c3a351cedc44c3fc45806430543382fcc4743a9b757a2a0b4ed" [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -4388,9 +4388,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", @@ -5257,9 +5257,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 00000000..779513e9 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,79 @@ +# git-cliff ~ default 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] +# template for the changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + {% if commit.github.pr_labels is containing("dependencies") %} + {% continue %} + {% endif %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ +{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} + * @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }} +{%- endfor -%} +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/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 -' }, +] +# 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" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +# filter out the commits that are not matched by commit parsers +filter_commits = false +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest"