5 Commits
v1.3 ... v1.5

Author SHA1 Message Date
af6b41a0ae fix ci script 2019-05-30 14:59:02 +02:00
26a8759919 some fixes 2019-05-30 14:43:07 +02:00
62c3f0e00f adjust info file 2019-05-30 14:36:50 +02:00
dff4090678 add ci script 2019-05-30 14:35:35 +02:00
0c8e75e82e interpreter and x flag 2019-05-30 14:13:11 +02:00
4 changed files with 54 additions and 14 deletions

28
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,28 @@
stages:
- check
- release
build:
stage: check
image: registry.gitlab.com/wolutator/base-build-env:latest
tags:
- hottis
- linux
- docker
script:
- for I in *.py; do python -m py_compile $I; done
- for I in *.py; do python -m pycodestyle --max-line-length=120 $I; done
release:
stage: release
image: registry.gitlab.com/wolutator/base-build-env
tags:
- hottis
- linux
- docker
only:
- master
script:
- python gitlabreleaseuploader.py -p $PRIVATE_TOKEN -i $CI_PROJECT_ID -u $CI_PROJECT_URL
-f gitlabreleaseuploader.py -F info.json -T $CI_COMMIT_REF_NAME

20
gitlabreleaseuploader.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/python
import requests import requests
import json import json
import argparse import argparse
@ -72,7 +74,8 @@ if (releaseInfoFilename):
if 'releaseTagTarget' in releaseInfo: if 'releaseTagTarget' in releaseInfo:
releaseTagTarget = releaseInfo['releaseTagTarget'] releaseTagTarget = releaseInfo['releaseTagTarget']
if 'createReleaseTag' in releaseInfo: if 'createReleaseTag' in releaseInfo:
createReleaseTag = (releaseInfo['createReleaseTag'] in ('true', 'True')) createReleaseTag = (releaseInfo['createReleaseTag'] in
('true', 'True'))
if 'description' in releaseInfo: if 'description' in releaseInfo:
releaseDescription = releaseInfo['description'] releaseDescription = releaseInfo['description']
@ -107,14 +110,10 @@ uploadResultJson = json.loads(uploadResult.text)
# --- create release tag # --- create release tag
if createReleaseTag: if createReleaseTag:
createReleaseTagUrl = "%s/api/v4//projects/%s/repository/tags" % (instanceUrl, projectId) createReleaseTagUrl = ("%s/api/v4//projects/%s/repository/tags" %
headers = {"PRIVATE-TOKEN": privateToken, "Content-Type": "application/json"} (instanceUrl, projectId))
headers = {"PRIVATE-TOKEN": privateToken,
# id (required) - The ID or URL-encoded path of the project owned by the authenticated user "Content-Type": "application/json"}
# tag_name (required) - The name of a tag
# ref (required) - Create tag using commit SHA, another tag name, or branch name.
# message (optional) - Creates annotated tag.
# release_description (optional) - Add release notes to the git tag and store it in the GitLab database.
payloadCreateReleaseTag = { payloadCreateReleaseTag = {
"tag_name": releaseTag, "tag_name": releaseTag,
@ -123,7 +122,8 @@ if createReleaseTag:
"message": "Tag for release %s" % releaseName "message": "Tag for release %s" % releaseName
} }
createReleaseTagResult = requests.post(createReleaseTagUrl, headers=headers, createReleaseTagResult = requests.post(createReleaseTagUrl,
headers=headers,
data=json.dumps(payloadCreateReleaseTag)) data=json.dumps(payloadCreateReleaseTag))
if createReleaseTagResult.status_code != 201: if createReleaseTagResult.status_code != 201:

View File

@ -1,7 +1,7 @@
{ {
"releaseTag": "v1.3", "releaseTag": "v1.5",
"createReleaseTag": "true", "createReleaseTag": "true",
"releaseName": "Fourth release of the uploader", "releaseName": "Sixth release of the uploader",
"description": "Disable forgotten debug output" "description": "Now with CI script and automatic release upload (he, eat your own dogfood)"
} }

12
readme.md Normal file
View File

@ -0,0 +1,12 @@
Release Uploader for Gitlab
===========================
Creating releases on Gitlab seems to work only via the REST API.
This Python script handles the upload of a release file, the creation of
the required release tag in the repository and the creation of the actual
release referring to both the tag and the file.
It supports commandline options and an input file, adjusted to be used in
Gitlab CI scripts.