Adding upstream version 0.24.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
0b53ff4373
commit
fbd716708c
11 changed files with 955 additions and 0 deletions
6
.cz.toml
Normal file
6
.cz.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
version = "0.24.0"
|
||||
format = "v$version"
|
||||
update_changelog_on_bump = true
|
||||
major_version_zero = true
|
28
.github/workflows/bumpversion.yaml
vendored
Normal file
28
.github/workflows/bumpversion.yaml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
name: Bump version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
bump_version:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'Bump version and create changelog with commitizen'
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Create bump and changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
github_token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
|
||||
changelog_increment_filename: body.md
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body_path: "body.md"
|
||||
tag_name: "${{ env.REVISION }}"
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
|
57
.github/workflows/test_action.yml
vendored
Normal file
57
.github/workflows/test_action.yml
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
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
|
||||
- name: Capture commit id
|
||||
id: capture
|
||||
run: |
|
||||
COMMIT_ID="$(git rev-parse "${{ github.head_ref }}")"
|
||||
echo "The sha of the starting commit is $COMMIT_ID"
|
||||
echo "SHA=$COMMIT_ID" >>"$GITHUB_OUTPUT"
|
||||
- name: create test commit
|
||||
run: |
|
||||
touch test_file
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
git add test_file
|
||||
git commit -m "feat: test feature"
|
||||
- name: test action
|
||||
uses: ./
|
||||
with:
|
||||
github_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
commit: false
|
||||
push: false
|
||||
- uses: actions/checkout@v2
|
||||
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
|
||||
path: new_head
|
||||
- name: Test push
|
||||
run: |
|
||||
cd new_head
|
||||
last_pushed_commit="$(git rev-parse "${{ github.head_ref }}")"
|
||||
echo "Commit sha on origin: $last_pushed_commit"
|
||||
if [[ $last_pushed_commit != ${{ steps.capture.outputs.SHA }} ]]; then
|
||||
echo "Something got pushed to ${{ github.head_ref }}"
|
||||
exit 1
|
||||
fi
|
||||
- name: Test commit
|
||||
run: |
|
||||
commit_message="$(git log -1 HEAD --pretty=format:%s)"
|
||||
echo "Latest commit: $commit_message"
|
||||
if [[ $commit_message != "feat: test feature" ]]; then
|
||||
echo "The latest commit message is not 'feat: test feature'"
|
||||
exit 1
|
||||
fi
|
19
.github/workflows/update_semver.yml
vendored
Normal file
19
.github/workflows/update_semver.yml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
name: Update Major Minor Tags
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- "**"
|
||||
tags:
|
||||
- "*.*.*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update_major_minor_tags:
|
||||
name: Make sure major and minor tags are up to date on a patch release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Run Update semver
|
||||
uses: haya14busa/action-update-semver@v1
|
129
.gitignore
vendored
Normal file
129
.gitignore
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
254
CHANGELOG.md
Normal file
254
CHANGELOG.md
Normal file
|
@ -0,0 +1,254 @@
|
|||
## 0.24.0 (2025-02-25)
|
||||
|
||||
### Feat
|
||||
|
||||
- add support for manual version bumping
|
||||
|
||||
## 0.23.1 (2024-12-21)
|
||||
|
||||
## 0.23.0 (2024-12-09)
|
||||
|
||||
### Feat
|
||||
|
||||
- **#55**: add ACTOR input parameter
|
||||
|
||||
## 0.22.0 (2024-11-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- add working-directory input
|
||||
|
||||
## 0.21.0 (2024-03-05)
|
||||
|
||||
### Feat
|
||||
|
||||
- add local version and devrelease as inputs (#69)
|
||||
- Add PREVIOUS_REVISION to environment
|
||||
|
||||
## 0.20.0 (2023-09-14)
|
||||
|
||||
### Feat
|
||||
|
||||
- Add new option to hide git output
|
||||
|
||||
## 0.19.0 (2023-09-08)
|
||||
|
||||
## 0.18.2 (2023-05-18)
|
||||
|
||||
### Fix
|
||||
|
||||
- install git-lfs into the dockerfile
|
||||
|
||||
## 0.18.1 (2023-03-28)
|
||||
|
||||
### Fix
|
||||
|
||||
- Add support for GitHub Enterprise Server (#66)
|
||||
|
||||
## 0.18.0 (2023-03-03)
|
||||
|
||||
### BREAKING CHANGE
|
||||
|
||||
- Remove `use_ssh`. Documentation is in place to deploy using SSH keys
|
||||
|
||||
### Fix
|
||||
|
||||
- remove use_ssh flag (#65)
|
||||
|
||||
## 0.17.1 (2023-03-03)
|
||||
|
||||
### Fix
|
||||
|
||||
- add openssh to Dockerfile
|
||||
|
||||
## 0.17.0 (2023-03-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- add support for SSH deploy keys (#64)
|
||||
|
||||
## 0.16.3 (2023-02-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- missing `libffi-dev` in `Dockerfile` which breaks third party plugins (#60)
|
||||
|
||||
## 0.16.2 (2023-02-06)
|
||||
|
||||
### Fix
|
||||
|
||||
- change docker image version back to 3.8 (#59)
|
||||
|
||||
## 0.16.1 (2023-02-05)
|
||||
|
||||
### Fix
|
||||
|
||||
- add safe directory to git (#57)
|
||||
|
||||
## 0.16.0 (2023-01-07)
|
||||
|
||||
### Feat
|
||||
|
||||
- **entrypoing.sh**: add `gpg` sign
|
||||
- **debug**: add option for debug output
|
||||
|
||||
### Fix
|
||||
|
||||
- check_consistency flag being ignored
|
||||
|
||||
## 0.15.1 (2022-10-18)
|
||||
|
||||
### Fix
|
||||
|
||||
- Port from set-output to environment files
|
||||
|
||||
## 0.15.0 (2022-10-04)
|
||||
|
||||
### Feat
|
||||
|
||||
- add `check-consistency` option
|
||||
|
||||
## 0.14.1 (2022-07-07)
|
||||
|
||||
### Fix
|
||||
|
||||
- Refuse to push on pull_request event
|
||||
- Don't pull or push with nothing to push
|
||||
- Print error message to stderr
|
||||
|
||||
## 0.14.0 (2022-07-05)
|
||||
|
||||
### Fix
|
||||
|
||||
- remove bad comma
|
||||
|
||||
### Feat
|
||||
|
||||
- add increment option
|
||||
|
||||
## 0.13.2 (2022-05-11)
|
||||
|
||||
### Fix
|
||||
|
||||
- Don't quote the > operator in entrypoint.sh
|
||||
- Don't quote the > operator in entrypoint.sh
|
||||
- Follow Bash best practices in entrypoint
|
||||
- Configure git pull to rebase instead of merge
|
||||
- Configure git pull to rebase instead of merge
|
||||
|
||||
### Refactor
|
||||
|
||||
- Remove unnecessary --follow-tags
|
||||
- Get current Git branch more simply
|
||||
|
||||
## 0.13.1 (2022-05-10)
|
||||
|
||||
### Fix
|
||||
|
||||
- Correct default branch from master to current
|
||||
|
||||
## 0.13.0 (2022-05-04)
|
||||
|
||||
### Feat
|
||||
|
||||
- add no-raise option
|
||||
- add no-raise option
|
||||
|
||||
## 0.12.0 (2022-02-24)
|
||||
|
||||
### Feat
|
||||
|
||||
- add commitizen version input
|
||||
- add commitizen version input
|
||||
|
||||
### Refactor
|
||||
|
||||
- rename cz version variable
|
||||
|
||||
## 0.11.0 (2021-12-18)
|
||||
|
||||
### Feat
|
||||
|
||||
- detect default branch
|
||||
- detect default branch
|
||||
|
||||
## 0.10.0 (2021-11-17)
|
||||
|
||||
### Feat
|
||||
|
||||
- add `commit` and `push` inputs
|
||||
|
||||
## 0.9.0 (2021-09-14)
|
||||
|
||||
### Feat
|
||||
|
||||
- add version output
|
||||
|
||||
## 0.8.0 (2021-08-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- removed id from default git_email
|
||||
|
||||
### Feat
|
||||
|
||||
- support custom git config
|
||||
|
||||
## 0.7.0 (2021-03-08)
|
||||
|
||||
### Feat
|
||||
|
||||
- add support for `--changelog-to-stdout`
|
||||
|
||||
### Fix
|
||||
|
||||
- use commitizen-tool action instead of Woile's
|
||||
|
||||
## 0.6.0 (2021-02-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- add pull before pushing to avoid error with remote with new changes
|
||||
|
||||
## 0.5.0 (2020-12-02)
|
||||
|
||||
### Feat
|
||||
|
||||
- add extra_requirements parameters instead of reading the requirements.txt file
|
||||
|
||||
## 0.4.0 (2020-11-24)
|
||||
|
||||
### Feat
|
||||
|
||||
- add echo Commitizen version to better debug (#4)
|
||||
|
||||
## 0.3.0 (2020-10-05)
|
||||
|
||||
### Feat
|
||||
|
||||
- add prerelease option
|
||||
|
||||
## 0.2.1 (2020-10-04)
|
||||
|
||||
### Fix
|
||||
|
||||
- **entrypoint**: typo correction
|
||||
|
||||
## 0.2.0 (2020-08-13)
|
||||
|
||||
### Feat
|
||||
|
||||
- change tag format
|
||||
|
||||
## 0.1.0 (2020-08-13)
|
||||
|
||||
### Feat
|
||||
|
||||
- add parameters `github_token`, `repository` and `branch`
|
||||
- introduce github action
|
||||
|
||||
### Fix
|
||||
|
||||
- **entrypoint**: add git user and email
|
||||
- add 'yes' arg to bump
|
||||
- remove tag format
|
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
FROM python:3.10-alpine
|
||||
|
||||
RUN set -eux; \
|
||||
apk add --no-cache \
|
||||
git \
|
||||
git-lfs \
|
||||
gpg \
|
||||
alpine-sdk \
|
||||
bash \
|
||||
libffi-dev \
|
||||
; \
|
||||
git lfs install;
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Santiago
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
192
README.md
Normal file
192
README.md
Normal file
|
@ -0,0 +1,192 @@
|
|||
# commitizen-action
|
||||
|
||||
Add [commitizen][cz] incredibly fast into your project!
|
||||
|
||||
## Features
|
||||
|
||||
- Allow prerelease
|
||||
- Super easy to setup
|
||||
- Automatically bump version
|
||||
- Automatically create changelog
|
||||
- Update any file in your repo with the new version
|
||||
|
||||
Are you using [conventional commits][cc] and [semver][semver]?
|
||||
|
||||
Then you are ready to use this github action! The only thing you'll need is the
|
||||
`.cz.toml` file in your project.
|
||||
|
||||
## Usage
|
||||
|
||||
1. In your repository create a `.cz.toml` file (you can run `cz init` to create it)
|
||||
2. Create a `.github/workflows/bumpversion.yaml` with the Sample Workflow
|
||||
|
||||
### Minimal configuration
|
||||
|
||||
Your `.cz.toml` (or `pyproject.toml` if you are using python) should look like
|
||||
this.
|
||||
|
||||
```toml
|
||||
[tool.commitizen]
|
||||
version = "0.1.0" # This should be your current semver version
|
||||
```
|
||||
|
||||
For more information visit [commitizen's configuration page][cz-conf]
|
||||
|
||||
## Sample Workflow
|
||||
|
||||
```yaml
|
||||
name: Bump version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
bump_version:
|
||||
if: "!startsWith(github.event.head_commit.message, 'bump:')"
|
||||
runs-on: ubuntu-latest
|
||||
name: "Bump version and create changelog with commitizen"
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- id: cz
|
||||
name: Create bump and changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Print Version
|
||||
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
|
||||
```
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
||||
| `github_token` | Token for the repo. Can be passed in using `${{ secrets.GITHUB_TOKEN }}`. Required if `push: true` | - |
|
||||
| `working_directory` | Change to this directory before running | repo root directory |
|
||||
| `dry_run` | Run without creating commit, output to stdout | false |
|
||||
| `repository` | Repository name to push. Default or empty value represents current github repository | current one |
|
||||
| `branch` | Destination branch to push changes | Same as the one executing the action by default |
|
||||
| `prerelease` | Set as prerelease {alpha,beta,rc} choose type of prerelease | - |
|
||||
| `extra_requirements` | Custom requirements, if your project uses a custom rule or plugins, you can specify them separated by a space. E.g: `'commitizen-emoji conventional-JIRA'` | - |
|
||||
| `changelog_increment_filename` | Filename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version. Example: `body.md` | - |
|
||||
| `git_redirect_stderr` | Redirect git output to stderr. Useful if you do not want git output in your changelog | `false` |
|
||||
| `git_name` | Name used to configure git (for git operations) | `github-actions[bot]` |
|
||||
| `git_email` | Email address used to configure git (for git operations) | `github-actions[bot]@users.noreply.github.com` |
|
||||
| `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 |
|
||||
| `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} | - |
|
||||
| `check_consistency` | Check consistency among versions defined in commitizen configuration and version_files | `false` |
|
||||
| `gpg_sign` | If true, use GPG to sign commits and tags (for git operations). Requires separate setup of GPG key and passphrase in GitHub Actions (e.g. with the action `crazy-max/ghaction-import-gpg`) | `false` |
|
||||
| `debug` | Prints debug output to GitHub Actions stdout | `false` |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
| --------- | --------------- |
|
||||
| `version` | The new version |
|
||||
|
||||
The new version is also available as an environment variable under `REVISION` or you can access using `${{ steps.cz.outputs.version }}`
|
||||
|
||||
## Using SSH with deploy keys
|
||||
|
||||
1. Create a [deploy key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys) (which is the SSH **public key**)
|
||||
2. Add the **private key** as a [Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) in your repository, e.g: `COMMIT_KEY`
|
||||
3. Set up your action
|
||||
|
||||
```yaml
|
||||
name: Bump version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
if: "!startsWith(github.event.head_commit.message, 'bump:')"
|
||||
runs-on: ubuntu-latest
|
||||
name: "Bump version and create changelog with commitizen"
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ssh-key: "${{ secrets.COMMIT_KEY }}"
|
||||
- name: Create bump and changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
push: false
|
||||
- name: Push using ssh
|
||||
run: |
|
||||
git push origin main --tags
|
||||
```
|
||||
|
||||
## Creating a Github release
|
||||
|
||||
```yaml
|
||||
name: Bump version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
if: "!startsWith(github.event.head_commit.message, 'bump:')"
|
||||
runs-on: ubuntu-latest
|
||||
name: "Bump version and create changelog with commitizen"
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
|
||||
- name: Create bump and changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
||||
changelog_increment_filename: body.md
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body_path: "body.md"
|
||||
tag_name: ${{ env.REVISION }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Other actions are not triggered when the tag is pushed
|
||||
|
||||
This problem occurs because `secrets.GITHUB_TOKEN` do not trigger other
|
||||
actions [by design][by_design].
|
||||
|
||||
To solve it, you must use a personal access token in the checkout and the commitizen steps.
|
||||
|
||||
Follow the instructions in [commitizen's documentation][cz-docs-ga].
|
||||
|
||||
## 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,
|
||||
create a new commitizen python package, or you can describe it on the `toml` config itself.
|
||||
|
||||
[Read more about customization][cz-custom]
|
||||
|
||||
[by_design]: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#example-using-multiple-events-with-activity-types-or-configuration
|
||||
[cz-docs-ga]: https://commitizen-tools.github.io/commitizen/tutorials/github_actions/
|
||||
[cz]: https://commitizen-tools.github.io/commitizen/
|
||||
[cc]: https://www.conventionalcommits.org/
|
||||
[semver]: https://semver.org/
|
||||
[cz-conf]: https://commitizen-tools.github.io/commitizen/config/
|
||||
[cz-custom]: https://commitizen-tools.github.io/commitizen/customization/
|
108
action.yml
Normal file
108
action.yml
Normal file
|
@ -0,0 +1,108 @@
|
|||
name: "Bump and changelog using commitizen"
|
||||
description: "Create a commit bumping the version of your project and creating a changelog file"
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
branding:
|
||||
icon: "git-commit"
|
||||
color: "purple"
|
||||
outputs:
|
||||
version:
|
||||
description: "New version"
|
||||
inputs:
|
||||
working_directory:
|
||||
description: "Change to this directory before running"
|
||||
required: false
|
||||
dry_run:
|
||||
description: "Run without creating commit, output to stdout"
|
||||
required: false
|
||||
commit:
|
||||
description: "If true a commit is created containing the bump changes"
|
||||
required: false
|
||||
default: "true"
|
||||
push:
|
||||
description: "If true the bump commit is pushed to the remote repository"
|
||||
required: false
|
||||
default: "true"
|
||||
merge:
|
||||
description: >
|
||||
If true, the bump commit is pushed to the remote repository even when the
|
||||
action is run on the pull_request event, immediately merging the pull request
|
||||
required: false
|
||||
default: "false"
|
||||
prerelease:
|
||||
description: "Set as prerelease version"
|
||||
required: false
|
||||
devrelease:
|
||||
description: "Non-negative integer for dev. release"
|
||||
required: false
|
||||
local_version:
|
||||
description: "Bump only the local version portion"
|
||||
required: false
|
||||
default: "false"
|
||||
changelog:
|
||||
description: "Create changelog when bumping the version"
|
||||
default: "true"
|
||||
required: false
|
||||
github_token:
|
||||
description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
|
||||
required: false
|
||||
repository:
|
||||
description: "Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})"
|
||||
default: ""
|
||||
required: false
|
||||
branch:
|
||||
description: "Destination branch to push changes"
|
||||
required: false
|
||||
default: ""
|
||||
extra_requirements:
|
||||
description: "Extra commitizen dependencies like your custom plugins or rules"
|
||||
required: false
|
||||
default: ""
|
||||
changelog_increment_filename:
|
||||
description: "Filename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version"
|
||||
required: false
|
||||
git_redirect_stderr:
|
||||
description: "Redirect git output to stderr. Useful if you do not want git output in your changelog"
|
||||
required: false
|
||||
default: "false"
|
||||
git_name:
|
||||
description: "Name used to configure git (for git operations)"
|
||||
required: false
|
||||
default: "github-actions[bot]"
|
||||
git_email:
|
||||
description: "Email address used to configure git (for git operations)"
|
||||
required: false
|
||||
default: "github-actions[bot]@users.noreply.github.com"
|
||||
commitizen_version:
|
||||
description: "Specify the version to be used by commitizen"
|
||||
required: false
|
||||
default: latest
|
||||
no_raise:
|
||||
description: "Don't raise the given comma-delimited exit codes"
|
||||
required: false
|
||||
default: "21"
|
||||
increment:
|
||||
description: "Manually specify the desired increment"
|
||||
required: false
|
||||
check_consistency:
|
||||
default: "false"
|
||||
description: "check consistency among versions defined in commitizen configuration and version_files"
|
||||
required: false
|
||||
gpg_sign:
|
||||
description: >
|
||||
If true, use GPG to sign commits and tags (for git operations). Requires separate
|
||||
setup of GPG key and passphrase in GitHub Actions (e.g. with the action
|
||||
crazy-max/ghaction-import-gpg)
|
||||
required: false
|
||||
default: "false"
|
||||
debug:
|
||||
description: "If true, prints debug output to GitHub Actions stdout."
|
||||
required: false
|
||||
default: "false"
|
||||
actor:
|
||||
description: "The account that will be used to perform git operations, defaults to the GITHUB_ACTOR"
|
||||
required: false
|
||||
manual_version:
|
||||
description: "Manually specify the version to bump to"
|
||||
required: false
|
127
entrypoint.sh
Executable file
127
entrypoint.sh
Executable file
|
@ -0,0 +1,127 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Reporting
|
||||
gpg --version
|
||||
git --version
|
||||
|
||||
if [[ -z $INPUT_GITHUB_TOKEN && $INPUT_PUSH == "true" ]]; then
|
||||
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}" which is required to push.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Configuring Git username, email, and pull behavior..."
|
||||
|
||||
# Fix #56
|
||||
git config --global --add safe.directory "*"
|
||||
|
||||
git config --local user.name "${INPUT_GIT_NAME}"
|
||||
git config --local user.email "${INPUT_GIT_EMAIL}"
|
||||
git config --local pull.rebase true
|
||||
echo "Git name: $(git config --get user.name)"
|
||||
echo "Git email: $(git config --get user.email)"
|
||||
|
||||
PIP_CMD=('pip' 'install')
|
||||
if [[ $INPUT_COMMITIZEN_VERSION == 'latest' ]]; then
|
||||
PIP_CMD+=('commitizen')
|
||||
else
|
||||
PIP_CMD+=("commitizen==${INPUT_COMMITIZEN_VERSION}")
|
||||
fi
|
||||
IFS=" " read -r -a INPUT_EXTRA_REQUIREMENTS <<<"$INPUT_EXTRA_REQUIREMENTS"
|
||||
PIP_CMD+=("${INPUT_EXTRA_REQUIREMENTS[@]}")
|
||||
echo "${PIP_CMD[@]}"
|
||||
"${PIP_CMD[@]}"
|
||||
echo "Commitizen version: $(cz version)"
|
||||
|
||||
if [[ $INPUT_WORKING_DIRECTORY ]]; then
|
||||
cd $INPUT_WORKING_DIRECTORY
|
||||
fi
|
||||
|
||||
PREV_REV="$(cz version --project)"
|
||||
echo "PREVIOUS_REVISION=${PREV_REV}" >>"$GITHUB_ENV"
|
||||
|
||||
CZ_CMD=('cz')
|
||||
if [[ $INPUT_DEBUG == 'true' ]]; then
|
||||
CZ_CMD+=('--debug')
|
||||
fi
|
||||
if [[ $INPUT_NO_RAISE ]]; then
|
||||
CZ_CMD+=('--no-raise' "$INPUT_NO_RAISE")
|
||||
fi
|
||||
CZ_CMD+=('bump' '--yes')
|
||||
if [[ $INPUT_GPG_SIGN == 'true' ]]; then
|
||||
CZ_CMD+=('--gpg-sign')
|
||||
fi
|
||||
if [[ $INPUT_DRY_RUN == 'true' ]]; then
|
||||
CZ_CMD+=('--dry-run')
|
||||
fi
|
||||
if [[ $INPUT_CHANGELOG == 'true' ]]; then
|
||||
CZ_CMD+=('--changelog')
|
||||
fi
|
||||
if [[ $INPUT_PRERELEASE ]]; then
|
||||
CZ_CMD+=('--prerelease' "$INPUT_PRERELEASE")
|
||||
fi
|
||||
if [[ $INPUT_DEVRELEASE ]]; then
|
||||
CZ_CMD+=('--devrelease' "$INPUT_DEVRELEASE")
|
||||
fi
|
||||
if [[ $INPUT_LOCAL_VERSION == 'true' ]]; then
|
||||
CZ_CMD+=('--local-version')
|
||||
fi
|
||||
if [[ $INPUT_COMMIT == 'false' ]]; then
|
||||
CZ_CMD+=('--files-only')
|
||||
fi
|
||||
if [[ $INPUT_INCREMENT ]]; then
|
||||
CZ_CMD+=('--increment' "$INPUT_INCREMENT")
|
||||
fi
|
||||
if [[ $INPUT_CHECK_CONSISTENCY == 'true' ]]; then
|
||||
CZ_CMD+=('--check-consistency')
|
||||
fi
|
||||
if [[ $INPUT_GIT_REDIRECT_STDERR == 'true' ]]; then
|
||||
CZ_CMD+=('--git-output-to-stderr')
|
||||
fi
|
||||
if [[ $INPUT_MANUAL_VERSION ]]; then
|
||||
CZ_CMD+=("$INPUT_MANUAL_VERSION")
|
||||
fi
|
||||
if [[ $INPUT_CHANGELOG_INCREMENT_FILENAME ]]; then
|
||||
CZ_CMD+=('--changelog-to-stdout')
|
||||
echo "${CZ_CMD[@]}" ">$INPUT_CHANGELOG_INCREMENT_FILENAME"
|
||||
"${CZ_CMD[@]}" >"$INPUT_CHANGELOG_INCREMENT_FILENAME"
|
||||
else
|
||||
echo "${CZ_CMD[@]}"
|
||||
"${CZ_CMD[@]}"
|
||||
fi
|
||||
if [[ $INPUT_ACTOR ]]; then
|
||||
ACTOR=$INPUT_ACTOR
|
||||
else
|
||||
ACTOR=$GITHUB_ACTOR
|
||||
fi
|
||||
|
||||
REV="$(cz version --project)"
|
||||
if [[ $REV == "$PREV_REV" ]]; then
|
||||
INPUT_PUSH='false'
|
||||
fi
|
||||
echo "REVISION=${REV}" >>"$GITHUB_ENV"
|
||||
echo "version=${REV}" >>"$GITHUB_OUTPUT"
|
||||
|
||||
GITHUB_DOMAIN=${GITHUB_SERVER_URL#*//}
|
||||
CURRENT_BRANCH="$(git branch --show-current)"
|
||||
INPUT_BRANCH="${INPUT_BRANCH:-$CURRENT_BRANCH}"
|
||||
INPUT_REPOSITORY="${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}"
|
||||
|
||||
echo "Repository: ${INPUT_REPOSITORY}"
|
||||
echo "Actor: ${ACTOR}"
|
||||
|
||||
if [[ $INPUT_PUSH == 'true' ]]; then
|
||||
if [[ $INPUT_MERGE != 'true' && $GITHUB_EVENT_NAME == 'pull_request' ]]; then
|
||||
echo "Refusing to push on pull_request event since that would merge the pull request." >&2
|
||||
echo "You probably want to run on push to your default branch instead." >&2
|
||||
else
|
||||
echo "Pushing to branch..."
|
||||
REMOTE_REPO="https://${ACTOR}:${INPUT_GITHUB_TOKEN}@${GITHUB_DOMAIN}/${INPUT_REPOSITORY}.git"
|
||||
git pull "$REMOTE_REPO" "$INPUT_BRANCH"
|
||||
git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags
|
||||
fi
|
||||
else
|
||||
echo "Not pushing"
|
||||
fi
|
||||
echo "Done."
|
Loading…
Add table
Add a link
Reference in a new issue