Skip to content
Snippets Groups Projects
Unverified Commit 54b6c388 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': artifact['name'],
'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 ...@@ -6,6 +6,7 @@ import os
from binartifact import BinArtifact from binartifact import BinArtifact
from job import Job from job import Job
from placeholder import PlaceHolder from placeholder import PlaceHolder
from releaselinks import ReleaseLinks
from releasenote import ReleaseNote from releasenote import ReleaseNote
from releasewikipage import ReleaseWikiPage from releasewikipage import ReleaseWikiPage
from sourceartifact import SourceArtifact from sourceartifact import SourceArtifact
...@@ -45,12 +46,18 @@ class Releaser: ...@@ -45,12 +46,18 @@ class Releaser:
''' '''
Main job to publish a pre-release. Main job to publish a pre-release.
''' '''
releaseLinks = ReleaseLinks()
releaseNote = ReleaseNote() releaseNote = ReleaseNote()
current_message = releaseNote.get_message() current_message = releaseNote.get_message()
artifacts_list = [] artifacts_list = []
binArtifacts = self._get_bin_artifacts()
# Publish binaries as links
for binArtifact in binArtifacts:
releaseLinks.create_artifact(binArtifact.to_dict())
# Get releases # Get releases
artifacts_list += self._get_bin_artifacts() artifacts_list += binArtifacts
artifacts_list.sort() artifacts_list.sort()
artifacts_list += list(map(lambda e: SourceArtifact(e), self.source_ext)) artifacts_list += list(map(lambda e: SourceArtifact(e), self.source_ext))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment