Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
ref: "${{ github.event.pull_request.head.ref }}"
repository: "${{ github.event.pull_request.head.repo.full_name }}"
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
- name: Capture commit id
id: capture
run: |
Expand All @@ -28,15 +28,25 @@ jobs:
git commit -m "feat: test feature"
- name: test action
uses: ./
id: cz
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
commit: false
push: false
- uses: actions/checkout@v2
- name: check outputs
run: |
echo "version: ${{ steps.cz.outputs.version }}"
echo "next_version: ${{ steps.cz.outputs.next_version }}"
echo "next_version_major: ${{ steps.cz.outputs.next_version_major }}"
echo "next_version_minor: ${{ steps.cz.outputs.next_version_minor }}"
echo "previous_version: ${{ steps.cz.outputs.previous_version }}"
echo "previous_version_major: ${{ steps.cz.outputs.previous_version_major }}"
echo "previous_version_minor: ${{ steps.cz.outputs.previous_version_minor }}"
- uses: actions/checkout@v5
with:
ref: "${{ github.event.pull_request.head.ref }}"
repository: "${{ github.event.pull_request.head.repo.full_name }}"
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
path: new_head
- name: Test push
run: |
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
fetch-depth: 0
token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
| `push` | Define if the changes should be pushed to the branch. | true |
| `merge` | Define if the changes should be pushed even on the pull_request event, immediately merging the pull request. | false |
| `commit` | Define if the changes should be committed to the branch. | true |
| `commitizen_version` | Specify the version to be used by commitizen. Eg: `2.21. | latest |
| `commitizen_version` | Specify the version to be used by commitizen. Eg: `4.10.0` | latest |
| `changelog` | Create changelog when bumping the version | true |
| `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/) |
| `increment` | Manually specify the desired increment {MAJOR,MINOR, PATCH} | - |
Expand All @@ -90,9 +90,15 @@ jobs:

## Outputs

| Name | Description |
| --------- | --------------- |
| `version` | The new version |
| Name | Description |
| ------------------------ | ----------------------------------------------------------------------- |
| `version` | The next version (same as `next_version`, kept for historical purposes) |
| `next_version` | Next version |
| `next_version_major` | Only the major version of the next version |
| `next_version_minor` | Only the minor version of the next version |
| `previous_version` | Version before the bump |
| `previous_version_major` | Only the major version of the previous version |
| `previous_version_minor` | Only the minor version of the previous version |

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

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

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

Alternatively, you can try using the `gh` cli in your github action:

```sh
gh workflow run <workflow.yaml> ...
```

## I'm not using conventional commits, I'm using my own set of rules on commits

If your rules can be parsed, then you can build your own commitizen rules,
Expand Down
14 changes: 13 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ branding:
icon: "git-commit"
color: "purple"
outputs:
version:
version: # old classic next_version
description: "New version"
next_version:
description: "Next version"
next_version_major:
description: "Only the major version of the next version"
next_version_minor:
description: "Only the minor version of the next version"
previous_version:
description: "Version before the bump"
previous_version_major:
description: "Only the major version of the previous version"
previous_version_minor:
description: "Only the minor version of the previous version"
inputs:
working_directory:
description: "Change to this directory before running"
Expand Down
17 changes: 17 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ fi

PREV_REV="$(cz version --project)"
echo "PREVIOUS_REVISION=${PREV_REV}" >>"$GITHUB_ENV"
echo "previous_version=${PREV_REV}" >>"$GITHUB_OUTPUT"

PREV_REV_MAJOR="$(cz version --project --major)"
echo "PREVIOUS_REVISION_MAJOR=${PREV_REV_MAJOR}" >>"$GITHUB_ENV"
echo "previous_version_major=${PREV_REV_MAJOR}" >>"$GITHUB_OUTPUT"
PREV_REV_MINOR="$(cz version --project --minor)"
echo "PREVIOUS_REVISION_MINOR=${PREV_REV_MINOR}" >>"$GITHUB_ENV"
echo "previous_version_minor=${PREV_REV_MINOR}" >>"$GITHUB_OUTPUT"


CZ_CMD=('cz')
if [[ $INPUT_DEBUG == 'true' ]]; then
Expand Down Expand Up @@ -102,6 +111,14 @@ if [[ $REV == "$PREV_REV" ]]; then
fi
echo "REVISION=${REV}" >>"$GITHUB_ENV"
echo "version=${REV}" >>"$GITHUB_OUTPUT"
echo "next_version=${REV}" >>"$GITHUB_OUTPUT"

NEXT_REV_MAJOR="$(cz version --project --major)"
echo "NEXT_REVISION_MAJOR=${NEXT_REV_MAJOR}" >>"$GITHUB_ENV"
echo "next_version_major=${REV}" >>"$GITHUB_OUTPUT"
NEXT_REV_MINOR="$(cz version --project --minor)"
echo "NEXT_REVISION_MINOR=${NEXT_REV_MINOR}" >>"$GITHUB_ENV"
echo "next_version_minor=${REV}" >>"$GITHUB_OUTPUT"

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