Skip to content

Commit

Permalink
Merge pull request #20 from karlicoss/ci
Browse files Browse the repository at this point in the history
switch to github actions and CI pypi releases
  • Loading branch information
karlicoss authored Apr 19, 2020
2 parents ed0a622 + 64cebed commit 264d9fc
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 85 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/main.yml
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?
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

23 changes: 0 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ cog: orgparse/__init__.py
orgparse/__init__.py: README.rst
cd orgparse && cog.py -r __init__.py

.PHONY: clean
clean:
rm -rf dist/*


build: clean cog
python3 setup.py sdist bdist_wheel

targets := $(wildcard dist/*)

check: build $(targets)
twine check $(targets)



## https://packaging.python.org/guides/using-testpypi
.PHONY: test-upload
test-upload: check $(targets)
twine upload --verbose --repository-url https://test.pypi.org/legacy/ $(targets)


## Upload to PyPI
.PHONY: upload
upload: check $(target)
twine upload --verbose $(targets)

5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
* `Documentation (Read the Docs) <https://orgparse.readthedocs.org>`_
* `Repository (at GitHub) <https://github.com/karlicoss/orgparse>`_
* `PyPI <https://pypi.python.org/pypi/orgparse>`_
* `Travis CI <https://travis-ci.org/karlicoss/orgparse>`_ |build-status|

.. |build-status|
image:: https://travis-ci.org/karlicoss/orgparse.svg?branch=master
:target: https://travis-ci.org/karlicoss/orgparse

Install
-------
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
copyright = u'2012, Takafumi Arakaki'

# The short X.Y version.
# TODO use setup.py for version
version = orgparse.__version__
# The full version, including alpha/beta/rc tags.
release = orgparse.__version__
Expand Down
6 changes: 0 additions & 6 deletions orgparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
* `Documentation (Read the Docs) <https://orgparse.readthedocs.org>`_
* `Repository (at GitHub) <https://github.com/karlicoss/orgparse>`_
* `PyPI <https://pypi.python.org/pypi/orgparse>`_
* `Travis CI <https://travis-ci.org/karlicoss/orgparse>`_ |build-status|
.. |build-status|
image:: https://travis-ci.org/karlicoss/orgparse.svg?branch=master
:target: https://travis-ci.org/karlicoss/orgparse
Install
-------
Expand Down Expand Up @@ -116,7 +111,6 @@
from .node import parse_lines
from .utils.py3compat import basestring

__version__ = '0.1.4dev0'
__author__ = 'Takafumi Arakaki, Dmitrii Gerasimov'
__license__ = 'BSD License'
__all__ = ["load", "loads", "loadi"]
Expand Down
7 changes: 7 additions & 0 deletions scripts/ci/run
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
66 changes: 66 additions & 0 deletions scripts/release
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()
103 changes: 58 additions & 45 deletions setup.py
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()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py36
envlist = py2,py3
[testenv]
deps =
pytest
Expand Down

0 comments on commit 264d9fc

Please sign in to comment.