Skip to content

Commit 97f245e

Browse files
committed
test of action in gh
1 parent 6ec1216 commit 97f245e

4 files changed

Lines changed: 142 additions & 56 deletions

File tree

.github/workflows/rust.yml

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
1-
name: Rust
1+
name: Release on Tag
22

33
on:
44
push:
5-
branches: [ "main" ]
6-
pull_request:
7-
branches: [ "main" ]
5+
tags: ['v*'] # run only when a tag like v1.2.3 is pushed
86

97
env:
108
CARGO_TERM_COLOR: always
119

1210
jobs:
13-
build:
14-
11+
release:
1512
runs-on: ubuntu-latest
16-
13+
permissions:
14+
contents: write # push commits + create releases
1715
steps:
18-
- uses: actions/checkout@v3
19-
- name: Build
20-
run: cargo build --verbose
21-
- name: Run tests
22-
run: cargo test --verbose
16+
# 1. Checkout the tag with full history for git-cliff
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
# 2. Generate/update changelog and commit it
23+
- name: Generate changelog
24+
uses: orhun/git-cliff-action@v4
25+
id: changelog
26+
with:
27+
config: cliff.toml # optional; falls back to defaults
28+
args: --unreleased --strip header
29+
env:
30+
output: CHANGELOG.md
31+
GITHUB_REPOSITORY: ${{ github.repository }}
32+
33+
- name: Commit updated changelog
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "github-actions[bot]@users.noreply.github.com"
37+
git add CHANGELOG.md
38+
git commit -m "chore: update changelog for ${{ github.ref_name }}"
39+
git push origin HEAD:main
40+
41+
# 3. Run Rust tests
42+
- name: Run tests
43+
run: cargo test --locked
44+
45+
# 4. Build release binary
46+
- name: Build release
47+
run: cargo build --release --locked
48+
49+
# 5. Create GitHub release with changelog body & binary asset
50+
- name: Create Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
tag_name: ${{ github.ref_name }}
54+
name: Release ${{ github.ref_name }}
55+
body: ${{ steps.changelog.outputs.content }}
56+
files: target/release/mostro-cli
57+
draft: false
58+
prerelease: false
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cliff.toml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
# [remote.github]
5+
# owner = "orhun"
6+
# repo = "git-cliff"
7+
# token = ""
8+
9+
[changelog]
10+
# A Tera template to be rendered for each release in the changelog.
11+
# See https://keats.github.io/tera/docs/#introduction
12+
body = """
13+
## What's Changed
14+
15+
{%- if version %} in {{ version }}{%- endif -%}
16+
{% for commit in commits %}
17+
{% if commit.remote.pr_title -%}
18+
{%- set commit_message = commit.remote.pr_title -%}
19+
{%- else -%}
20+
{%- set commit_message = commit.message -%}
21+
{%- endif -%}
22+
* {{ commit_message | split(pat="\n") | first | trim }}\
23+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
24+
{% if commit.remote.pr_number %} in \
25+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
26+
{%- endif %}
27+
{%- endfor -%}
28+
29+
{%- if github -%}
30+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
31+
{% raw %}\n{% endraw -%}
32+
## New Contributors
33+
{%- endif %}\
34+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
35+
* @{{ contributor.username }} made their first contribution
36+
{%- if contributor.pr_number %} in \
37+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
38+
{%- endif %}
39+
{%- endfor -%}
40+
{%- endif -%}
41+
42+
{% if version %}
43+
{% if previous.version %}
44+
**Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
45+
{% endif %}
46+
{% else -%}
47+
{% raw %}\n{% endraw %}
48+
{% endif %}
49+
50+
{%- macro remote_url() -%}
51+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
52+
{%- endmacro -%}
53+
"""
54+
# Remove leading and trailing whitespaces from the changelog's body.
55+
trim = true
56+
# A Tera template to be rendered as the changelog's footer.
57+
# See https://keats.github.io/tera/docs/#introduction
58+
footer = """
59+
<!-- generated by git-cliff -->
60+
"""
61+
# An array of regex based postprocessors to modify the changelog.
62+
# Replace the placeholder `<REPO>` with a URL.
63+
postprocessors = []
64+
65+
[git]
66+
# Parse commits according to the conventional commits specification.
67+
# See https://www.conventionalcommits.org
68+
conventional_commits = false
69+
# Exclude commits that do not match the conventional commits specification.
70+
filter_unconventional = true
71+
# Split commits on newlines, treating each line as an individual commit.
72+
split_commits = false
73+
# An array of regex based parsers to modify commit messages prior to further processing.
74+
commit_preprocessors = [{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }]
75+
# Exclude commits that are not matched by any commit parser.
76+
filter_commits = false
77+
# Order releases topologically instead of chronologically.
78+
topo_order = false
79+
# Order of commits in each group/release within the changelog.
80+
# Allowed values: newest, oldest
81+
sort_commits = "newest"

0 commit comments

Comments
 (0)