Making a binary release via CI/CD

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