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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flake.nix linguist-vendored
flake.lock linguist-vendored
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,25 @@ jobs:
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.`);
test-get-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: ./
- name: Build changelog
env:
GIVEN_VERSION: "v0.1.0"
run: |
cz changelog --dry-run "${GIVEN_VERSION}" > .changelog.md
- name: Verify changelog content
uses: actions/github-script@v8
with:
script: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const changelogContent = fs.readFileSync('.changelog.md', 'utf8');
assert.ok(changelogContent.includes('v0.1.0 (2025-11-20)'), 'Expected changelog to contain version 0.1.0');
assert.ok(changelogContent.includes('### Feat'), 'Expected changelog to contain a header for features');
assert.ok(changelogContent.includes('### Fix'), 'Expected changelog to contain a header for fixes');
21 changes: 20 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,43 @@ inputs:
extra_requirements:
description: "Install extra dependencies"
required: false
cache:
description: 'Cache commitizen installation, set to "true" to enable'
required: false
default: "false"

runs:
using: "composite"
steps:
- uses: actions/setup-python@v6
- id: set-vars
shell: python
env:
COMMITIZEN_VERSION: ${{ inputs.version }}
CACHE: ${{ inputs.cache }}
run: |
import os

# Set commitizen version
commitizen_version = os.environ.get("COMMITIZEN_VERSION", "").strip()
if commitizen_version == "latest":
set_commitizen_version = ""
else:
set_commitizen_version = f"=={commitizen_version}"

# Set python cache
cache = os.environ.get("CACHE", "")
if cache == True or cache == "true":
set_cache = "pip"
else:
set_cache = ""

# Write outputs
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
fh.write(f"COMMITIZEN_VERSION={set_commitizen_version}\n")
fh.write(f"PYTHON_CACHE={set_cache}\n")
- uses: actions/setup-python@v6
with:
cache: ${{ steps.set-vars.outputs.PYTHON_CACHE }}
- name: Install commitizen
shell: bash
env:
Expand Down
40 changes: 40 additions & 0 deletions examples/build-changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Build the changelog for a given version with a manual trigger
on:
workflow_dispatch:
inputs:
version:
description: "Version to build changelog for"
required: true
type: string
# You can also trigger this workflow from another workflow
workflow_call:
inputs:
version:
description: "Version to build changelog for"
required: true
type: string

jobs:
build-changelog:
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.build-changelog.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: commitizen-tools/setup-cz@main
- name: Build changelog
env:
GIVEN_VERSION: ${{ github.event.inputs.version }}
run: |
cz changelog --dry-run "${GIVEN_VERSION}" > .changelog.md
- name: Display changelog
run: |
cat .changelog.md
# You can send this file wherever you want:
# - For a Github release
# - Update a website
# - Send it to a Slack channel
# - Send it to a compliance tool
2 changes: 1 addition & 1 deletion examples/bump-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
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
current_version="$(cz version -p)" # 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:
Expand Down
51 changes: 51 additions & 0 deletions examples/collect-version-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This action shows how to collect version information and propagate it to the next job.
name: Collect Version Info

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
collect-version-info:
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.version-info.outputs.current_version }}
current_major_version: ${{ steps.version-info.outputs.current_major_version }}
current_minor_version: ${{ steps.version-info.outputs.current_minor_version }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-tags: true # in case your version provider is cvs
- uses: commitizen-tools/setup-cz@main
- id: version-info
run: |
# Gather version information
current_version="$(cz version -p)"
current_major_version="$(cz version -p --major)"
current_minor_version="$(cz version -p --minor)"

# Set output variables
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "current_major_version=$current_major_version" >> $GITHUB_OUTPUT
echo "current_minor_version=$current_minor_version" >> $GITHUB_OUTPUT
read-version-info:
runs-on: ubuntu-latest
needs: collect-version-info
steps:
- name: Checkout code
uses: actions/checkout@v5
- run: |
# Read version information
current_version="${{ needs.collect-version-info.outputs.current_version }}"
current_major_version="${{ needs.collect-version-info.outputs.current_major_version }}"
current_minor_version="${{ needs.collect-version-info.outputs.current_minor_version }}"

# Print version information
echo "Current version: $current_version"
echo "Current major version: $current_major_version"
echo "Current minor version: $current_minor_version"
Loading