Skip to content

Commit

Permalink
ci: use custom release-plz logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Mar 17, 2024
1 parent 64f19d7 commit bf4c151
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 31 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:
push:
branches:
- main
- release-plz

concurrency:
group: release-plz-${{ github.ref }}
group: release-plz

jobs:
release-plz:
Expand All @@ -20,7 +21,18 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: test
save-if: false
- uses: jdx/mise-action@v2
with:
experimental: true
- run: mise trust --all
- run: mise run release-plz
env:
GITHUB_TOKEN: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: MarcoIeni/release-plz-action@v0.5
env:
GITHUB_TOKEN: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
shared-key: test
save-if: ${{ github.ref_name == 'main' }}
- uses: jdx/mise-action@v2
- run: mise r build
Expand Down
7 changes: 4 additions & 3 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
CARGO_TERM_COLOR = 'always'
_.path = ["./target/debug"]

[tools]
"npm:prettier" = "latest"
"cargo:cargo-edit" = "latest"

[tasks.build]
sources = ['{cli/,}src/**/*.rs', '{cli/,}Cargo.toml']
outputs = ['target/debug/rtx']
Expand Down Expand Up @@ -74,6 +78,3 @@ run = [

[tasks.release]
run = "cargo release --workspace"

[tools]
"npm:prettier" = "latest"
29 changes: 29 additions & 0 deletions .mise/tasks/release-plz
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euxo pipefail

released_versions="$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$')"
cur_version="$(cargo pkgid usage-lib | cut -d# -f2)"
if ! echo "$released_versions" | grep -q "^$cur_version$"; then
echo "Releasing $cur_version"
cargo publish -p usage-lib
cargo publish -p usage-cli
fi

version="$(git cliff --bumped-version)"
changelog="$(git cliff --bump --unreleased --strip all)"

git cliff --bump -o CHANGELOG.md
cargo set-version "${version#v}"

git config user.name mise-en-dev
git config user.email 123107610+mise-en-dev@users.noreply.github.com
cargo update
git add \
Cargo.lock \
Cargo.toml \
CHANGELOG.md
git checkout -B release
git commit -m "Release $version"
git push origin release --force
gh pr create --title "Release $version" --body "$changelog" --label "release" ||
gh pr edit --title "Release $version" --body "$changelog"
39 changes: 29 additions & 10 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,32 @@ 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 = """
---
{% 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 | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
- **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.github.username | default(value=commit.author.name) }}
{%- endfor -%}
{% raw %}\n{% endraw %}\
{%- for commit in commits %}
{%- if commit.scope -%}
{% else -%}
- {% if commit.breaking %} [**breaking**]{% endif %}\
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.github.username | default(value=commit.author.name) }}
{% endif -%}
{% endfor -%}
{% endfor %}\n
"""
# template for the changelog footer
Expand All @@ -34,9 +48,8 @@ footer = """
"""
# remove the leading and trailing s
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
{ pattern = '\$REPO', replace = "https://github.com/jdx/mise" },
]

[git]
Expand All @@ -57,6 +70,7 @@ commit_preprocessors = [
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix\\(deps\\)", skip = true },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
Expand All @@ -67,6 +81,7 @@ commit_parsers = [
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore: Release", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
Expand All @@ -76,9 +91,9 @@ protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# regex for matching git tags
tag_pattern = "^v[0-9].[0-9].[0-9]$"
tag_pattern = 'v\d+\.\d+\.\d+'
# regex for skipping tags
skip_tags = "^(v0.1.9|v0.1.8|v0.1.7|v0.1.6|v0.1.5|v0.1.4|v0.1.3|v0.1.2)$"
skip_tags = '^v(1|2023)\.'
# regex for ignoring tags
# ignore_tags = ""
# sort the tags topologically
Expand All @@ -87,3 +102,7 @@ topo_order = false
sort_commits = "oldest"
# limit the number of commits included in the changelog.
# limit_commits = 42

[remote.github]
owner = "jdx"
repo = "usage"
16 changes: 0 additions & 16 deletions release-plz.toml

This file was deleted.

0 comments on commit bf4c151

Please sign in to comment.