ci: sync configs to pymplate
- add python3.12 - add ruff
This commit is contained in:
parent
fabcbab751
commit
0512488241
9 changed files with 117 additions and 74 deletions
66
.ci/release
Executable file
66
.ci/release
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python3
|
||||
'''
|
||||
Run [[file:scripts/release][scripts/release]] to deploy Python package onto [[https://pypi.org][PyPi]] and [[https://test.pypi.org][test PyPi]].
|
||||
|
||||
The script expects =TWINE_PASSWORD= environment variable to contain the [[https://pypi.org/help/#apitoken][PyPi token]] (not the password!).
|
||||
|
||||
The script can be run manually.
|
||||
It's also running as =pypi= job in [[file:.github/workflows/main.yml][Github Actions config]]. Packages are deployed on:
|
||||
- every master commit, onto test pypi
|
||||
- every new tag, onto production pypi
|
||||
|
||||
You'll need to set =TWINE_PASSWORD= and =TWINE_PASSWORD_TEST= in [[https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets][secrets]]
|
||||
for Github Actions deployment to work.
|
||||
'''
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
import shutil
|
||||
|
||||
is_ci = os.environ.get('CI') is not None
|
||||
|
||||
def main() -> None:
|
||||
import argparse
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--test', action='store_true', help='use test pypi')
|
||||
args = p.parse_args()
|
||||
|
||||
extra = []
|
||||
if args.test:
|
||||
extra.extend(['--repository', 'testpypi'])
|
||||
|
||||
root = Path(__file__).absolute().parent.parent
|
||||
os.chdir(root) # just in case
|
||||
|
||||
if is_ci:
|
||||
# see https://github.com/actions/checkout/issues/217
|
||||
check_call('git fetch --prune --unshallow'.split())
|
||||
|
||||
dist = root / 'dist'
|
||||
if dist.exists():
|
||||
shutil.rmtree(dist)
|
||||
|
||||
check_call(['python3', '-m', 'build'])
|
||||
|
||||
TP = 'TWINE_PASSWORD'
|
||||
password = os.environ.get(TP)
|
||||
if password is None:
|
||||
print(f"WARNING: no {TP} passed", file=sys.stderr)
|
||||
import pip_secrets
|
||||
password = pip_secrets.token_test if args.test else pip_secrets.token # meh
|
||||
|
||||
check_call([
|
||||
'python3', '-m', 'twine',
|
||||
'upload', *dist.iterdir(),
|
||||
*extra,
|
||||
], env={
|
||||
'TWINE_USERNAME': '__token__',
|
||||
TP: password,
|
||||
**os.environ,
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
41
.ci/run
Executable file
41
.ci/run
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd .. # git root
|
||||
|
||||
if ! command -v sudo; then
|
||||
# CI or Docker sometimes doesn't have it, so useful to have a dummy
|
||||
function sudo {
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
|
||||
if [ -n "${CI-}" ]; then
|
||||
# install OS specific stuff here
|
||||
case "$OSTYPE" in
|
||||
darwin*)
|
||||
# macos
|
||||
brew install fd
|
||||
;;
|
||||
cygwin* | msys* | win*)
|
||||
# windows
|
||||
:
|
||||
;;
|
||||
*)
|
||||
# must be linux?
|
||||
sudo apt update
|
||||
sudo apt install fd-find
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
PY_BIN="python3"
|
||||
# some systems might have python pointing to python3
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
PY_BIN="python"
|
||||
fi
|
||||
|
||||
"$PY_BIN" -m pip install --user tox
|
||||
"$PY_BIN" -m tox --parallel --parallel-live "$@"
|
Loading…
Add table
Add a link
Reference in a new issue