diff --git a/README.md b/README.md index ccedc17..94ce5f4 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ npx publish-gitlab-release -v "1.2.3" [options] 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` _(optional)_ +#### `-t, --token` _(required)_ -Gitlab API token. If provided, the tool will use this token to authenticate with Gitlab when creating the release. If not provided, the tool will attempt to use the environment variable `CI_JOB_TOKEN` within Gitlab pipelines. +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_. #### `--ref` _(optional)_ diff --git a/package.json b/package.json index 3d074f8..3a110b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "publish-gitlab-release", - "version": "0.0.4", + "version": "0.0.5", "description": "publish-gitlab-release is a command-line tool that automates the process of creating GitLab releases, including generating changelogs, adding comments to merge requests and linked issues, all while providing flexibility in versioning schemes.", "license": "MIT", "repository": "https://github.com/jase88/publish-gitlab-release", diff --git a/src/create-context-from-arguments.ts b/src/create-context-from-arguments.ts index 3ee81d5..04c995a 100644 --- a/src/create-context-from-arguments.ts +++ b/src/create-context-from-arguments.ts @@ -37,7 +37,6 @@ export function createContextFromArguments(): Context { CI_SERVER_PROTOCOL, CI_SERVER_HOST, CI_SERVER_PORT, - CI_JOB_TOKEN, CI_COMMIT_SHA, } = env; @@ -84,7 +83,7 @@ Description: Options: -v, --version Specifies the version name to be used for the Git tag and the Gitlab release. - -t, --token (Optional) Gitlab API token. If not provided, the tool will attempt to use the environment variable CI_JOB_TOKEN within Gitlab pipelines. + -t, --token Gitlab API token. Personal or project access token. --ref (Optional) Git ref that should be tagged. If not provided, the tool will use the given environment variable CI_COMMIT_SHA from Gitlab pipelines. --host (Optional) Gitlab URI. If not specified, the tool will default to gitlab.com. --project (Optional) Gitlab project ID. If not specified, the tool will use the given variable CI_PROJECT_ID from Gitlab pipelines. @@ -98,12 +97,17 @@ Description: ? `${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}` : 'gitlab.com'; const projectId = Number.parseInt(gitlabProjectId || CI_PROJECT_ID, 10); - const token = gitlabToken || CI_JOB_TOKEN; const reference = gitReference || CI_COMMIT_SHA; - validateArguments({ version, token, projectId, ref: reference, host }); + validateArguments({ + version, + token: gitlabToken, + projectId, + ref: reference, + host, + }); - const api = new Gitlab({ host, token }); + const api = new Gitlab({ host, token: gitlabToken }); return { api, host, projectId, version, reference }; }