-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from karlicoss/ci
switch to github actions and CI pypi releases
- Loading branch information
Showing
10 changed files
with
198 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# see https://github.com/karlicoss/pymplate for up-to-date reference | ||
|
||
name: CI | ||
on: [push] | ||
|
||
env: | ||
# useful for scripts & sometimes tests to know | ||
CI: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.5, 3.6, 3.7, 3.8] | ||
|
||
steps: | ||
# fuck me. https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path | ||
- run: echo "::add-path::$HOME/.local/bin" | ||
|
||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
# uncomment for SSH debugging | ||
# - uses: mxschmitt/action-tmate@v2 | ||
|
||
- run: scripts/ci/run | ||
|
||
pypi: | ||
runs-on: ubuntu-latest | ||
needs: [build] # add all other jobs here | ||
|
||
steps: | ||
- run: echo "::add-path::$HOME/.local/bin" | ||
|
||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: 'release to test pypi' | ||
# always deploy merged master to test pypi | ||
if: github.event.ref == 'refs/heads/master' | ||
env: | ||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }} | ||
run: pip3 install --user wheel twine && scripts/release --test | ||
|
||
- name: 'release to pypi' | ||
# always deploy tags to release pypi | ||
# TODO filter release tags only? | ||
if: startsWith(github.event.ref, 'refs/tags') | ||
env: | ||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | ||
run: pip3 install --user wheel twine && scripts/release | ||
|
||
# todo generate mypy coverage artifacts? |
This file was deleted.
Oops, something went wrong.
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
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
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,7 @@ | ||
#!/bin/bash -eu | ||
|
||
cd "$(dirname "$0")" | ||
cd ../.. | ||
|
||
pip3 install --user tox | ||
tox |
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,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(): | ||
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-url', 'https://test.pypi.org/legacy/']) | ||
|
||
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 setup.py sdist bdist_wheel', shell=True) | ||
|
||
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() |
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,45 +1,58 @@ | ||
import setuptools | ||
from distutils.core import setup | ||
|
||
import orgparse | ||
|
||
setup( | ||
name='orgparse', | ||
version=orgparse.__version__, | ||
packages=[ | ||
'orgparse', | ||
'orgparse.utils', | ||
'orgparse.tests', | ||
'orgparse.tests.data', | ||
], | ||
package_data={ | ||
'orgparse.tests.data': ['*.org'], | ||
}, | ||
|
||
author=orgparse.__author__, | ||
author_email='[email protected]', | ||
maintainer='Dima Gerasimov (@karlicoss)', | ||
maintainer_email='[email protected]', | ||
|
||
url='https://github.com/karlicoss/orgparse', | ||
license=orgparse.__license__, | ||
|
||
description='orgparse - Emacs org-mode parser in Python', | ||
long_description=orgparse.__doc__, | ||
|
||
keywords='org org-mode emacs', | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'License :: OSI Approved :: BSD License', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.6', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Topic :: Text Processing :: Markup', | ||
# see: http://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
], | ||
) | ||
# see https://github.com/karlicoss/pymplate for up-to-date reference | ||
# | ||
from setuptools import setup, find_packages # type: ignore | ||
|
||
|
||
def main(): | ||
import orgparse | ||
setup( | ||
name='orgparse', | ||
use_scm_version={ | ||
'version_scheme': 'python-simplified-semver', | ||
'local_scheme': 'dirty-tag', | ||
}, | ||
setup_requires=['setuptools_scm'], | ||
|
||
zip_safe=False, | ||
|
||
packages=[ | ||
'orgparse', | ||
'orgparse.utils', | ||
'orgparse.tests', | ||
'orgparse.tests.data', | ||
], | ||
package_data={ | ||
'orgparse.tests.data': ['*.org'], | ||
}, | ||
|
||
author=orgparse.__author__, | ||
author_email='[email protected]', | ||
maintainer='Dima Gerasimov (@karlicoss)', | ||
maintainer_email='[email protected]', | ||
|
||
url='https://github.com/karlicoss/orgparse', | ||
license=orgparse.__license__, | ||
|
||
description='orgparse - Emacs org-mode parser in Python', | ||
long_description=orgparse.__doc__, | ||
|
||
keywords='org org-mode emacs', | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'License :: OSI Approved :: BSD License', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.6', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Topic :: Text Processing :: Markup', | ||
# see: http://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
], | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tox] | ||
envlist = py27, py36 | ||
envlist = py2,py3 | ||
[testenv] | ||
deps = | ||
pytest | ||
|