-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increment ubuntu container version move from pygithub to ghapi skip the chown step
- Loading branch information
Showing
7 changed files
with
50 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
# get the parent directory of the script, to link libs | ||
|
||
import os | ||
import sys | ||
|
||
from libs.github import get_latest_github_repo_version | ||
|
||
def main(): | ||
latest_release = get_latest_github_repo_version("github/codeql-cli-binaries") | ||
print(latest_release.title) | ||
latest_release = get_latest_github_repo_version("github", "codeql-cli-binaries") | ||
print(latest_release.tag_name) | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import os | ||
from datetime import datetime, MINYEAR | ||
from github import Github, GitRelease, Repository, GithubException | ||
from ghapi.all import GhApi | ||
from datetime import datetime, timezone | ||
from dateutil import parser | ||
|
||
def get_latest_github_repo_version(repo): | ||
def get_latest_github_repo_version(owner, repository): | ||
# check for a github token that may be used alongside the codeql cli to upload github results | ||
# this will limit rate limting 403 errors on checking codeql versions, as the request will be authenticated if possible. | ||
# by default codeql uses env var "GITHUB_TOKEN" to authenticate | ||
# https://codeql.github.com/docs/codeql-cli/manual/github-upload-results/ | ||
access_token = os.getenv('GITHUB_TOKEN') | ||
client = Github(access_token) if access_token != None else Github() | ||
repo = client.get_repo(repo) | ||
releases = repo.get_releases() | ||
api = GhApi(owner=owner, repo=repository, token=access_token) if access_token != None else GhApi(owner=owner, repo=repository) | ||
releases = api.repos.list_releases() | ||
latest_release = get_latest_github_release(releases) | ||
return latest_release | ||
|
||
def get_latest_github_release(releases): | ||
latest_release = None | ||
latest_date = datetime(MINYEAR, 1, 1) | ||
latest_date = datetime(MINYEAR, 1, 1).replace(tzinfo=timezone.utc) | ||
for release in releases: | ||
if release.created_at > latest_date: | ||
latest_date = release.created_at | ||
release_date = parser.parse(release.created_at) | ||
if release_date > latest_date: | ||
latest_date = release_date | ||
latest_release = release | ||
return latest_release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
PyGithub==1.43.7 | ||
ghapi==1.0.3 | ||
python-dateutil==2.8.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters