Recipe to automate adding release info to an git tag

is there a recipe to achieve the following:

  1. Create Changelog for tag✅
  2. Tag the commit✅
  3. push + start pipeline :white_check_mark:
  4. build artifacts :white_check_mark:
  5. add artifact and parts of the changelog to the tag and convert it into a release without having an users api key in ci :question:

I found the release api, but the fact, that i have to put an api key of a user into an env var scares me, as gitlab knows who triggered the build and alteady provides other tokens.

So basicly we have that:

curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" \
     --data '{ "name": "New release", "tag_name": "v0.3", "description": "Super nice release", "milestones": ["v1.0", "v1.0-rc"], "assets": { "links": [{ "name": "hoge", "url": "https://google.com", "filepath": "/binaries/linux-amd64" }] } }' \
     --request POST https://gitlab.example.com/api/v4/projects/24/releases

The problem is, that i would expect the private token to be one of the tokens provided by the CI Env.

What might work is to add a future release with our local release preparation workflow and then push the tag to really do the release.
But this might break the asset creation i mentioned earlier, as i would expect to build the assets during CI

Another thing which does not seem possible is to create a release, which is a future release via the UI.

@kaystrobach - thanks for experimenting with our Releases API!

Have you taken a look at our tool for generating Releases? We are still developing it to include adding artifacts via CI. Although, the JOB TOKEN can be used in place of a PAT.

On the future release concept, if you associate a future milestone to the release tag, it will populate a badge on the Release that states it is “Upcoming”. The released_at attribute can also be set in the future.

Hope this helps!

2 Likes