forked from rez0n/actions-github-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.py
executable file
·43 lines (37 loc) · 1.16 KB
/
entrypoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
from github import Github
import os
# Settings
wanted_release = os.getenv('type')
repository = os.getenv('repository')
token = os.getenv('token', None)
# Init class
G = Github(token)
repo = G.get_repo(repository)
releases = repo.get_releases()
# Output formatting function
def output(release):
print('::set-output name=release::{}'.format(release.tag_name))
print('::set-output name=release_id::{}'.format(release.id))
assets = release.get_assets()
dl_url = assets[0].browser_download_url if assets.totalCount > 0 else '""'
print('::set-output name=browser_download_url::{}'.format(dl_url))
# Releases parsing
for release in releases:
if wanted_release == 'stable':
if release.prerelease == 0 and release.draft == 0:
output(release)
break
elif wanted_release == 'prerelease':
if release.prerelease == 1:
output(release)
break
elif wanted_release == 'latest':
output(release)
break
elif wanted_release == 'nodraft':
if release.draft == 0:
output(release)
break
else:
print('Can\'t get release')