Skip to content

Commit

Permalink
ci: Automatically publish pypi package when tag is created
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoopmans committed Jan 21, 2023
1 parent 927b90b commit 17d4ed7
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 29 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci-cd.yml
@@ -0,0 +1,77 @@
name: CI/CD

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
Test:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -r requirements.txt && \
python -m pip install -r requirements_dev.txt
- name: Test with pytest
run: |
pytest
Publish:
if: |
github.repository == 'rkoopmans/python-certificate-chain-resolver' &&
startsWith(github.ref, 'refs/tags') &&
github.event_name == 'push'
timeout-minutes: 10
needs: [Test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install build wheel
- name: Check if properly tagged
run: |
PACKAGE_VERSION="$(python -c 'from cert_chain_resolver import __version__;print(__version__)')";
CURRENT_TAG="${GITHUB_REF#refs/*/}";
if [[ "${PACKAGE_VERSION}" != "${CURRENT_TAG}" ]]; then
>&2 echo "Tag mismatch. Version in __init__.py does not match tagged commit"
>&2 echo "Skipping deploy"
exit 1;
fi
- name: Build package (sdist & wheel)
run: |
python -m build --sdist --wheel --outdir dist/
- name: Test sdist install
run: |
python -m venv sdist_env
./sdist_env/bin/pip install dist/cert_chain_resolver-*.tar.gz
- name: Test wheel install
run: |
python -m venv wheel_env
./wheel_env/bin/pip install dist/cert_chain_resolver-*.whl
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
packages_dir: dist/
print_hash: true
28 changes: 0 additions & 28 deletions .github/workflows/python-test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
# Python certificate chain resolver

[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://tldrlegal.com/license/mit-license)
![Build](https://github.com/rkoopmans/python-certificate-chain-resolver/workflows/CI%20tests/badge.svg?branch=master)
[![CI](https://github.com/rkoopmans/python-certificate-chain-resolver/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/rkoopmans/python-certificate-chain-resolver/actions/workflows/ci-cd.yml)
[![Docs](https://readthedocs.org/projects/certificate-resolver/badge/?version=latest)](https://certificate-resolver.readthedocs.io/en/latest/)
[![Downloads](https://static.pepy.tech/personalized-badge/cert-chain-resolver?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads)](https://pepy.tech/project/cert-chain-resolver)
![Python)](https://img.shields.io/pypi/pyversions/cert-chain-resolver.svg)
Expand Down

0 comments on commit 17d4ed7

Please sign in to comment.