diff --git a/.github/workflows/publish_to_pypi.yaml b/.github/workflows/publish_to_pypi.yaml new file mode 100644 index 0000000..50403c6 --- /dev/null +++ b/.github/workflows/publish_to_pypi.yaml @@ -0,0 +1,36 @@ +name: Publish distribution to PyPI + +on: + release: + types: [published] + +jobs: + build-and-publish: + name: Build and publish distribution to PyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@v1.4.2 + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..55bc922 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,57 @@ +name: PR + +on: + pull_request: + branches: + - "master" + +jobs: + python-dependencies: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Pipenv + run: pip install pipenv==2020.11.15 + - name: Cache virtualenv + id: cache-virtualenv + uses: actions/cache@v2 + with: + path: ~/.local/share/virtualenvs/ + key: ${{ runner.os }}-${{ matrix.python-version }}-virtualenvs-${{ hashFiles('Pipfile.lock') }} + - name: Install virtual environment + if: steps.cache-virtualenv.outputs.cache-hit != 'true' + run: pipenv install --dev + + test-unit: + needs: python-dependencies + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install pipenv + run: pip install pipenv==2020.11.15 + - name: Cache virtualenv + id: cache-virtualenv + uses: actions/cache@v2 + with: + path: ~/.local/share/virtualenvs/ + key: ${{ runner.os }}-${{ matrix.python-version }}-virtualenvs-${{ hashFiles('Pipfile.lock') }} + - name: Install virtual environment + if: steps.cache-virtualenv.outputs.cache-hit != 'true' + run: pipenv install --dev + - name: Running unit tests + run: pipenv run make test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 79374ad..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: python -dist: xenial -python: - - "3.9" - - "3.8" - - "3.7" - - "3.6" -sudo: required -before_install: - - pip install pip - - pip install pipenv -install: - - make build - - pipenv install codecov -script: - - make test -deploy: - provider: pypi - distributions: sdist bdist_wheel - username: __token__ - password: $PYPI_API_TOKEN - on: - tags: true - python: 3.9 diff --git a/CHANGELOG.md b/CHANGELOG.md index 616072c..b25f4ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ### Unreleased +- Deprecate Travis CI integration +- Add Github Actions workflows ### 1.0.9 - Release to facilitate a Travis Pypi deployment. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b0471b7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta:__legacy__" \ No newline at end of file diff --git a/setup.py b/setup.py index ef380c0..82fecb7 100644 --- a/setup.py +++ b/setup.py @@ -13,13 +13,19 @@ # For pip installations version = str( ast.literal_eval( - open(os.path.join( - os.path.dirname(__file__), - "sdc", "crypto", "__init__.py"), - 'r').read().split("=")[-1].strip() + open( + os.path.join(os.path.dirname(__file__), "sdc", "crypto", "__init__.py"), + "r", + ) + .read() + .split("=")[-1] + .strip() ) ) +with open("./README.md") as fp: + description = fp.read() + # For more info on pipenv and setuptools - https://realpython.com/pipenv-guide/#package-distribution # and https://pipenv.readthedocs.io/en/latest/advanced/#pipfile-vs-setup-py setup( @@ -28,7 +34,8 @@ description="A shared library for SDC services that use JWT with JWE", author="ONS", url="https://github.com/ONSdigital/sdc-cryptography", - long_description=__doc__, + long_description=description, + long_description_content_type="text/markdown", classifiers=[ "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", @@ -41,12 +48,11 @@ "sdc.crypto", "sdc.crypto.scripts", ], - scripts=['sdc/crypto/scripts/generate_keys.py'], + scripts=["sdc/crypto/scripts/generate_keys.py"], install_requires=["jwcrypto", "cryptography", "PyYAML"], entry_points={ - "console_scripts": [ - ], + "console_scripts": [], }, namespace_packages=["sdc"], - zip_safe=False + zip_safe=False, )