diff --git a/.cz.toml b/.cz.toml index fac65e1..efcd9be 100644 --- a/.cz.toml +++ b/.cz.toml @@ -1,6 +1,6 @@ [tool.commitizen] name = "cz_conventional_commits" -version = "0.18.2" +version = "0.24.0" format = "v$version" update_changelog_on_bump = true major_version_zero = true diff --git a/.github/workflows/bumpversion.yaml b/.github/workflows/bumpversion.yaml index 76e8e65..bb486f6 100644 --- a/.github/workflows/bumpversion.yaml +++ b/.github/workflows/bumpversion.yaml @@ -17,7 +17,7 @@ jobs: - name: Create bump and changelog uses: commitizen-tools/commitizen-action@master with: - github_token: "${{ secrets.GITHUB_TOKEN }}" + github_token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" changelog_increment_filename: body.md - name: Release uses: softprops/action-gh-release@v1 @@ -25,4 +25,4 @@ jobs: body_path: "body.md" tag_name: "${{ env.REVISION }}" env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" diff --git a/.github/workflows/update_semver.yml b/.github/workflows/update_semver.yml new file mode 100644 index 0000000..dc41a80 --- /dev/null +++ b/.github/workflows/update_semver.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index da2e737..96a36da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +## 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 diff --git a/README.md b/README.md index 9b23a7d..b49d76b 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,14 @@ jobs: | 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 | diff --git a/action.yml b/action.yml index d3e5d16..a817f96 100644 --- a/action.yml +++ b/action.yml @@ -1,24 +1,27 @@ -name: 'Bump and changelog using commitizen' -description: 'Create a commit bumping the version of your project and creating a changelog file' +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' + using: "docker" + image: "Dockerfile" branding: - icon: 'git-commit' - color: 'purple' + icon: "git-commit" + color: "purple" outputs: version: - description: 'New 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' + description: "Run without creating commit, output to stdout" required: false commit: - description: 'If true a commit is created containing the bump changes' + 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' + description: "If true the bump commit is pushed to the remote repository" required: false default: "true" merge: @@ -28,51 +31,62 @@ inputs: required: false default: "false" prerelease: - description: 'Set as prerelease version' + 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' + 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: '' + 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' + description: "Destination branch to push changes" required: false - default: '' + default: "" extra_requirements: - description: 'Extra commitizen dependencies like your custom plugins or rules' + description: "Extra commitizen dependencies like your custom plugins or rules" required: false - default: '' + 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' + 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)' + description: "Name used to configure git (for git operations)" required: false - default: 'github-actions[bot]' + default: "github-actions[bot]" git_email: - description: 'Email address used to configure git (for git operations)' + description: "Email address used to configure git (for git operations)" required: false - default: 'github-actions[bot]@users.noreply.github.com' + default: "github-actions[bot]@users.noreply.github.com" commitizen_version: - description: 'Specify the version to be used by commitizen' + 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' + default: "21" increment: description: "Manually specify the desired increment" required: false check_consistency: - default: 'false' + default: "false" description: "check consistency among versions defined in commitizen configuration and version_files" required: false gpg_sign: @@ -86,3 +100,9 @@ inputs: 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 diff --git a/entrypoint.sh b/entrypoint.sh index 8a6a7d7..40850ff 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -34,7 +34,12 @@ 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 @@ -56,15 +61,27 @@ 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 ]]; then +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" @@ -73,6 +90,11 @@ 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 @@ -87,7 +109,7 @@ INPUT_BRANCH="${INPUT_BRANCH:-$CURRENT_BRANCH}" INPUT_REPOSITORY="${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}" echo "Repository: ${INPUT_REPOSITORY}" -echo "Actor: ${GITHUB_ACTOR}" +echo "Actor: ${ACTOR}" if [[ $INPUT_PUSH == 'true' ]]; then if [[ $INPUT_MERGE != 'true' && $GITHUB_EVENT_NAME == 'pull_request' ]]; then @@ -95,7 +117,7 @@ if [[ $INPUT_PUSH == 'true' ]]; then echo "You probably want to run on push to your default branch instead." >&2 else echo "Pushing to branch..." - REMOTE_REPO="https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${GITHUB_DOMAIN}/${INPUT_REPOSITORY}.git" + 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