Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
name: Release

on:
push:
tags:
- "v*.*.*"

permissions:
contents: write
issues: read
pull-requests: read

jobs:
ci:
uses: ./.github/workflows/ci.yaml
secrets: inherit

generate-changelog:
name: Generate a changelog
runs-on: ubuntu-latest
needs:
- ci
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-publish:
name: Build and Publish release
needs:
- generate-changelog
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- name: linux-x64-glibc
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.build.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build binary
run: cargo build --release --locked --target ${{ matrix.build.target }}
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Prepare release assets
run: |
mkdir -p release/
cp {LICENSE,README.md,CHANGELOG.md} release/
cp "target/${{ matrix.build.target }}/release/leetcode-cli" release/
mv release/ leetcode-cli-${{ env.RELEASE_VERSION }}/
- name: Create
shell: bash
run: |
tar -czvf leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz \
leetcode-cli-${{ env.RELEASE_VERSION }}/
shasum -a 512 leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz \
> leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz.sha512
- name: Upload the binary releases
id: upload-release
uses: softprops/action-gh-release@v2
with:
files: |
leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}*
body: ${{ needs.generate-changelog.outputs.release_body }}
draft: false
prerelease: false
Empty file added CHANGELOG.md
Empty file.
99 changes: 99 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[remote.github]
owner = "coding-kelps"
repo = "leetcode-cli"

[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.
"""
body = """
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
{% macro print_commit(commit) -%}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }} - \
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
{% endmacro -%}
{% if version %}\
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}]\
({{ self::remote_url() }}/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 | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
{{ self::print_commit(commit=commit) }}
{%- endfor %}
{% for commit in commits %}
{%- if not commit.scope -%}
{{ self::print_commit(commit=commit) }}
{% endif -%}
{% endfor -%}
{% endfor -%}
{%- if github -%}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
## New Contributors ❤️
{% endif %}\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
* @{{ contributor.username }} made their first contribution
{%- if contributor.pr_number %} in \
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endfor -%}
{%- endif %}
"""

footer = """
<!-- generated by git-cliff -->
"""
trim = true

[contributors]
# drop any contributor whose username matches one of these literals or regexes
ignore = [
"github-actions\\[bot\\]"
]

[git]
conventional_commits = true
filter_unconventional = true
split_commits = false

commit_parsers = [
{ field = "author.email", pattern = "github-actions\\[bot\\]@users.noreply.github.com", skip = true},
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor\\(clippy\\)", skip = true },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^build", group = "<!-- 7 -->🔨 Build" },
{ message = "^ci", group = "<!-- 8 -->⚙️ Miscellaneous Tasks" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
]
protect_breaking_commits = false
filter_commits = false
tag_pattern = "v[0-9].*"
skip_tags = "beta|alpha"
ignore_tags = "rc"
topo_order = false
sort_commits = "newest"