So I'm trying my hand on goreleaser for a personal project on gitlab (private repo) and I'm blocked with this error during build:
⨯ release failed after 31s error=scm releases: failed to publish artifacts: GET https://gitlab.com/api/v4/projects/night-gold/PROJECT/releases/0.0.10: 401 {message: 401 Unauthorized}
As you can see I'm on gitlab.com, so I did not set the gitlab_urls in my goreleaser.yml as I should be using the defaults.
My gitlabci.yml:
stages:
- release
release:
stage: release
image:
name: goreleaser/goreleaser
entrypoint: ['']
only:
- tags
variables:
# Disable shallow cloning so that goreleaser can diff between tags to
# generate a changelog.
GIT_DEPTH: 0
GITLAB_TOKEN: $GITLAB_TOKEN
script:
- goreleaser release --clean
My goreleaser.yml:
project_name: PROJECTNAME
version: 1
before:
hooks:
- go mod tidy
builds:
- env: [CGO_ENABLED=0]
goos:
- linux
goarch:
- amd64
- arm64
archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
I generated the token with api permission as it's written in the doc, but it's not working, to be even more precise, the token has maintainer role, I tested to see if it does something.
What am I missing here?
EDIT:
I've currently find something, the url used by goreleaser is something like this:
https://gitlab.com/api/v4/projects/User/Project_Name/releases/0.0.11
And after multiple tests I figured out that this type of url does not work... the gitlab.com/api/ takes the projects ID and not the User/Project_Name, in my case, it's not really a 401 I get a 404 because it's targeting a non existant URL...
Still searching if there is a solution for that.