Automatically build and release binaries

,

How to automatically build and upload files to release

I’ve been searching for this and found nothing. Tried many different things and nothing works. Sometimes the pipelines fail, sometimes they succeed but no binaries are attached to the release.

This is what i’ve got. I’ve been trying it out on an unimportant repo and building a binary just for linux. In theory it should create a release and add a binary to it, but it fails:

stages:
  - build
  - release

build:
  stage: build
  image: rust:latest
  script:
    - rustup toolchain add nightly
    - cargo +nightly build --release
  artifacts:
    paths:
      - target/release/jector
  
  only:
    - tags

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  script:
    - >
      release-cli create --name "$CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG
      --assets-link "jector::target/release/jector"
  only:
    - tags

I’ve done this for a friend with github and it was rather straightforward, but I can’t for the life of me how to do it with gitlab CI/CD.
I will need to also add a windows and mac binary for the important repo, so if you could also help me with that it would be awesome. But if not I’ll try to figure it out myself.

Many thanks!

The assets links must be a JSON, you can read about required format and more details here