Skip to content

Commit 083bb24

Browse files
committed
feat: add more output information
BREAKING CHANGE: This update requires commitizen > 4.10 in order to use --minor and --major
1 parent 5b0848c commit 083bb24

File tree

4 files changed

+61
-10
lines changed

4 files changed

+61
-10
lines changed

.github/workflows/test_action.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
test:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v5
1212
with:
1313
ref: "${{ github.event.pull_request.head.ref }}"
1414
repository: "${{ github.event.pull_request.head.repo.full_name }}"
15-
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
15+
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
1616
- name: Capture commit id
1717
id: capture
1818
run: |
@@ -28,15 +28,25 @@ jobs:
2828
git commit -m "feat: test feature"
2929
- name: test action
3030
uses: ./
31+
id: cz
3132
with:
3233
github_token: "${{ secrets.GITHUB_TOKEN }}"
3334
commit: false
3435
push: false
35-
- uses: actions/checkout@v2
36+
- name: check outputs
37+
run: |
38+
echo "version: ${{ steps.cz.outputs.version }}"
39+
echo "next_version: ${{ steps.cz.outputs.next_version }}"
40+
echo "next_version_major: ${{ steps.cz.outputs.next_version_major }}"
41+
echo "next_version_minor: ${{ steps.cz.outputs.next_version_minor }}"
42+
echo "previous_version: ${{ steps.cz.outputs.previous_version }}"
43+
echo "previous_version_major: ${{ steps.cz.outputs.previous_version_major }}"
44+
echo "previous_version_minor: ${{ steps.cz.outputs.previous_version_minor }}"
45+
- uses: actions/checkout@v5
3646
with:
3747
ref: "${{ github.event.pull_request.head.ref }}"
3848
repository: "${{ github.event.pull_request.head.repo.full_name }}"
39-
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
49+
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
4050
path: new_head
4151
- name: Test push
4252
run: |

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
name: "Bump version and create changelog with commitizen"
5050
steps:
5151
- name: Check out
52-
uses: actions/checkout@v3
52+
uses: actions/checkout@v5
5353
with:
5454
fetch-depth: 0
5555
token: "${{ secrets.GITHUB_TOKEN }}"
@@ -80,7 +80,7 @@ jobs:
8080
| `push` | Define if the changes should be pushed to the branch. | true |
8181
| `merge` | Define if the changes should be pushed even on the pull_request event, immediately merging the pull request. | false |
8282
| `commit` | Define if the changes should be committed to the branch. | true |
83-
| `commitizen_version` | Specify the version to be used by commitizen. Eg: `2.21. | latest |
83+
| `commitizen_version` | Specify the version to be used by commitizen. Eg: `4.10.0` | latest |
8484
| `changelog` | Create changelog when bumping the version | true |
8585
| `no_raise` | Don't raise the given comma-delimited exit codes (e.g., no_raise: '20,21'). Use with caution! Open an issue in [commitizen](https://github.com/commitizen-tools/commitizen/issues) if you need help thinking about your workflow. | [21](https://commitizen-tools.github.io/commitizen/exit_codes/) |
8686
| `increment` | Manually specify the desired increment {MAJOR,MINOR, PATCH} | - |
@@ -90,9 +90,15 @@ jobs:
9090

9191
## Outputs
9292

93-
| Name | Description |
94-
| --------- | --------------- |
95-
| `version` | The new version |
93+
| Name | Description |
94+
| ------------------------ | ----------------------------------------------------------------------- |
95+
| `version` | The next version (same as `next_version`, kept for historical purposes) |
96+
| `next_version` | Next version |
97+
| `next_version_major` | Only the major version of the next version |
98+
| `next_version_minor` | Only the minor version of the next version |
99+
| `previous_version` | Version before the bump |
100+
| `previous_version_major` | Only the major version of the previous version |
101+
| `previous_version_minor` | Only the minor version of the previous version |
96102

97103
The new version is also available as an environment variable under `REVISION` or you can access using `${{ steps.cz.outputs.version }}`
98104

@@ -176,6 +182,12 @@ To solve it, you must use a personal access token in the checkout and the commit
176182

177183
Follow the instructions in [commitizen's documentation][cz-docs-ga].
178184

185+
Alternatively, you can try using the `gh` cli in your github action:
186+
187+
```sh
188+
gh workflow run <workflow.yaml> ...
189+
```
190+
179191
## I'm not using conventional commits, I'm using my own set of rules on commits
180192

181193
If your rules can be parsed, then you can build your own commitizen rules,

action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,20 @@ branding:
77
icon: "git-commit"
88
color: "purple"
99
outputs:
10-
version:
10+
version: # old classic next_version
1111
description: "New version"
12+
next_version:
13+
description: "Next version"
14+
next_version_major:
15+
description: "Only the major version of the next version"
16+
next_version_minor:
17+
description: "Only the minor version of the next version"
18+
previous_version:
19+
description: "Version before the bump"
20+
previous_version_major:
21+
description: "Only the major version of the previous version"
22+
previous_version_minor:
23+
description: "Only the minor version of the previous version"
1224
inputs:
1325
working_directory:
1426
description: "Change to this directory before running"

entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ fi
4040

4141
PREV_REV="$(cz version --project)"
4242
echo "PREVIOUS_REVISION=${PREV_REV}" >>"$GITHUB_ENV"
43+
echo "previous_version=${PREV_REV}" >>"$GITHUB_OUTPUT"
44+
45+
PREV_REV_MAJOR="$(cz version --project --major)"
46+
echo "PREVIOUS_REVISION_MAJOR=${PREV_REV_MAJOR}" >>"$GITHUB_ENV"
47+
echo "previous_version_major=${PREV_REV_MAJOR}" >>"$GITHUB_OUTPUT"
48+
PREV_REV_MINOR="$(cz version --project --minor)"
49+
echo "PREVIOUS_REVISION_MINOR=${PREV_REV_MINOR}" >>"$GITHUB_ENV"
50+
echo "previous_version_minor=${PREV_REV_MINOR}" >>"$GITHUB_OUTPUT"
51+
4352

4453
CZ_CMD=('cz')
4554
if [[ $INPUT_DEBUG == 'true' ]]; then
@@ -102,6 +111,14 @@ if [[ $REV == "$PREV_REV" ]]; then
102111
fi
103112
echo "REVISION=${REV}" >>"$GITHUB_ENV"
104113
echo "version=${REV}" >>"$GITHUB_OUTPUT"
114+
echo "next_version=${REV}" >>"$GITHUB_OUTPUT"
115+
116+
NEXT_REV_MAJOR="$(cz version --project --major)"
117+
echo "NEXT_REVISION_MAJOR=${NEXT_REV_MAJOR}" >>"$GITHUB_ENV"
118+
echo "next_version_major=${REV}" >>"$GITHUB_OUTPUT"
119+
NEXT_REV_MINOR="$(cz version --project --minor)"
120+
echo "NEXT_REVISION_MINOR=${NEXT_REV_MINOR}" >>"$GITHUB_ENV"
121+
echo "next_version_minor=${REV}" >>"$GITHUB_OUTPUT"
105122

106123
GITHUB_DOMAIN=${GITHUB_SERVER_URL#*//}
107124
CURRENT_BRANCH="$(git branch --show-current)"

0 commit comments

Comments
 (0)