mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 02:13:44 +03:00
Clean up the packaging procedure
This commit is contained in:
parent
06c3c3a557
commit
521981584d
|
@ -52,7 +52,7 @@ How to make a psycopg2 release
|
||||||
- When the workflows have finished download the packages using the
|
- When the workflows have finished download the packages using the
|
||||||
``download_packages.py`` and ``download_packages_appveyor.py`` scripts from
|
``download_packages.py`` and ``download_packages_appveyor.py`` scripts from
|
||||||
the ``scripts/build`` directory. They will be saved in a
|
the ``scripts/build`` directory. They will be saved in a
|
||||||
``psycopg2-${VERSION}`` directory.
|
``packages/psycopg2-${VERSION}`` directory.
|
||||||
|
|
||||||
- Remove the ``.exe`` from the dir, because we don't want to upload them on
|
- Remove the ``.exe`` from the dir, because we don't want to upload them on
|
||||||
PyPI::
|
PyPI::
|
||||||
|
|
|
@ -6,15 +6,14 @@ import io
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
import datetime as dt
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logging.basicConfig(
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
||||||
level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s"
|
|
||||||
)
|
|
||||||
|
|
||||||
REPOS = "psycopg/psycopg2"
|
REPOS = "psycopg/psycopg2"
|
||||||
WORKFLOW_NAME = "Build packages"
|
WORKFLOW_NAME = "Build packages"
|
||||||
|
@ -43,7 +42,17 @@ def main():
|
||||||
else:
|
else:
|
||||||
raise ScriptError(f"couldn't find {WORKFLOW_NAME!r} in recent runs")
|
raise ScriptError(f"couldn't find {WORKFLOW_NAME!r} in recent runs")
|
||||||
|
|
||||||
logger.info(f"looking for run {run['id']} artifacts")
|
if run["status"] != "completed":
|
||||||
|
raise ScriptError(f"run #{run['run_number']} is in status {run['status']}")
|
||||||
|
|
||||||
|
updated_at = dt.datetime.fromisoformat(run["updated_at"].replace("Z", "+00:00"))
|
||||||
|
now = dt.datetime.now(dt.timezone.utc)
|
||||||
|
age = now - updated_at
|
||||||
|
logger.info(f"found run #{run['run_number']} updated {pretty_interval(age)} ago")
|
||||||
|
if age > dt.timedelta(hours=6):
|
||||||
|
logger.warning("maybe it's a bit old?")
|
||||||
|
|
||||||
|
logger.info(f"looking for run #{run['run_number']} artifacts")
|
||||||
resp = s.get(f"{run['url']}/artifacts")
|
resp = s.get(f"{run['url']}/artifacts")
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
artifacts = resp.json()["artifacts"]
|
artifacts = resp.json()["artifacts"]
|
||||||
|
@ -64,6 +73,19 @@ def main():
|
||||||
logger.info(f"now you can run: 'twine upload -s {dest}/*'")
|
logger.info(f"now you can run: 'twine upload -s {dest}/*'")
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_interval(td):
|
||||||
|
secs = td.total_seconds()
|
||||||
|
mins, secs = divmod(secs, 60)
|
||||||
|
hours, mins = divmod(mins, 60)
|
||||||
|
days, hours = divmod(hours, 24)
|
||||||
|
if days:
|
||||||
|
return f"{int(days)} days, {int(hours)} hours, {int(mins)} minutes"
|
||||||
|
elif hours:
|
||||||
|
return f"{int(hours)} hours, {int(mins)} minutes"
|
||||||
|
else:
|
||||||
|
return f"{int(mins)} minutes"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
import datetime as dt
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
@ -35,6 +37,18 @@ def main():
|
||||||
resp = s.get(f"{API_URL}/projects/{REPOS}/")
|
resp = s.get(f"{API_URL}/projects/{REPOS}/")
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
|
|
||||||
|
updated_at = dt.datetime.fromisoformat(
|
||||||
|
re.sub(r"\.\d+", "", data["build"]["finished"])
|
||||||
|
)
|
||||||
|
now = dt.datetime.now(dt.timezone.utc)
|
||||||
|
age = now - updated_at
|
||||||
|
logger.info(
|
||||||
|
f"found build {data['build']['version']} updated {pretty_interval(age)} ago"
|
||||||
|
)
|
||||||
|
if age > dt.timedelta(hours=6):
|
||||||
|
logger.warning("maybe it's a bit old?")
|
||||||
|
|
||||||
jobs = data["build"]["jobs"]
|
jobs = data["build"]["jobs"]
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
if job["status"] != "success":
|
if job["status"] != "success":
|
||||||
|
@ -63,6 +77,19 @@ def main():
|
||||||
logger.info("now you can run: 'twine upload -s packages/*'")
|
logger.info("now you can run: 'twine upload -s packages/*'")
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_interval(td):
|
||||||
|
secs = td.total_seconds()
|
||||||
|
mins, secs = divmod(secs, 60)
|
||||||
|
hours, mins = divmod(mins, 60)
|
||||||
|
days, hours = divmod(hours, 24)
|
||||||
|
if days:
|
||||||
|
return f"{int(days)} days, {int(hours)} hours, {int(mins)} minutes"
|
||||||
|
elif hours:
|
||||||
|
return f"{int(hours)} hours, {int(mins)} minutes"
|
||||||
|
else:
|
||||||
|
return f"{int(mins)} minutes"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
@ -74,4 +101,3 @@ if __name__ == "__main__":
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.info("user interrupt")
|
logger.info("user interrupt")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user