2021-07-10 19:11:37 +02:00
# GitLab
## API Token
GoReleaser requires an API token with the `api` scope selected to deploy the artifacts to GitLab.
2022-08-28 21:15:24 +02:00
That token can either be a Personal, or a Project one.
2021-07-10 19:11:37 +02:00
This token should be added to the environment variables as `GITLAB_TOKEN` .
Alternatively, you can provide the GitLab token in a file.
2021-12-23 02:52:01 +02:00
GoReleaser will check `~/.config/goreleaser/gitlab_token` by default, but you can change that in the `.goreleaser.yaml` file:
2021-07-10 19:11:37 +02:00
```yaml
2021-12-23 02:52:01 +02:00
# .goreleaser.yaml
2021-07-10 19:11:37 +02:00
env_files:
gitlab_token: ~/.path/to/my/gitlab_token
```
2022-03-19 22:49:55 +02:00
!!! warning
2023-07-20 15:16:30 +02:00
2022-03-19 22:49:55 +02:00
If you use a project access token, make sure to set `use_package_registry`
to `true` as well, otherwise it might not work.
2022-11-04 21:04:19 +02:00
!!! warning
2023-07-20 15:16:30 +02:00
2022-11-04 21:04:19 +02:00
If you are using a [protected variable ](https://docs.gitlab.com/ee/ci/variables/#protected-cicd-variables )
to store any of the values needed by goreleaser, ensure that you are protecting the tags as CI jobs in
Gitlab only may access protected variables if the job is run for protected refs
([branches](https://docs.gitlab.com/ee/user/project/protected_branches.html),
[tags ](https://docs.gitlab.com/ee/user/project/protected_tags.html )).
2021-07-10 19:11:37 +02:00
## GitLab Enterprise or private hosted
2021-09-09 03:42:13 +02:00
You can use GoReleaser with GitLab Enterprise by providing its URLs in the
2022-08-28 21:15:24 +02:00
`.goreleaser.yml` configuration file. This takes a normal string, or a template value.
2021-07-10 19:11:37 +02:00
```yaml
# .goreleaser.yml
gitlab_urls:
api: https://gitlab.mycompany.com/api/v4/
download: https://gitlab.company.com
2022-08-16 05:39:13 +02:00
2021-07-10 19:11:37 +02:00
# set to true if you use a self-signed certificate
skip_tls_verify: false
2022-08-16 05:39:13 +02:00
2022-01-07 03:11:11 +02:00
# set to true if you want to upload to the Package Registry rather than attachments
# Only works with GitLab 13.5+
use_package_registry: false
2022-08-16 05:39:13 +02:00
2022-09-11 21:54:51 +02:00
# Set this if you set GITLAB_TOKEN to the value of CI_JOB_TOKEN.
2022-08-16 05:39:13 +02:00
use_job_token: true
2021-07-10 19:11:37 +02:00
```
If none are set, they default to GitLab's public URLs.
!!! note
2023-07-20 15:16:30 +02:00
2021-07-10 19:11:37 +02:00
Releasing to a private-hosted GitLab CE will only work for version `v12.9+` , due to dependencies
on [release ](https://docs.gitlab.com/ee/user/project/releases/index.html ) functionality
and [direct asset linking ](https://docs.gitlab.com/ee/user/project/releases/index.html#permanent-links-to-release-assets ).
2022-01-07 03:11:11 +02:00
## Generic Package Registry
GitLab introduced the [Generic Package Registry ](https://docs.gitlab.com/ee/user/packages/package_registry/index.html ) in Gitlab 13.5.
2023-07-20 15:16:30 +02:00
Normally, `goreleaser` uploads release files as "attachments", which may have [administrative limits ](https://docs.gitlab.com/ee/user/admin_area/settings/account_and_limit_settings.html ).
Notably, hosted GitLab instances have a 10MB attachment limit, which cannot be changed.
2022-01-07 03:11:11 +02:00
2023-07-20 15:16:30 +02:00
Uploading to the Generic Package Registry does not have this restriction.
To use it instead, set `use_package_registry` to `true` .
2022-01-07 03:11:11 +02:00
```yaml
# .goreleaser.yml
gitlab_urls:
use_package_registry: true
```
2021-07-10 19:11:37 +02:00
## Example release
2022-06-11 04:04:16 +02:00
Here's an example of what the release might look like:
2021-07-10 19:11:37 +02:00
< a href = "https://gitlab.com/goreleaser/example/-/releases" >
< figure >
< img src = "https://img.carlosbecker.dev/goreleaser-gitlab.png" / >
< figcaption > Example release on GitLab.< / figcaption >
< / figure >
< / a >