Skip to content

Commit 264d9fc

Browse files
authored
Merge pull request #20 from karlicoss/ci
switch to github actions and CI pypi releases
2 parents ed0a622 + 64cebed commit 264d9fc

File tree

10 files changed

+198
-85
lines changed

10 files changed

+198
-85
lines changed

.github/workflows/main.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# see https://github.com/karlicoss/pymplate for up-to-date reference
2+
3+
name: CI
4+
on: [push]
5+
6+
env:
7+
# useful for scripts & sometimes tests to know
8+
CI: true
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
python-version: [3.5, 3.6, 3.7, 3.8]
17+
18+
steps:
19+
# fuck me. https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
20+
- run: echo "::add-path::$HOME/.local/bin"
21+
22+
- uses: actions/setup-python@v1
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- uses: actions/checkout@v2
27+
with:
28+
submodules: recursive
29+
30+
# uncomment for SSH debugging
31+
# - uses: mxschmitt/action-tmate@v2
32+
33+
- run: scripts/ci/run
34+
35+
pypi:
36+
runs-on: ubuntu-latest
37+
needs: [build] # add all other jobs here
38+
39+
steps:
40+
- run: echo "::add-path::$HOME/.local/bin"
41+
42+
- uses: actions/setup-python@v1
43+
with:
44+
python-version: 3.7
45+
46+
- uses: actions/checkout@v2
47+
with:
48+
submodules: recursive
49+
50+
- name: 'release to test pypi'
51+
# always deploy merged master to test pypi
52+
if: github.event.ref == 'refs/heads/master'
53+
env:
54+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }}
55+
run: pip3 install --user wheel twine && scripts/release --test
56+
57+
- name: 'release to pypi'
58+
# always deploy tags to release pypi
59+
# TODO filter release tags only?
60+
if: startsWith(github.event.ref, 'refs/tags')
61+
env:
62+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
63+
run: pip3 install --user wheel twine && scripts/release
64+
65+
# todo generate mypy coverage artifacts?

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,6 @@ cog: orgparse/__init__.py
1313
orgparse/__init__.py: README.rst
1414
cd orgparse && cog.py -r __init__.py
1515

