Hi Nico,
I have similar situation 
The way how I do it is the following:
I have a build
job that compiles code and creates an executable. I assume you have the same / similar. You can save this artifact using the artifacts
keyword, e.g.
build:
stage: build
script:
- echo "I am building my code here and it produces a .hex in out/somefile.hex"
artifacts:
paths:
- out/*.hex
Now, the thing is - artifacts don’t last forever. It’s a good habit instead of just linking the artifact to Release, upload it to Package registry. There is a Generic one, so you can put there whatever you want.
So, the next thing I do before I create a release (or paralel to it), I upload those artifacts to package registry (reference):
upload package:
stage: package
image: curlimages/curl:latest
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file out/somefile.hex "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/somefile/0.0.1/somefile.hex"'
only:
- main
Normally, your artifacts will automatically be downloaded from previous stages, so you don’t need to do anything additionally about it:
By default, jobs in later stages automatically download all the artifacts created by jobs in earlier stages. You can control artifact download behavior in jobs with dependencies
.
Then, you have a release job. You can do this in a few ways, but let’s say you use release-cli - it can tag your branch and create a release with links to your packages:
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- release-cli create --name release-branch-$CI_JOB_ID --description "Some description" --tag-name 0.0.1 --assets-link '{"name":"Binary","url":"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/somefile/0.0.1/somefile.hex","link_type":"package"}'
only:
- main
To be honest, I never tried to link packages directly with CLI, but according to the docs it should work. Also, you don’t need to use it in script
like I did in example, you can also specify some fields directly in yaml… have a look here.
If you don’t want to do it with release-cli, then you can also do it directly with GitLab API, e.g. using curl
. But in that case you have to create release first and then add assets link afterwards - have a look at Releases API docs and Releases Links API docs.
Now, it’s up to you to decide how you version your binaries, how to pass in the that version, description, certificates (if running on premise), etc… but the general idea is here.
P.S. I didn’t test any of the jobs above, use it just as a reference 