-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Has function to get name of latest gh release for a repo
- Loading branch information
Showing
6 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
name: Test scripts | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run gh_utils test | ||
run: python gh_utils.py KDAB/KDDockWidgets | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[MESSAGES CONTROL] | ||
disable=C0114,C0116 |
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 |
---|---|---|
|
@@ -5,7 +5,14 @@ SPDX-PackageDownloadLocation = "https://www.github.com/KDABLabs/ci-release-tools | |
|
||
#misc FILES | ||
[[annotations]] | ||
path = ["README.md", "REUSE.toml", "LICENSE.txt", ".pre-commit-config.yaml"] | ||
path = [ | ||
".gitignore", | ||
"README.md", | ||
"REUSE.toml", | ||
"LICENSE.txt", | ||
".pre-commit-config.yaml", | ||
".pylintrc", | ||
] | ||
precedence = "aggregate" | ||
SPDX-FileCopyrightText = "Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>" | ||
SPDX-License-Identifier = "MIT" |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Scripts related to GitHub | ||
|
||
# Examples: | ||
# $ gh_utils.py --get-latest-release=KDAB/KDDockWidgets | ||
# v2.1.0 | ||
|
||
import argparse | ||
from utils import run_command_with_output | ||
|
||
# Returns the tag of latest release | ||
# repo is for example 'KDAB/KDReports' | ||
|
||
|
||
def get_latest_release_tag_in_github(repo): | ||
lines = run_command_with_output( | ||
f"gh release list --repo {repo} --limit 1").split('\n') | ||
# example: | ||
# TITLE TYPE TAG NAME PUBLISHED | ||
# KDReports 2.3.0 Latest kdreports-2.3.0 about 2 months ago | ||
version = lines[0].split('\t')[2] | ||
return version | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--get-latest-release', | ||
help="returns latest release for a repo") | ||
args = parser.parse_args() | ||
if args.get_latest_release: | ||
print(get_latest_release_tag_in_github(args.get_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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Generic utils used by the other scripts | ||
|
||
import os | ||
import sys | ||
|
||
|
||
def exit_because(reason): | ||
print(reason) | ||
sys.exit(1) | ||
|
||
|
||
def run_command(command, fatal=True): | ||
if os.system(command) == 0: | ||
return True | ||
|
||
if fatal: | ||
exit_because(f"Failed to run command: {command}") | ||
|
||
return False | ||
|
||
|
||
def run_command_with_output(command): | ||
output = os.popen(command).read() | ||
return output |