16-
.PHONY: clean
17-
clean:
18-
rm -rf dist/*
19-
20-
2116
build: clean cog
2217
python3 setup.py sdist bdist_wheel
2318

24-
targets := $(wildcard dist/*)
25-
26-
check: build $(targets)
27-
twine check $(targets)
28-
29-
30-
31-
## https://packaging.python.org/guides/using-testpypi
32-
.PHONY: test-upload
33-
test-upload: check $(targets)
34-
twine upload --verbose --repository-url https://test.pypi.org/legacy/ $(targets)
35-
36-
37-
## Upload to PyPI
38-
.PHONY: upload
39-
upload: check $(target)
40-
twine upload --verbose $(targets)
41-

README.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
* `Documentation (Read the Docs) <https://orgparse.readthedocs.org>`_
77
* `Repository (at GitHub) <https://github.com/karlicoss/orgparse>`_
88
* `PyPI <https://pypi.python.org/pypi/orgparse>`_
9-
* `Travis CI <https://travis-ci.org/karlicoss/orgparse>`_ |build-status|
10-
11-
.. |build-status|
12-
image:: https://travis-ci.org/karlicoss/orgparse.svg?branch=master
13-
:target: https://travis-ci.org/karlicoss/orgparse
149

1510
Install
1611
-------

doc/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
copyright = u'2012, Takafumi Arakaki'
2424

2525
# The short X.Y version.
26+
# TODO use setup.py for version
2627
version = orgparse.__version__
2728
# The full version, including alpha/beta/rc tags.
2829
release = orgparse.__version__

orgparse/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
* `Documentation (Read the Docs) <https://orgparse.readthedocs.org>`_
1313
* `Repository (at GitHub) <https://github.com/karlicoss/orgparse>`_
1414
* `PyPI <https://pypi.python.org/pypi/orgparse>`_
15-
* `Travis CI <https://travis-ci.org/karlicoss/orgparse>`_ |build-status|
16-
17-
.. |build-status|
18-
image:: https://travis-ci.org/karlicoss/orgparse.svg?branch=master
19-
:target: https://travis-ci.org/karlicoss/orgparse
2015
2116
Install
2217
-------
@@ -116,7 +111,6 @@
116111
from .node import parse_lines
117112
from .utils.py3compat import basestring
118113

119-
__version__ = '0.1.4dev0'
120114
__author__ = 'Takafumi Arakaki, Dmitrii Gerasimov'
121115
__license__ = 'BSD License'
122116
__all__ = ["load", "loads", "loadi"]

scripts/ci/run

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash -eu
2+
3+
cd "$(dirname "$0")"
4+
cd ../..
5+
6+
pip3 install --user tox
7+
tox

scripts/release

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python3
2+
'''
3+
Run [[file:scripts/release][scripts/release]] to deploy Python package onto [[https://pypi.org][PyPi]] and [[https://test.pypi.org][test PyPi]].
4+
5+
The script expects =TWINE_PASSWORD= environment variable to contain the [[https://pypi.org/help/#apitoken][PyPi token]] (not the password!).
6+
7+
The script can be run manually.
8+
It's also running as =pypi= job in [[file:.github/workflows/main.yml][Github Actions config]]. Packages are deployed on:
9+
- every master commit, onto test pypi
10+
- every new tag, onto production pypi
11+
12+
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]]
13+
for Github Actions deployment to work.
14+
'''
15+
16+
import os
17+
import sys
18+
from pathlib import Path
19+
from subprocess import check_call
20+
import shutil
21+
22+
is_ci = os.environ.get('CI') is not None
23+
24+
def main():
25+
import argparse
26+
p = argparse.ArgumentParser()
27+
p.add_argument('--test', action='store_true', help='use test pypi')
28+
args = p.parse_args()
29+
30+
extra = []
31+
if args.test:
32+
extra.extend(['--repository-url', 'https://test.pypi.org/legacy/'])
33+
34+
root = Path(__file__).absolute().parent.parent
35+
os.chdir(root) # just in case
36+
37+
if is_ci:
38+
# see https://github.com/actions/checkout/issues/217
39+
check_call('git fetch --prune --unshallow'.split())
40+
41+
dist = root / 'dist'
42+
if dist.exists():
43+
shutil.rmtree(dist)
44+
45+
check_call('python3 setup.py sdist bdist_wheel', shell=True)
46+
47+
TP = 'TWINE_PASSWORD'
48+
password = os.environ.get(TP)
49+
if password is None:
50+
print(f"WARNING: no {TP} passed", file=sys.stderr)
51+
import pip_secrets
52+
password = pip_secrets.token_test if args.test else pip_secrets.token # meh
53+
54+
check_call([
55+
'python3', '-m', 'twine',
56+
'upload', *dist.iterdir(),
57+
*extra,
58+
], env={
59+
'TWINE_USERNAME': '__token__',
60+
TP: password,
61+
**os.environ,
62+
})
63+
64+
65+
if __name__ == '__main__':
66+
main()

setup.py

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,58 @@
1-
import setuptools
2-
from distutils.core import setup
3-
4-
import orgparse
5-
6-
setup(
7-
name='orgparse',
8-
version=orgparse.__version__,
9-
packages=[
10-
'orgparse',
11-
'orgparse.utils',
12-
'orgparse.tests',
13-
'orgparse.tests.data',
14-
],
15-
package_data={
16-
'orgparse.tests.data': ['*.org'],
17-
},
18-
19-
author=orgparse.__author__,
20-
author_email='[email protected]',
21-
maintainer='Dima Gerasimov (@karlicoss)',
22-
maintainer_email='[email protected]',
23-
24-
url='https://github.com/karlicoss/orgparse',
25-
license=orgparse.__license__,
26-
27-
description='orgparse - Emacs org-mode parser in Python',
28-
long_description=orgparse.__doc__,
29-
30-
keywords='org org-mode emacs',
31-
classifiers=[
32-
'Development Status :: 5 - Production/Stable',
33-
'License :: OSI Approved :: BSD License',
34-
'Programming Language :: Python',
35-
'Programming Language :: Python :: 2',
36-
'Programming Language :: Python :: 2.6',
37-
'Programming Language :: Python :: 2.7',
38-
'Programming Language :: Python :: 3',
39-
'Programming Language :: Python :: 3.5',
40-
'Programming Language :: Python :: 3.6',
41-
'Programming Language :: Python :: 3.7',
42-
'Topic :: Text Processing :: Markup',
43-
# see: http://pypi.python.org/pypi?%3Aaction=list_classifiers
44-
],
45-
)
1+
# see https://github.com/karlicoss/pymplate for up-to-date reference
2+
#
3+
from setuptools import setup, find_packages # type: ignore
4+
5+
6+
def main():
7+
import orgparse
8+
setup(
9+
name='orgparse',
10+
use_scm_version={
11+
'version_scheme': 'python-simplified-semver',
12+
'local_scheme': 'dirty-tag',
13+
},
14+
setup_requires=['setuptools_scm'],
15+
16+
zip_safe=False,
17+
18+
packages=[
19+
'orgparse',
20+
'orgparse.utils',
21+
'orgparse.tests',
22+
'orgparse.tests.data',
23+
],
24+
package_data={
25+
'orgparse.tests.data': ['*.org'],
26+
},
27+
28+
author=orgparse.__author__,
29+
author_email='[email protected]',
30+
maintainer='Dima Gerasimov (@karlicoss)',
31+
maintainer_email='[email protected]',
32+
33+
url='https://github.com/karlicoss/orgparse',
34+
license=orgparse.__license__,
35+
36+
description='orgparse - Emacs org-mode parser in Python',
37+
long_description=orgparse.__doc__,
38+
39+
keywords='org org-mode emacs',
40+
classifiers=[
41+
'Development Status :: 5 - Production/Stable',
42+
'License :: OSI Approved :: BSD License',
43+
'Programming Language :: Python',
44+
'Programming Language :: Python :: 2',
45+
'Programming Language :: Python :: 2.6',
46+
'Programming Language :: Python :: 2.7',
47+
'Programming Language :: Python :: 3',
48+
'Programming Language :: Python :: 3.5',
49+
'Programming Language :: Python :: 3.6',
50+
'Programming Language :: Python :: 3.7',
51+
'Topic :: Text Processing :: Markup',
52+
# see: http://pypi.python.org/pypi?%3Aaction=list_classifiers
53+
],
54+
)
55+
56+
57+
if __name__ == '__main__':
58+
main()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py36
2+
envlist = py2,py3
33
[testenv]
44
deps =
55
pytest

0 commit comments

Comments
 (0)