Attach job artifacts as assets when creating release through .gitlab-ci.yml
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
Now that we can attach asset links to releases created through .gitlab-ci.yml (#271454 (closed)), it would be neat if the same syntax could be used to attach job artifacts as assets to the release.
Example .gitlab-ci.yml syntax
stages:
- build
- release
build:
stage: build
script:
- echo "This is a job artifact" > my_compiled_binary.bin
artifacts:
paths:
- my_compiled_binary.bin
create_release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
script:
- echo "Creating a new release for tag $CI_COMMIT_TAG..."
release:
name: Version $CI_COMMIT_TAG
tag_name: $CI_COMMIT_TAG
ref: $CI_DEFAULT_BRANCH
assets:
links:
- name: "The compiled binary"
artifact: my_compiled_binary.bin
Technical proposal
When an release:assets:links:artifact key is provided (like in the example above), upload the specified artifact to the Generic Package Registry, using a package name that matches the tag name of the release.
Alternatively, we could upload the file to the project using the project upload API.
Workarounds
Currently, it's up to developers to manually upload job artifacts to some kind of publicly accessible storage and then associate the URL to the release.
For example, this is what the semantic-release/gitlab plugin does; it uses the project upload API to upload artifacts and then links to them when creating a release.
Here's another example that accomplishes this all through a .gitlab-ci.yml file.