Skip to main content

Utility for use in gitlab ci to upload files (from build) to the current projects release (tag)

Project description

This python utility is used to upload specific release files from a gitlab-ci build to the tag release page 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.

It can be used in a gitlab-ci.yml stage like:

release:
  stage: release
  image: python3
  script:
    - pip3 install gitlab_release
    - python3 -m gitlab_release "$PRIVATE_TOKEN" *.zip
  only:
    - tags

Or if you want to bundle a bunch of files into a zip and upload that

release:
  stage: release
  image: python3
  script:
    - pip3 install gitlab_release
    - python3 -m gitlab_release --zip "release-${CI_COMMIT_TAG}.zip" "$PRIVATE_TOKEN" *
  only:
    - tags

This tool requires you to put a copy of a PRIVATE_TOKEN in a secret CI variable for the project to give it access to post the files back to the project

You can use your personal token from https://gitlab.com/profile/account

Or better, create a new Personal Access Token for this and use that: https://gitlab.com/profile/personal_access_tokens

Make sure you enable API access when creating the token. The label you use is just for you to remeber what it’s for, it wont affeect operation.

Add it to a secret variable called PRIVATE_TOKEN for the project you’re building at https://gitlab.com/<user>/<project>/settings/ci_cd

On any tagged release the files specified in the glob will then be availble on the Tags tab of your project.

Usage

usage: gitlab_release [-h] [--server SERVER] [--project_id PROJECT_ID]
                     [--release_tag RELEASE_TAG] [--timeout TIMEOUT]
                     [--ignore_cert] [--zip ZIP]
                     [--description DESCRIPTION]
                     private_token files [files ...]

positional arguments

private_token

login token with permissions to commit to repo

files

file names and/or globs of files to upload

optional arguments

–server SERVER

url of gitlab server or $CI_PROJECT_URL

–project_id PROJECT_ID

Unique id of project, available in Project Settings/General or $CI_PROJECT_ID

–release_tag RELEASE_TAG

Tag to upload files against or $CI_BUILD_TAG

–timeout TIMEOUT

Timeout for http requests

–ignore_cert

Ignore ssl certificate failures

–zip ZIP

Add all globbed files to provided zip name and upload that

–description DESCRIPTION

Extra text to add to the release description

-h, –help

show this help message and exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gitlab_release-2.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_release-2.5-py3-none-any.whl.

File metadata

  • Download URL: gitlab_release-2.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for gitlab_release-2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4640f29739356ed021011627d72ed39b4f6d801a3b82de27582fc1797f2e5520
MD5 46722f7e5fbbe5177c90b26ab3c4b5a0
BLAKE2b-256 2cc656c8e198ab54ddcc3f43cf2d3b44abcd02f3a54b73e06f2bb9c16b9a8753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page