Skip to content

Commit 4184174

Browse files
committed
docs: improve scm tutorial
1 parent d914b4d commit 4184174

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

docs/tutorials/release-scm.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Releasing with the SCM Version Provider
22

3+
In this tutorial, you will learn how to bump the version using the `scp` version provider; as you can't use `cz bump`.
4+
35
## About
46

57
When `version_provider` is set to `scm`, Commitizen reads the version directly from your Git tags instead of a config file.
@@ -11,34 +13,26 @@ tag_format = "v${version}"
1113
version_provider = "scm"
1214
```
1315

14-
This means `cz bump` cannot complete its usual job of writing the new version anywhere (see [Why can't I bump with SCM?](#why-cant-i-bump-with-scm) below).
16+
This means `cz bump` cannot complete its usual job of writing the new version anywhere (see [Why can't I bump with SCM?](#why-cant-i-bump-with-scm) below). In the next section, you will learn how to do it anyways.
1517

1618
## Creating a New Version Tag Manually
1719

18-
To release a new version without an extra commit, compute the next tag yourself and create it directly:
20+
To release a new version without an extra commit and using tags,
21+
you can compute the next tag using `cz version` and then, you can manually create the tag directly.
22+
23+
In this example, we create an annotated tag with the changelog as the tag message, using just `git`.
1924

2025
```sh
2126
next_version=$(cz version --project --next --tag)
22-
git tag --annotate "$next_version" --message "$next_version"
27+
cz changelog --incremental --dry-run --unreleased-version "$next_version" > .changelog.md
28+
git tag --annotate "$next_version" -F .changelog.md
2329
git push --follow-tags
2430
```
2531

2632
!!! tip
2733
Wrap this in a CI job to fully automate releases when using the `scm` provider using [setup-cz](https://github.com/commitizen-tools/setup-cz)
2834

29-
## Why Can't I Bump with SCM?
30-
31-
When you run `cz bump`, Commitizen normally creates a new commit that updates the version somewhere,
32-
either in `.cz.toml`, or in `pyproject.toml` if you're using Python, or `Cargo.toml` for rust.
33-
It may also update `version_files` and regenerate `CHANGELOG.md`.
34-
35-
Commitizen deliberately bundles a new release into a single commit.
36-
This is core to its philosophy: the version should live in the code itself, not only in a Git tag,
37-
so anyone can read the current version straight from the source, without needing to inspect the tags.
38-
When a Git tag is the sole source of truth, that guarantee disappears,
39-
the version becomes metadata layered on top of your history instead of something visible within the code itself.
40-
41-
## Github action example
35+
## GitHub Action Example
4236

4337
```yaml title=".github/workflows/bump-version.yml"
4438
name: Bump version
@@ -66,6 +60,23 @@ jobs:
6660
- id: bump-version
6761
run: |
6862
next_version=$(cz version --project --next --tag)
69-
git tag --annotate "$next_version" --message "$next_version"
63+
cz changelog --incremental --dry-run --unreleased-version "$next_version" > .changelog.md
64+
git tag --annotate "$next_version" -F .changelog.md
7065
git push --follow-tags
7166
```
67+
68+
## Why Can't I Bump with SCM?
69+
70+
When you run `cz bump`, Commitizen normally creates a new commit that updates the version somewhere,
71+
either in `.cz.toml`, or in `pyproject.toml` if you're using Python, or `Cargo.toml` for rust.
72+
It may also update `version_files` and regenerate `CHANGELOG.md`.
73+
74+
Commitizen deliberately bundles a new release into a single "release commit".
75+
76+
This is core to its philosophy: the version should live in the code itself, not only in a Git tag,
77+
so anyone can read the current version straight from the source, without needing to inspect the tags.
78+
79+
When a Git tag is the sole source of truth, that guarantee disappears,
80+
the version becomes metadata layered on top of your history instead of something visible within the code itself.
81+
82+
Nonetheless, you can still do it.

0 commit comments

Comments
 (0)