From 17a540dbd81819403b61e8b12bdbe9c39c9c6372 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:10:18 +0000 Subject: [PATCH 1/6] fix: exclude nix from language profile --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4dee12a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +flake.nix linguist-vendored +flake.lock linguist-vendored From 35bdec267ac3e0f7a94e1b1fd701df6bd4adba79 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:16:32 +0000 Subject: [PATCH 2/6] fix(example): remove wrong parameter --- examples/bump-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bump-release.yaml b/examples/bump-release.yaml index c5bd6a7..55300ea 100644 --- a/examples/bump-release.yaml +++ b/examples/bump-release.yaml @@ -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: From ad3483dae7dddd51c77f79867233eb407a19151f Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:16:52 +0000 Subject: [PATCH 3/6] feat(examples): add new collect-version-info --- examples/collect-version-info.yaml | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 examples/collect-version-info.yaml diff --git a/examples/collect-version-info.yaml b/examples/collect-version-info.yaml new file mode 100644 index 0000000..b252518 --- /dev/null +++ b/examples/collect-version-info.yaml @@ -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" From 6d33ba3d4cd322a1d2975876a4199024fb6b1f2c Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:21:38 +0000 Subject: [PATCH 4/6] feat(examples): add new build-changelog --- examples/build-changelog.yaml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/build-changelog.yaml diff --git a/examples/build-changelog.yaml b/examples/build-changelog.yaml new file mode 100644 index 0000000..b653b0f --- /dev/null +++ b/examples/build-changelog.yaml @@ -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 From ae5fa3e637dcfb5f4701ea7714ce93fa7df37ece Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:26:12 +0000 Subject: [PATCH 5/6] fix(tests): add a new test for a command --- .github/workflows/test.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9ca4437..4c431dc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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'); From d698a668c8085e1cedfafcd8872ab9a0abe72aa4 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 21 Nov 2025 08:33:20 +0000 Subject: [PATCH 6/6] feat(action): enable cache --- action.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 9ae5acc..3a52f7c 100644 --- a/action.yaml +++ b/action.yaml @@ -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: