From e4b8ae8900fab7d3b33ef9573bb3f0832843daa5 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Mon, 23 Mar 2026 13:36:45 +0100 Subject: [PATCH] chore(release): prepare 1.0.0 release --- .github/workflows/release.yml | 86 +++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 68 ++++++++++++++++++++++++++- cliff.toml | 71 ----------------------------- justfile | 39 +++++++++++++++- nix/shell.nix | 3 ++ src/commit/types/message.rs | 2 +- 7 files changed, 195 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 cliff.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7a91df8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Run Checks + run: nix develop --no-pure-eval --command just check-all + + release: + needs: checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.CI_TOKEN }} + + - name: Install Nix + uses: cachix/install-nix-action@v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Check for releasable commits + id: releasable + run: | + COUNT=$(nix develop --no-pure-eval --command just cliff-count) + echo "count=$COUNT" >> $GITHUB_OUTPUT + + - name: Determine next version + if: steps.releasable.outputs.count > 0 + id: next_version + run: | + CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --command just cliff-next-version) + echo "version=$CLIFF_NEXT_VERSION" >> $GITHUB_OUTPUT + + - name: Update changelog + if: steps.releasable.outputs.count > 0 + run: nix develop --no-pure-eval --command just cliff-bump + + - name: Create release commit + if: steps.releasable.outputs.count > 0 + run: | + VERSION=${{ steps.next_version.outputs.version }} + nix develop --no-pure-eval --command just commit-release "$VERSION" + + - name: Create version tag + if: steps.releasable.outputs.count > 0 + run: | + VERSION=${{ steps.next_version.outputs.version }} + nix develop --no-pure-eval --command just create-release-tag "$VERSION" + + - name: Build Linux release binaries + if: steps.releasable.outputs.count > 0 + run: nix build + + - name: Build Windows release binaries + if: steps.releasable.outputs.count > 0 + run: nix build .#windows + + - name: Publish on crates.io + if: steps.releasable.outputs.count > 0 + run: nix develop --no-pure-eval --accept-flake-config --command cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - name: Rebase develop onto main + if: steps.releasable.outputs.count > 0 + run: nix develop --no-pure-eval --command just rebase-develop + + - name: Bump to next dev version + if: steps.releasable.outputs.count > 0 + run: | + VERSION=${{ steps.next_version.outputs.version }} + nix develop --no-pure-eval --command just update-develop-version "$VERSION" diff --git a/Cargo.lock b/Cargo.lock index 367c7a2..59f60db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1650,7 +1650,7 @@ dependencies = [ [[package]] name = "jj-cz" -version = "0.1.0" +version = "1.0.0-dev" dependencies = [ "assert_cmd", "assert_fs", diff --git a/Cargo.toml b/Cargo.toml index 261f33e..1310f0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "jj-cz" -version = "0.1.0" +version = "1.0.0-dev" +description = "Conventional commits for Jujutsu" edition = "2024" -publish = false +publish = true authors = ["Lucien Cartier-Tilet "] license = "MIT OR GPL-3.0-or-later" homepage = "https://labs.phundrak.com/phundrak/jj-cz" @@ -47,3 +48,66 @@ lto = true codegen-units = 1 panic = "abort" strip = true + +[package.metadata.git-cliff.changelog] +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% 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 %} +{% endfor %} +""" +trim = true +render_always = true +postprocessors = [ + { pattern = '', replace = "https://labs.phundrak.com/phundrak/jj-cz" }, +] + +[package.metadata.git-cliff.bump] +features_always_bump_minor = true +breaking_always_bump_major = true +initial_tag = "1.0.0" + +[package.metadata.git-cliff.git] +conventional_commits = true +filter_unconventional = true +require_conventional = false +split_commits = false +commit_preprocessors = [ + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + { pattern = '.*', replace_command = 'typos --write-changes -' }, +] +protect_breaking_commits = false +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\\):", 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" }, + { message = ".*", group = "Other" }, +] +filter_commits = false +fail_on_unmatched_commit = false +link_parsers = [] +use_branch_tags = false +topo_order = false +topo_order_commits = true +sort_commits = "oldest" +recurse_submodules = false diff --git a/cliff.toml b/cliff.toml deleted file mode 100644 index 65de6c4..0000000 --- a/cliff.toml +++ /dev/null @@ -1,71 +0,0 @@ -# configuration file for git-cliff -# see https://github.com/orhun/git-cliff#configuration-file - -[changelog] -# changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file.\n -""" -# template for the changelog body -# https://tera.netlify.app/docs/#introduction -body = """ -{% if version %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | upper_first }} - {% for commit in commits %} - - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ - {% endfor %} -{% endfor %}\n -""" -# remove the leading and trailing whitespace from the template -trim = true -# changelog footer -footer = """ - -""" - -[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 = [ - # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers -] -# 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", group = "Miscellaneous Tasks"}, - { body = ".*security", group = "Security"}, -] -# protect breaking changes from being skipped due to matching a skipping commit_parser -protect_breaking_commits = false -# filter out the commits that are not matched by commit parsers -filter_commits = false -# glob pattern for matching git tags -tag_pattern = "v[0-9]*" -# regex for skipping tags -skip_tags = "v0.1.0-beta.1" -# regex for ignoring tags -ignore_tags = "" -# sort the tags topologically -topo_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" -# limit the number of commits included in the changelog. -# limit_commits = 42 diff --git a/justfile b/justfile index 60fafbd..5c4d4e9 100644 --- a/justfile +++ b/justfile @@ -30,6 +30,9 @@ lint-report: test: cargo test --features test-utils +fast-test: + cargo nextest run --all --all-features + coverage: mkdir -p coverage cargo tarpaulin --config .tarpaulin.local.toml --features test-utils @@ -38,7 +41,41 @@ coverage-ci: mkdir -p coverage cargo tarpaulin --config .tarpaulin.ci.toml --features test-utils -check-all: format-check lint coverage audit +check-all: format-check lint fast-test audit + +cliff-count: + git-cliff --unreleased | tail -n +3 | wc -l + +cliff-next-version: + git-cliff --bumped-version + +cliff-bump: + git-cliff --bump -o CHANGELOG.md + +commit-release version: + cargo set-version "{{version}}" + git config user.name "CI Bot" + git config user.email "ci@phundrak.com" + git add Cargo.toml Cargo.lock CHANGELOG.md + git commit -m "chore(release): release {{version}} [skip ci]" + git push origin main + +create-release-tag version: + git tag "{{version}}" + git push origin "{{version}}" + +rebase-develop: + git fetch origin + git checkout develop + git rebase origin/main + +update-develop-version version: + #!/usr/bin/env bash + NEXT_DEV=$(echo "{{version}}" | awk -F. '{print $1"."$2"."$3+1}')"-dev" + cargo set-version "$NEXT_DEV" + git add Cargo.toml Cargo.lock + git commit -m "chore(release): bump version to $NEXT_DEV [skip ci]" + git push origin develop ## Local Variables: ## mode: makefile diff --git a/nix/shell.nix b/nix/shell.nix index 1dee101..ed5ddbd 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -19,9 +19,12 @@ inputs.devenv.lib.mkShell { }) bacon cargo-deny + cargo-edit cargo-nextest cargo-tarpaulin + git-cliff just + typos ]; } ]; diff --git a/src/commit/types/message.rs b/src/commit/types/message.rs index 4d9f52a..b9dc058 100644 --- a/src/commit/types/message.rs +++ b/src/commit/types/message.rs @@ -81,7 +81,7 @@ impl ConventionalCommit { + self.description.len() } - /// Format the complete commit messsage + /// Format the complete commit message /// /// Returns `type(scope): description` if scope is non-empty, or /// `type: description` if scope is empty