Making a binary release via CI/CD

Hello all!
I want to automatically release binary of my app whenever I make a tagged commit. This is what I tried:

stages:
    - build
    - release

build:
    stage: build
    image: rust:latest
    script: 
        - cargo build --release
        - mv target/release/quack target/release/quack-$CI_COMMIT_TAG
        - echo "$CI_JOB_ID" > CI_JOB_ID.txt
    cache:
        paths:
            - target/release/
    artifacts:
        paths:
            - target/release/quack-$CI_COMMIT_TAG
            - CI_JOB_ID.txt
    rules:
        - if: $CI_COMMIT_TAG

release:
    stage: release
    image: registry.gitlab.com/gitlab-org/release-cli:latest
    rules:
        - if: $CI_COMMIT_TAG
    script:
        - echo 'Running release'
    release:
        name: 'quack-$CI_COMMIT_TAG'
        description: '$CI_COMMIT_TAG'
        tag_name: $CI_COMMIT_TAG
        assets:
            links:
                - name: 'quack-$CI_COMMIT_TAG'
                - url: 'https://gitlab.com/J-Arun-Mani/quack/-/jobs/`cat CI_JOB_ID.txt`/artifacts/browse/target/release/'

Whenever I make tagged commit, the build job passes successfully but the release job fails with the follow error:
API Error Response status_code: 400 message: Validation failed: Links url can't be blank, Links url must be a valid URL, Links name can't be blank" version=0.9.0

So I kindly require help here. What am I doing wrong? Is the way I make the releases good or can it be improved?

Thanks for reading!

I solved it.
For future readers, you would be better off with using GitLab’s excellent Package Registry for deploying packages. This is my final CI YML file for your reference.

stages:
    - build
    - upload
    - release

variables:
    PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/quack/${CI_COMMIT_TAG}"

build:
    stage: build
    image: rust:latest
    script: 
        - cargo build --release
        - mkdir bin
        - mv target/release/quack bin/quack-${CI_COMMIT_TAG}
    cache:
        paths:
            - target/release/
    artifacts:
        paths:
            - bin
    rules:
        - if: $CI_COMMIT_TAG

upload:
    stage: upload
    image: curlimages/curl:latest
    rules:
        - if: $CI_COMMIT_TAG
    script:
        - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/quack-${CI_COMMIT_TAG} ${PACKAGE_REGISTRY_URL}/quack-${CI_COMMIT_TAG}'


release:
    stage: release
    image: registry.gitlab.com/gitlab-org/release-cli:latest
    rules:
        - if: $CI_COMMIT_TAG
    script:
        - 'release-cli create --name "quack-$CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG --assets-link "{\"name\":\"quack-${CI_COMMIT_TAG}\", \"url\":\"${PACKAGE_REGISTRY_URL}/quack-${CI_COMMIT_TAG}\"}"'
1 Like