Commit e440b262 authored by Éloïs's avatar Éloïs

Merge branch 'feature/perm-links' into dev

parents 42e65cac 3f6fc9a9
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment