forked from rez0n/actions-github-release
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.py
More file actions
executable file
·51 lines (43 loc) · 1.43 KB
/
entrypoint.py
File metadata and controls
executable file
·51 lines (43 loc) · 1.43 KB
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
44
45
46
47
48
49
50
#!/usr/bin/env python3
from github import Github, Auth
import os
# Settings
wanted_release = os.getenv('type')
repository = os.getenv('repository')
token = os.getenv('token', None)
package = os.getenv('package')
# Init class
auth = Auth.Token(token)
G = Github(auth=auth)
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
found = False
for release in releases:
print(f'Checking release: {release.tag_name}') # Debugging log
if package in release.tag_name:
if wanted_release == 'stable' and not release.prerelease and not release.draft:
output(release)
found = True
break
elif wanted_release == 'prerelease' and release.prerelease:
output(release)
found = True
break
elif wanted_release == 'latest':
output(release)
found = True
break
elif wanted_release == 'nodraft' and not release.draft:
output(release)
found = True
break
if not found:
print('Can\'t get release')