Skip to content

Commit

Permalink
feat: support gitlab, gitea, and bitbucket for git-cliff (#208)
Browse files Browse the repository at this point in the history
fixes #188

BREAKING CHANGE: `--github-repo` has been renamed to `--git-repo`
BREAKING CHANGE: `githubRepo` has been renamed to `gitRepo`
BREAKING CHANGE: `--github-token` has been renamed to `gitToken`
BREAKING CHANGE: `githubToken` has been renamed to `gitToken`
BREAKING CHANGE: The environment variables `TOKEN_GITHUB` and `TOKEN_GH` are no longer supported
BREAKING CHANGE: environment variables `GITLAB_TOKEN`, `GITEA_TOKEN`, and `BITBUCKET_TOKEN` are now supported for `--git-token`
BREAKING CHANGE: A new option `--git-host-variant` was added, which defaults to `'github'`. To release to GitHub, this has to be set to `'github'`.
  • Loading branch information
favna authored Oct 19, 2024
1 parent 22a51d9 commit a4b30d0
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 114 deletions.
4 changes: 2 additions & 2 deletions .cliff-jumperrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packagePath": ".",
"identifierBase": false,
"pushTag": true,
"gitRepo": "auto",
"githubRelease": true,
"githubReleaseLatest": true,
"githubRepo": "auto"
"githubReleaseLatest": true
}
69 changes: 36 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,15 @@ Options:
Defaults to "chore({{name}}): release {{full-name}}@{{new-version}}"
You can use "{{new-version}}" in your template which will be dynamically replaced with whatever the new version is that will be published.
You can use "{{name}}" in your template, this will be replaced with the name provided through "-n", "--name" or the same value set in your config file.
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is
provided).
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is provided).
--tag-template [string] A custom tag template to use.
When "org" is provided this will default to "@{{org}}/{{name}}@{{new-version}}", for example "@favware/[email protected]"
When "org" is not provided this will default to "v{{new-version}}", for example "v1.0.0"
You can use "{{new-version}}" in your template which will be dynamically replaced with whatever the new version is that will be published.
You can use "{{org}}" in your template, this will be replaced with the org provided through "-o", "--org" or the same value set in your config file.
You can use "{{name}}" in your template, this will be replaced with the name provided through "-n", "--name" or the same value set in your config file.
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is
provided).
-i, --install Whether to run npm install after bumping the version but before committing and creating a git tag. This is useful when you have a mono repo where bumping
one package would then cause the lockfile to be out of date.
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is provided).
-i, --install Whether to run npm install after bumping the version but before committing and creating a git tag. This is useful when you have a mono repo where bumping one package would then cause the lockfile to be out of date.
--skip-changelog Whether to skip updating your changelog file
default "true" when CI=true, "false" otherwise
--no-skip-changelog Whether to skip updating your changelog file
Expand All @@ -127,39 +124,43 @@ Options:
default "true" when CI=true, "false" otherwise
-cpf, --changelog-prepend-file [string] The file that git-cliff should use for the --prepend flag, defaults to ./CHANGELOG.md. This should be relative to the current working directory.
--skip-commit [skipCommit...] Repeatable, each will be treated as a new entry. A list of SHA1 commit hashes that will be skipped in the changelog.
--github-repo The GitHub repository to use for linking to issues and PRs in the changelog.
--git-host-variant The git host variant. Git-cliff supports 4 hosting websites, GitHub, GitLab, Gitea, and BitBucket. By setting this option you control which api is used by git-cliff. Defaults to "github" for backwards compatibility.
--git-repo The git repository to use for linking to issues and PRs in the changelog.
You can pass the unique string "auto" to automatically set this value as {{org}}/{{name}} as provided from --org and --name
This should be in the format "owner/repo"
You can use the "GITHUB_REPO" environment variable to automatically set this value
--github-token A token to authenticate requests to the GitHub API. This is required when using the "--github-repo" option.
You can use the "GIT_REPO" environment variable to automatically set this value
--git-token A token to authenticate requests to the Git host API. This can be a GitHub, GitLab, Gitea, or BitBucket token. Which is used is determined by "--git-host-variant". This is required when using the "--git-repo" option.
You can also set the one of the following environment variables.
- GITHUB_TOKEN
- GITLAB_TOKEN
- GITEA_TOKEN
- BITBUCKET_TOKEN
- GH_TOKEN
- TOKEN_GITHUB
- TOKEN_GH
The multiple options for the name of the environment are to aim to not conflict with other tooling that use similar tokens in case you want to use a unique
token for release management.
-pt, --push-tag Whether to push the tag to the remote repository.
This will simply execute "git push && git push --tags" so make sure you have configured git for pushing properly beforehand.
-npt, --no-push-tag Whether to push the tag to the remote repository.
This will simply execute "git push && git push --tags" so make sure you have configured git for pushing properly beforehand.
-ghr, --github-release Whether to create a release on GitHub, requires "--push-tag" to be enabled, otherwise there will be no tag to create a release from
For the repository the release is created on the value from "--github-repo" will be used
-ghr, --github-release Note that this is only supported if "--git-host-variant" is set to "github"
Whether to create a release on GitHub, requires "--push-tag" to be enabled, otherwise there will be no tag to create a release from
For the repository the release is created on the value from "--git-repo" will be used
If the changelog section from git-cliff is empty, the release notes will be auto-generated by GitHub.
-nghr, --no-github-release Whether to create a release on GitHub, requires "--push-tag" to be enabled, otherwise there will be no tag to create a release from
For the repository the release is created on the value from "--github-repo" will be used
-nghr, --no-github-release Note that this is only supported if "--git-host-variant" is set to "github"
Whether to create a release on GitHub, requires "--push-tag" to be enabled, otherwise there will be no tag to create a release from
For the repository the release is created on the value from "--git-repo" will be used
If the changelog section from git-cliff is empty, the release notes will be auto-generated by GitHub.
-ghrd, --github-release-draft Whether the release should be a draft
-ghrpr, --github-release-pre-release Whether the release should be a pre-release
-ghrl, --github-release-latest Whether the release should be marked as the latest release, will try to read this value, then the value of --github-release, and then default to false.
Please note that when setting --github-release-pre-release to `true` GitHub will prevent the release to be marked as latest an this option will essentially
be ignored.
-ghrnt, --github-release-name-template [string] A GitHub release name template to use. Defaults to an empty string, which means GitHub will use the tag name as the release name.
-ghrd, --github-release-draft Note that this is only supported if "--git-host-variant" is set to "github"
Whether the release should be a draft
-ghrpr, --github-release-pre-release Note that this is only supported if "--git-host-variant" is set to "github"
Whether the release should be a pre-release
-ghrl, --github-release-latest Note that this is only supported if "--git-host-variant" is set to "github"
Whether the release should be marked as the latest release, will try to read this value, then the value of --github-release, and then default to false. Please note that when setting --github-release-pre-release to `true` GitHub will prevent the release to
be marked as latest an this option will essentially be ignored.
-ghrnt, --github-release-name-template [string] Note that this is only supported if "--git-host-variant" is set to "github"
A GitHub release name template to use. Defaults to an empty string, which means GitHub will use the tag name as the release name.
You can use "{{new-version}}" in your template which will be dynamically replaced with whatever the new version is that will be published.
You can use "{{org}}" in your template, this will be replaced with the org provided through "-o", "--org" or the same value set in your config file.
You can use "{{name}}" in your template, this will be replaced with the name provided through "-n", "--name" or the same value set in your config file.
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is
provided).
You can use "{{full-name}}" in your template, this will be replaced "{{name}}" (when "org" is not provided), or "@{{org}}/{{name}}" (when "org" is provided).
-v, --verbose Whether to print verbose information (default: false)
-h, --help display help for command
```
Expand All @@ -186,8 +187,9 @@ package). It should be named `.cliff-jumperrc`, optionally suffixed with
- `--skip-tag` and `--no-skip-tag` map to `skipTag`
- `--changelog-prepend-file` maps to `changelogPrependFile`
- `--skip-commit` maps to `skipCommit`
- `--github-repo` maps to `githubRepo`
- `--github-token` maps to `githubToken`
- `--git-host-variant` maps to `gitHostVariant`
- `--git-repo` maps to `gitRepo`
- `--git-token` maps to `gitToken`
- `--push-tag` and `--no-push-tag` map to `pushTag`
- `--github-release` and `--no-github-release` map to `githubRelease`
- `--github-release-draft` maps to `githubReleaseDraft`
Expand Down Expand Up @@ -272,8 +274,9 @@ This library has opinionated defaults for its options. These are as follows:
provided), or `@{{org}}/{{name}}` (when `org` is provided).
- `--changelog-prepend-file` will default to `./CHANGELOG.md`.
- `--skip-commit` will default to `[]` (an empty array).
- `--github-repo` will default to `undefined`.
- `--github-token` will default to `undefined`.
- `--git-host-variant` will default to `'github'`.
- `--git-repo` will default to `undefined`.
- `--git-token` will default to `undefined`.
- `--push-tag` will default to `false`. Alternatively you can force this to
false by providing `--no-push-tag`.
- `--github-release` will default to `false`. Alternatively you can force this
Expand Down Expand Up @@ -304,9 +307,9 @@ such as in a CI environment.
This package provides the options `--push-tag` and `--github-release` to
automatically create a release on GitHub using the output from `git-cliff` as
the release notes. In order to use this feature you have to provide
`--github-repo` and `--github-token` (or set their respective environment
variables). Alternatively, if you want to run this step from a GitHub workflow
you can base your step on the following example.
`--git-host-variant=github`, `--git-repo`, and `--git-token` (or set the latter
respective environment variables). Alternatively, if you want to run this step
from a GitHub workflow you can base your step on the following example.
It is very important that if your main branch is protected by branch protection
you have to provide a Personal Access Token (this can be both a classic or a
Expand Down Expand Up @@ -360,7 +363,7 @@ example. Replace the values in between `<>` with your desired values.
name: <package-name>
packagePath: .
pushTag: true
githubRepo: <repo-owner>/<repo-name>
gitRepo: <repo-owner>/<repo-name>
githubRelease: true
githubReleaseLatest: true
```
Expand Down
24 changes: 15 additions & 9 deletions assets/cliff-jumper.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@
},
"default": []
},
"githubRepo": {
"description": "The GitHub repository to use for linking to issues and PRs in the changelog.\n\nYou can pass the unique string \"auto\" to automatically set this value as \"{{org}}/{{name}}\" as provided from \"--org\" and \"--name\". This should be in the format \"owner/repo\". You can use the \"GITHUB_REPO\" environment variable to automatically set this value",
"gitHostVariant": {
"description": "The git host variant. Git-cliff supports 4 hosting websites, GitHub, GitLab, Gitea, and BitBucket. By setting this option you control which api is used by git-cliff. Defaults to \"github\" for backwards compatibility.",
"type": "string",
"enum": ["github", "gitlab", "gitea", "bitbucket"],
"default": "github"
},
"gitRepo": {
"description": "The git repository to use for linking to issues and PRs in the changelog.\nYou can pass the unique string \"auto\" to automatically set this value as {{org}}/{{name}} as provided from --org and --name\nThis should be in the format \"owner/repo\"\nYou can use the \"GIT_REPO\" environment variable to automatically set this value",
"type": "string"
},
"githubToken": {
"description": "A token to authenticate requests to the GitHub API. This is required when using the \"--github-repo\" option.\nYou can also set the one of the following environment variables.\n- GITHUB_TOKEN\n- GH_TOKEN\n- TOKEN_GITHUB\n- TOKEN_GH",
"gitToken": {
"description": "A token to authenticate requests to the Git host API. This can be a GitHub, GitLab, Gitea, or BitBucket token. Which is used is determined by \"--git-host-variant\". This is required when using the \"--git-repo\" option.\nYou can also set the one of the following environment variables.\n- GITHUB_TOKEN\n- GITLAB_TOKEN\n- GITEA_TOKEN\n- BITBUCKET_TOKEN\n- GH_TOKEN",
"type": "string"
},
"install": {
Expand All @@ -87,27 +93,27 @@
"default": false
},
"githubRelease": {
"description": "Whether to create a release on GitHub, requires \"pushTag\" to be enabled, otherwise there will be no tag to create a release from\nFor the repository the release is created on the value from \"githubRepo\" will be used\nIf the changelog section from git-cliff is empty, the release notes will be auto-generated by GitHub.",
"description": "Note that this is only supported if \"--git-host-variant\" is set to \"github\"\nWhether to create a release on GitHub, requires \"pushTag\" to be enabled, otherwise there will be no tag to create a release from\nFor the repository the release is created on the value from \"githubRepo\" will be used\nIf the changelog section from git-cliff is empty, the release notes will be auto-generated by GitHub.",
"type": "boolean",
"default": false
},
"githubReleaseDraft": {
"description": "Whether the release should be a draft",
"description": "Note that this is only supported if \"--git-host-variant\" is set to \"github\"\nWhether the release should be a draft",
"type": "boolean",
"default": false
},
"githubReleasePrerelease": {
"description": "Whether the release should be a pre-release",
"description": "Note that this is only supported if \"--git-host-variant\" is set to \"github\"\nWhether the release should be a pre-release",
"type": "boolean",
"default": false
},
"githubReleaseLatest": {
"description": "Whether the release should be marked as the latest release, will try to read this value, then the value of --github-release, and then default to false. Please note that when setting --github-release-pre-release to `true` GitHub will prevent the release to be marked as latest an this option will essentially be ignored..",
"description": "Note that this is only supported if \"--git-host-variant\" is set to \"github\"\nWhether the release should be marked as the latest release, will try to read this value, then the value of --github-release, and then default to false. Please note that when setting --github-release-pre-release to `true` GitHub will prevent the release to be marked as latest an this option will essentially be ignored..",
"type": "boolean",
"default": false
},
"githubReleaseNameTemplate": {
"description": "A custom release name template to use.\n\nYou can use \"{{new-version}}\" in your template which will be dynamically replaced with whatever the new version is that will be published.\n\nYou can use \"{{name}}\" in your template, this will be replaced with the name provided through \"-n\", \"--name\" or the same value set in your config file.\n\nYou can use \"{{full-name}}\" in your template, this will be replaced \"{{name}}\" (when \"org\" is not provided), or \"@{{org}}/{{name}}\" (when \"org\" is provided).",
"description": "Note that this is only supported if \"--git-host-variant\" is set to \"github\"\nA custom release name template to use.\n\nYou can use \"{{new-version}}\" in your template which will be dynamically replaced with whatever the new version is that will be published.\n\nYou can use \"{{name}}\" in your template, this will be replaced with the name provided through \"-n\", \"--name\" or the same value set in your config file.\n\nYou can use \"{{full-name}}\" in your template, this will be replaced \"{{name}}\" (when \"org\" is not provided), or \"@{{org}}/{{name}}\" (when \"org\" is provided).",
"type": "string"
},
"verbose": {
Expand Down
Loading

0 comments on commit a4b30d0

Please sign in to comment.