Package: gitlab-release
This Python utility is used to upload specific release
files from a gitlab-ci build to theReleases/Tagspage on gitlab.This allows a file or (generated) zip with arbitrary structure to be added to
a release for convenient download, as opposed to the artifacts which are
somewhat constrained to always be zipped with a folder structure taken
directly from the filesystem.By default the tool will now upload to the generic package registry for the project.
If you’d prefer to attach to the tag instead registry use can be disabled with--no-registryIt can be used in a.gitlab-ci.ymlstage like:release:
  stage: release
  image: python3
  script:
    - pip3 install gitlab-release
    - gitlab-release *.zip
  only:
    - tagsOr if you want to bundle a bunch of files into a zip and upload thatrelease:
  stage: release
  image: python3
  script:
    - pip3 install gitlab-release
    - gitlab-release --zip "release-${CI_COMMIT_TAG}.zip" *
  only:
    - tagsOr if you just want links to your job artifacts added to the release:release:
  stage: release
  image: python3
  script:
    - pip3 install gitlab-release
    - gitlab-release --link-artifact *.zip
  artifacts:
    paths:
      # Must include files passed to gitlab_release
      - ./*.zip
  only:
    - tagsOn any tagged release the files specified on the command line will then be
available on theTagstab of your project.gitlab-releaserequires Python 3.Setting up the required private tokenThis tool requires you to put a copy of aPRIVATE_TOKENin a
secret CI variable for the project to give it access to post the files
back to the project.For this create a newPersonal Access Tokenathttps://gitlab.com/profile/personal_access_tokensand use that. (You
could also use your personal token fromhttps://gitlab.com/profile/account, but this isnot recommended.)Make sure you enableAccess your APIwhen creating the token. Thenameof the token is just for you to remeber what it’s for, it wont
affeect operation.Add it to a secret variable calledPRIVATE_TOKENfor the project you’re
building athttps://gitlab.com/<user>/<project>/settings/ci_cd>.UsageNote: Version 4 and above use the Gitlab Releases api to include files as release
assets by default, whereas version 3 and older added the artifacts as a dot-point
list in the tag description.
The older behavior can still be used with the--link-in-descflag. This flag is
also automatically enabled if--link-prefixis set.usage: gitlab-release [-h] [--server SERVER] [--project_id PROJECT_ID]
                  [--release_tag RELEASE_TAG] [--timeout TIMEOUT] [--ignore_cert]
                  [--job-id JOB_ID] [--artifact-zip] [--zip ZIP]
                  [--description DESCRIPTION] [--link-prefix LINK_PREFIX] [--link-in-desc]
                  [--link-type LINK_TYPE] [--link-artifact]
                  [--no-registry] [--registry-vers REGISTRY_VERS]
                  [--registry-package-name REGISTRY_PACKAGE_NAME]
                  [--private-token PRIVATE_TOKEN] [--create-tag]
                  [files ...]positional argumentsfilesfile names and/or globs of files to uploadoptional arguments--serverSERVERurl of gitlab server (default: $CI_PROJECT_URL)--project_idPROJECT_IDUnique id of project, available in Project Settings/General (default: $CI_PROJECT_ID)--release_tagRELEASE_TAGTag to upload files against (default: $CI_COMMIT_TAG)--timeoutTIMEOUTTimeout for http requests--ignore_certIgnore ssl certificate failures--job-idJOB_IDOverride the job number used for artifacts--artifact-zipLink artifacts zip from current job--zipZIPAdd all files to provided zip name and upload that--descriptionDESCRIPTIONRelease description to be put in front of the files--link-prefixLINK_PREFIXPrefix text added in front of each file link, eg “* “ to create a list--link-in-descAdd the artifact links to the description. Uses release asset otherwise--link-typeLINK_TYPEThe type of the link: other, runbook, image, package--link-artifactLink files as artifact from the current job--no-registryDon’t upload artifacts to generic registry, attach to tag description instead--registry-versREGISTRY_VERSUpload artifacts to generic registry with provided version (default tag version numbers)--registry-package-nameREGISTRY_PACKAGE_NAMEUpload artifacts to generic registry with provided version (default project name)--private-tokenPRIVATE_TOKENlogin token with permissions to commit to repo--create-tagcreate the tag if it doesn’t already exist-h,--helpshow this help message and exit