Skip to content

Latest commit

 

History

History
71 lines (45 loc) · 3.55 KB

README.md

File metadata and controls

71 lines (45 loc) · 3.55 KB

publish-gitlab-release

publish-gitlab-release is a command-line tool designed to simplify the process of creating a Git tag and a corresponding GitLab release.

The tool automates the collection of commits made since the last tag, along with all associated merge requests and their linked issues. It also adds comments to merge requests and their linked issues, providing better visibility into the changes included in each release. Additionally, it generates a basic changelog based on raw commit messages.

Unlike some other tools like semantic release, publish-gitlab-release doesn't enforce a specific versioning scheme. It is flexible and works exclusively with GitLab via their API.

🌟 Features

  • Create a Git tag and publish a GitLab release with a single command.
  • Automatically add comments to Merge Requests and their linked issues for better visibility.
  • Generate a basic changelog for the GitLab release.

🧰 Requirements

  • Node 18 (or higher)
  • Gitlab
  • Your latest Git tag is always the tag since last release

🚀 Usage

To use publish-gitlab-release, invoke it using npx with the desired version number:

npx publish-gitlab-release -v "1.2.3" [options]

🛠️ Options

-v, --version (required)

Specifies the version name to be used for the Git tag and the Gitlab release. This option is required and should be used to define the version of the release.

-t, --token (required)

Gitlab API token. Unfortunately the CI_JOB_TOKEN has not enough rights, so that a personal access token or a project access token is required. Go to your project settings and then Access Tokens. Create a token with the scope api and add it to variables under the section CI/CD.

--ref (optional)

Git ref that should be tagged. If provided, the specified Git ref will be tagged with the version defined using the -v option. If not provided, the tool will use the given environment variable CI_COMMIT_SHA from Gitlab pipelines.

--host (optional)

Gitlab URI. Use this option to specify a custom Gitlab host URL. Within Gitlab pipelines the tool will use the environment variables CI_SERVER_PROTOCOL, CI_SERVER_HOST and CI_SERVER_PORT. Fallback is gitlab.com.

--project (optional)

Gitlab project ID. Use this option to specify the ID of the Gitlab project where the release should be published. If not provided, the tool will use the given variable CI_PROJECT_ID from Gitlab pipelines.

💻 CI example

publish-release:
  image: node:20.4.0
  script:
    - npx publish-gitlab-release --version "$VERSION" --token "$GITLAB_RELEASE_TOKEN"
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TAG == null'

Gitlab comment on a issue referring to a Gitlab release Gitlab comment on a merge request referring to a Gitlab release

👏 Credits