Automagically 🧚♀️ create branch, pull request, bump version (using Commitizen
), approve and merge.
pumper
helps create CI/CD bump version
jobs more secure 👮♀️.
Common version bump strategy these days is to have CI/CD workflow run automatic version bump directly in a main branch:
This raises following concerns (among others) in highly secured environments:
- direct push to a main branch required
- branch protection rules needs to be relieved
- change in main branch is not reviewed
Bump strategy with pumper
:
- Call great tool
Commitizen
. It checks your commit history and bumps your version. Check it out for more information how to configure and use it. - Create a branch including changes from above step a push it.
- Create PR.
- Optionally approve a merge PR.
pumper
can be installed from PYPI. It's recommended to install it in isolated Python environment using venv.
python -m venv .venv
.venv/bin/pip install pumper
Usage: pumper create [OPTIONS]
Bump version, push branch and create pull request.
╭─ Options ──────────────────────────────────────────────────────────────────────╮
│ * --repo TEXT The owner and repository name, eg 'owner/repo'. │
│ [env var: GITHUB_REPOSITORY] │
│ [default: None] │
│ [required] │
│ --url TEXT Github API url. │
│ [env var: GITHUB_API_URL] │
│ [default: https://api.github.com] │
│ * --token TEXT Github token. [env var: GITHUB_TOKEN] │
│ [default: None] [required] │
│ --base TEXT Base branch of a PR. [env var: BASE_BRANCH] │
│ [default: main] │
│ --branch TEXT Branch name and PR title. │
│ [default: release/{version}] │
│ --user TEXT Git user name. [default: github-actions[bot]] │
│ --email TEXT Git user email. │
│ [default: │
│ github-actions[bot]@users.noreply.github.com] │
│ --gh-env Create 'PR_NUM' env var for GH actions │
│ --label TEXT Add labels to PR. [default: None] │
│ --assign Assign PR [default: True] │
│ --assignee TEXT PR assignee name. [env var: GITHUB_ACTOR] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────╯
Usage: pumper approve [OPTIONS] PR_NUM
Approve pull request.
╭─ Arguments ────────────────────────────────────────────────────────────────────╮
│ * pr_num INTEGER PR number. [env var: PR_NUM] [default: None] │
│ [required] │
╰────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────╮
│ * --repo TEXT The owner and repository name, eg 'owner/repo'. │
│ [env var: GITHUB_REPOSITORY] │
│ [default: None] │
│ [required] │
│ --url TEXT Github API url. │
│ [env var: GITHUB_API_URL] │
│ [default: https://api.github.com] │
│ * --token TEXT Github token. [env var: GITHUB_TOKEN] [default: None] │
│ [required] │
│ --body TEXT PR message. [default: 🤖 Approved by GH actions!] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────╯
Usage: pumper merge [OPTIONS] PR_NUM
Merge pull request.
╭─ Arguments ───────────────────────────────────────────────────────────────────╮
│ * pr_num INTEGER PR number. [env var: PR_NUM] [default: None] │
│ [required] │
╰───────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────╮
│ --method [merge|squash|rebase] The merge method to use. │
│ [default: merge] │
│ * --repo TEXT The owner and repository name, eg │
│ 'owner/repo'. │
│ [env var: GITHUB_REPOSITORY] │
│ [default: None] │
│ [required] │
│ --url TEXT Github API url. │
│ [env var: GITHUB_API_URL] │
│ [default: https://api.github.com] │
│ * --token TEXT Github token. │
│ [env var: GITHUB_TOKEN] │
│ [default: None] │
│ [required] │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────╯
See my GH actions bumper.yaml
workflow. Replace pip install .
with pip install pumper==0.2.0
(line 31).
- Allow GitHub Actions to create and approve pull requests in your repository settings.
- Depending on which token you want to use:
-
Actions
GITHUB_TOKEN
needs following permissions:permissions: pull-requests: write contents: write
-
Github personal access tokens (classic) needs
public_repo
scope for public repositories or fullrepo
scope for a private repositories.
-
Big thanks 🙏 to following libraries: