Skip to content

Commit f90dada

Browse files
committed
feat: introduce github action
1 parent bc483cd commit f90dada

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed

.cz.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.commitizen]
2+
name = "cz_conventional_commits"
3+
version = "0.0.1"
4+
tag_format = "v$major"

.github/workflows/bumpversion.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Bump version
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
bump_version:
10+
runs-on: ubuntu-latest
11+
name: 'Bump version and create changelog with commitizen'
12+
steps:
13+
- name: Check out
14+
uses: actions/checkout@v2
15+
- name: Create bump and changelog
16+
uses: Woile/commitizen-action@master
17+
with:
18+
dry_run: false
19+
- name: Push changes back to master
20+
uses: ad-m/github-push-action@master
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM python:3.8
2+
COPY entrypoint.sh /entrypoint.sh
3+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
11
# commitizen-action
2+
23
Commitizen github action to bump and create changelog
4+
5+
## Usage
6+
7+
1. In your local repo remember to create a `.cz.toml` file (run `cz init` to create it)
8+
2. Create a `.github/workflows/bumpversion.yaml` with the Sample Workflow
9+
10+
## Sample Workflow
11+
12+
```yaml
13+
name: Bump version
14+
15+
on:
16+
push:
17+
branches:
18+
- master
19+
20+
jobs:
21+
bump_version:
22+
runs-on: ubuntu-latest
23+
name: 'Bump version and create changelog with commitizen'
24+
steps:
25+
- name: Check out
26+
uses: actions/checkout@v2
27+
- name: Create bump and changelog
28+
uses: Woile/commitizen-action@master
29+
with:
30+
dry_run: false
31+
- name: Push changes back to master
32+
uses: ad-m/github-push-action@master
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
```
37+
38+
## Variables
39+
40+
| Name | Description | Default |
41+
| ----------- | --------------------------------------------- | ------- |
42+
| `dry_run` | Run without creating commit, output to stdout | false |
43+
| `changelog` | Create changelog when bumping the version | true |
44+
45+
## Contributing
46+
47+
Whenever we want to release a new version, we have to mark it as breaking change.
48+
The `.cz.toml` configuration is using `$major` to format the tag, this means that
49+
it's the only kind of release allowed, so, mark as breaking change.

action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Bump and changelog using commitizen'
2+
description: 'Create a commit bumping the version of your project and creating a changelog file'
3+
runs:
4+
using: 'docker'
5+
image: 'Dockerfile'
6+
branding:
7+
icon: 'git-commit'
8+
color: 'purple'
9+
inputs:
10+
dry_run:
11+
description: 'Run without creating commit, output to stdout'
12+
default: "false"
13+
required: false
14+
changelog:
15+
description: 'Create changelog when bumping the version'
16+
default: "true"
17+
required: false

entrypoint.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
: "${INPUT_DRY_RUN:=false}"
4+
# : "${INPUT_CHANGELOG:=true}" ignroed for now, let's check that it works
5+
6+
set -e
7+
8+
echo "Repository: $GITHUB_REPOSITORY"
9+
echo "Actor: $GITHUB_ACTOR"
10+
11+
echo "Installing requirements..."
12+
13+
if [[ -f "requirements.txt" ]]; then
14+
# Ensure commitizen + reqs may have custom commitizen plugins
15+
pip install -r requirements.txt commitizen
16+
else
17+
pip install commitizen
18+
fi
19+
20+
echo "Runnung cz..."
21+
if ! $INPUT_DRY_RUN; then
22+
cz bump --changelog
23+
else
24+
cz bump --changelog --dry-run
25+
fi
26+
27+
echo "Done."

0 commit comments

Comments
 (0)