This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more checks to release workflow (#30)
* improve release workflow * ensure models plugin can be found * simplify
- Loading branch information
Showing
2 changed files
with
127 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
from typing import Dict | ||
|
||
import requests | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("version_type", choices=["stable", "latest", "current"]) | ||
return parser.parse_args() | ||
|
||
|
||
def get_current_version() -> str: | ||
VERSION: Dict[str, str] = {} | ||
with open("allennlp_models/version.py", "r") as version_file: | ||
exec(version_file.read(), VERSION) | ||
return "v" + VERSION["VERSION"] | ||
|
||
|
||
def get_latest_version() -> str: | ||
resp = requests.get("https://api.github.com/repos/allenai/allennlp-models/tags") | ||
return resp.json()[0]["name"] | ||
|
||
|
||
def get_stable_version() -> str: | ||
resp = requests.get("https://api.github.com/repos/allenai/allennlp-models/releases/latest") | ||
return resp.json()["tag_name"] | ||
|
||
|
||
def main() -> None: | ||
opts = parse_args() | ||
if opts.version_type == "stable": | ||
print(get_stable_version()) | ||
elif opts.version_type == "latest": | ||
print(get_latest_version()) | ||
elif opts.version_type == "current": | ||
print(get_current_version()) | ||
else: | ||
raise NotImplementedError | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |