Skip to content
Snippets Groups Projects
Unverified Commit 96afb017 authored by Stéphane Veyret's avatar Stéphane Veyret
Browse files

Publish links to the release binaries

Closes #1411
parent dd6a4f0d
No related branches found
No related tags found
No related merge requests found
import json
import os
import urllib.request
from projectapi import ProjectApi
class ReleaseLinks(ProjectApi):
'''
Release links API.
'''
def __init__(self):
ProjectApi.__init__(self, '/releases/{}/assets/links'.format(os.environ['CI_COMMIT_TAG']))
def create_artifact(self, artifact):
'''
Create the link for the given artifact.
:param artifact: The artifact data.
:type artifact: dict
'''
send_data = {
'name': '{} {} - {}'.format(artifact['category'], artifact['arch'], artifact['type']),
'filepath': '/binaries/{}'.format(artifact['name']),
'url': artifact['url']
}
send_data_serialized = json.dumps(send_data).encode('utf-8')
request = self.build_request(data=send_data_serialized, method='POST')
request.add_header('Content-Type', 'application/json')
urllib.request.urlopen(request)
......@@ -6,6 +6,7 @@ import os
from binartifact import BinArtifact
from job import Job
from placeholder import PlaceHolder
from releaselinks import ReleaseLinks
from releasenote import ReleaseNote
from releasewikipage import ReleaseWikiPage
from sourceartifact import SourceArtifact
......@@ -48,9 +49,11 @@ class Releaser:
releaseNote = ReleaseNote()
current_message = releaseNote.get_message()
artifacts_list = []
binArtifacts = self._get_bin_artifacts()
releaseLinks = ReleaseLinks()
# Get releases
artifacts_list += self._get_bin_artifacts()
artifacts_list += binArtifacts
artifacts_list.sort()
artifacts_list += list(map(lambda e: SourceArtifact(e), self.source_ext))
......@@ -65,6 +68,10 @@ class Releaser:
})
releaseNote.send_note(title_line + note)
# Publish binaries as links
for binArtifact in binArtifacts:
releaseLinks.create_artifact(binArtifact.to_dict())
print('Pre-release published')
def publish_release(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment