Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .cz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
commitizen:
major_version_zero: true
name: cz_conventional_commits
tag_format: v$version
update_changelog_on_bump: true
version: 0.0.1
version_scheme: semver2
annotated_tag: true
56 changes: 56 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
push:
branches:
- main

jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-cz@main
- uses: pndurette/gh-actions-auto-docs@v1
with:
git_push: false
- id: bump-version
run: |
cz bump --yes
current_version="v$(cz version -p --current)"
major_version="v$(cz version -p --major)"
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "major_version=$major_version" >> $GITHUB_OUTPUT
- name: Update major tag
env:
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
MAJOR_VERSION: ${{ steps.bump-version.outputs.major_version }}
run: |
# Push new commit + new tag
git push --follow-tags

# Move major tag to the latest commit
git tag -fa "${MAJOR_VERSION}" -m "release ${CURRENT_VERSION}"

# Force push new major tag
git push origin "${MAJOR_VERSION}" -f
- name: Build changelog
env:
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
run: |
cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: ".changelog.md"
tag_name: ${{ steps.bump-version.outputs.current_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test

on:
pull_request:
branches:
- main

jobs:
test-installs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./
- name: Test it was installed
run: |
cz version
test-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./
with:
version: 4.0.0
- name: Test version matches
uses: actions/github-script@v8
with:
script: |
const assert = require('node:assert/strict');
const czVersion = await exec.getExecOutput('cz', ['version']);
const expectedVersion = '4.0.0';
assert.equal(czVersion.stdout.trim(), expectedVersion);
test-extra-requirements:
strategy:
matrix:
extra_requirements:
- pip_name: cz-conventional-gitmoji
cz_name: cz_gitmoji
- pip_name: cz-kpn
cz_name: cz_kpn
- pip_name: cz-kpn cz-conventional-gitmoji==0.7.0
cz_name: cz_kpn
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./
with:
extra_requirements: ${{ matrix.extra_requirements.pip_name }}
- name: Test extra requirements were installed
uses: actions/github-script@v8
env:
EXTRA_REQUIREMENTS: ${{ matrix.extra_requirements.cz_name }}
with:
script: |
const assert = require('node:assert/strict');
const extraRequirements = process.env.EXTRA_REQUIREMENTS;
const czList = await exec.getExecOutput('cz', ['ls']);
const allItems = czList.stdout.trim().split('\n');
const result = allItems.includes(extraRequirements);
assert.ok(result, `Expected ${extraRequirements} to be included in the list of installed cz plugins, but it was not.`);
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
*$py.class

# nix
.direnv
result
.envrc

# python
.venv/
venv/
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# setup-cz
Github action to configure cz

> Github action to only configure cz CLI

## Usage

```yaml
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-cz@main
- name: Set up git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: |
cz version -p
cz bump --yes --annotated-tag
git push --follow-tags
```

<!--doc_begin-->
<!--doc_end-->
41 changes: 41 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Setup commitizen CLI
description: |
This workflow sets up the commitizen CLI for use in your GitHub workflows.
Unlike `commitizen-action`, this workflow only installs the CLI.
It does not automatically bump, commit or push changes.
This workflow, instead, gives more flexibility to the user by letting them
use the full range of commitizen commands.

inputs:
version:
description: "Version of commitizen to install"
required: false
default: "latest"
extra_requirements:
description: "Install extra dependencies"
required: false

runs:
using: "composite"
steps:
- uses: actions/setup-python@v6
- id: set-vars
shell: python
env:
COMMITIZEN_VERSION: ${{ inputs.version }}
run: |
import os
commitizen_version = os.environ.get("COMMITIZEN_VERSION", "").strip()
if commitizen_version == "latest":
set_commitizen_version = ""
else:
set_commitizen_version = f"=={commitizen_version}"
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
fh.write(f"COMMITIZEN_VERSION={set_commitizen_version}\n")
- name: Install commitizen
shell: bash
env:
COMMITIZEN_VERSION: ${{ steps.set-vars.outputs.COMMITIZEN_VERSION }}
EXTRA_REQUIREMENTS: ${{ inputs.extra_requirements }}
run: |
pip install -U commitizen${COMMITIZEN_VERSION} ${EXTRA_REQUIREMENTS}
42 changes: 42 additions & 0 deletions examples/bump-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# YES, YOU CAN COPY-PASTE THIS ACTION AND IT SHOULD WORK
# keep in mind, that it won't trigger other actions because it's using action permissions.
# You can: use a PAT token or a workflow_call to trigger another action
on:
push:
branches:
- main

jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-cz@main
- id: bump-version
run: |
cz bump --yes --annotated-tag
git push --follow-tags
current_version="$(cz version -p --current)" # ATTENTION: You may have to add the v* at the beginning of the version
echo "current_version=$current_version" >> $GITHUB_OUTPUT
- name: Build changelog for Release
env:
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
run: |
cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: ".changelog.md"
tag_name: ${{ steps.bump-version.outputs.current_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
description = "A development shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs =
inputs@{
flake-parts,
...
}:
# https://flake.parts/
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
perSystem =
{ pkgs, ... }:
{
# Default shell opened with `nix develop`
devShells.default = pkgs.mkShell {
name = "dev";

# Available packages on https://search.nixos.org/packages
buildInputs = with pkgs; [
python3
nodejs
commitizen
];

shellHook = ''
echo "Welcome to the devshell!"
'';
};
};
};
}
Loading