Skip to content

Commit c498691

Browse files
Merge pull request #6 from coding-kelps/release-workflow
ci(release): automated release creation
2 parents d27a252 + ba2eb64 commit c498691

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed

.github/workflows/release.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
permissions:
10+
contents: write
11+
issues: read
12+
pull-requests: read
13+
14+
jobs:
15+
ci:
16+
uses: ./.github/workflows/ci.yaml
17+
secrets: inherit
18+
19+
generate-changelog:
20+
name: Generate a changelog
21+
runs-on: ubuntu-latest
22+
needs:
23+
- ci
24+
outputs:
25+
release_body: ${{ steps.git-cliff.outputs.content }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- name: Generate a changelog
31+
uses: orhun/git-cliff-action@v4
32+
id: git-cliff
33+
with:
34+
config: cliff.toml
35+
args: -vv --latest --strip header
36+
env:
37+
OUTPUT: CHANGES.md
38+
GITHUB_REPO: ${{ github.repository }}
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
build-publish:
42+
name: Build and Publish release
43+
needs:
44+
- generate-changelog
45+
runs-on: ${{ matrix.build.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
build:
50+
- name: linux-x64-glibc
51+
os: ubuntu-latest
52+
target: x86_64-unknown-linux-gnu
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Cache
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/.cargo/registry
60+
~/.cargo/git
61+
target
62+
key: ${{ matrix.build.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
63+
- name: Build binary
64+
run: cargo build --release --locked --target ${{ matrix.build.target }}
65+
- name: Set the release version
66+
shell: bash
67+
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
68+
- name: Prepare release assets
69+
run: |
70+
mkdir -p release/
71+
cp {LICENSE,README.md,CHANGELOG.md} release/
72+
cp "target/${{ matrix.build.target }}/release/leetcode-cli" release/
73+
mv release/ leetcode-cli-${{ env.RELEASE_VERSION }}/
74+
- name: Create
75+
shell: bash
76+
run: |
77+
tar -czvf leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz \
78+
leetcode-cli-${{ env.RELEASE_VERSION }}/
79+
shasum -a 512 leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz \
80+
> leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}.tar.gz.sha512
81+
- name: Upload the binary releases
82+
id: upload-release
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
files: |
86+
leetcode-cli-${{ env.RELEASE_VERSION }}-${{ matrix.build.target }}*
87+
body: ${{ needs.generate-changelog.outputs.release_body }}
88+
draft: false
89+
prerelease: false

CHANGELOG.md

Whitespace-only changes.

cliff.toml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
[remote.github]
2+
owner = "coding-kelps"
3+
repo = "leetcode-cli"
4+
5+
[changelog]
6+
header = """
7+
# Changelog
8+
9+
All notable changes to this project will be documented in this file.
10+
11+
"""
12+
body = """
13+
{%- macro remote_url() -%}
14+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
15+
{%- endmacro -%}
16+
17+
{% macro print_commit(commit) -%}
18+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
19+
{% if commit.breaking %}[**breaking**] {% endif %}\
20+
{{ commit.message | upper_first }} - \
21+
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
22+
{% endmacro -%}
23+
24+
{% if version %}\
25+
{% if previous.version %}\
26+
## [{{ version | trim_start_matches(pat="v") }}]\
27+
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
28+
{% else %}\
29+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
30+
{% endif %}\
31+
{% else %}\
32+
## [unreleased]
33+
{% endif %}\
34+
35+
{% for group, commits in commits | group_by(attribute="group") %}
36+
### {{ group | striptags | trim | upper_first }}
37+
{% for commit in commits
38+
| filter(attribute="scope")
39+
| sort(attribute="scope") %}
40+
{{ self::print_commit(commit=commit) }}
41+
{%- endfor %}
42+
{% for commit in commits %}
43+
{%- if not commit.scope -%}
44+
{{ self::print_commit(commit=commit) }}
45+
{% endif -%}
46+
{% endfor -%}
47+
{% endfor -%}
48+
{%- if github -%}
49+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
50+
## New Contributors ❤️
51+
{% endif %}\
52+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
53+
* @{{ contributor.username }} made their first contribution
54+
{%- if contributor.pr_number %} in \
55+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
56+
{%- endif %}
57+
{%- endfor -%}
58+
{%- endif %}
59+
60+
61+
"""
62+
63+
footer = """
64+
<!-- generated by git-cliff -->
65+
"""
66+
trim = true
67+
68+
[contributors]
69+
# drop any contributor whose username matches one of these literals or regexes
70+
ignore = [
71+
"github-actions\\[bot\\]"
72+
]
73+
74+
[git]
75+
conventional_commits = true
76+
filter_unconventional = true
77+
split_commits = false
78+
79+
commit_parsers = [
80+
{ field = "author.email", pattern = "github-actions\\[bot\\]@users.noreply.github.com", skip = true},
81+
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" },
82+
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
83+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
84+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
85+
{ message = "^refactor\\(clippy\\)", skip = true },
86+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
87+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
88+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
89+
{ message = "^build", group = "<!-- 7 -->🔨 Build" },
90+
{ message = "^ci", group = "<!-- 8 -->⚙️ Miscellaneous Tasks" },
91+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
92+
]
93+
protect_breaking_commits = false
94+
filter_commits = false
95+
tag_pattern = "v[0-9].*"
96+
skip_tags = "beta|alpha"
97+
ignore_tags = "rc"
98+
topo_order = false
99+
sort_commits = "newest"

0 commit comments

Comments
 (0)