Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Automatically publish pypi package when tag is created
- Loading branch information
Showing
3 changed files
with
78 additions
and
29 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,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 |
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