Skip to content

Release

Release #29

name: Build and Publish Python Package
on:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'setup.py'
- 'pyproject.toml'
- '.github/workflows/**'
- 'src/cryptoservice/__init__.py'
workflow_dispatch:
release:
types: [published]
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
- name: Run tests with pytest
run: |
pytest tests/ -v --cov=cryptoservice --cov-report=xml
release:
needs: test
runs-on: ubuntu-22.04
concurrency: release
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog: "true"
git_committer_name: "github-actions"
git_committer_email: "[email protected]"
- name: Check if release was created
if: steps.release.outputs.released == 'true'
run: |
echo "Version: ${{ steps.release.outputs.version }}"
echo "Release created successfully"
- name: Set up Python
if: steps.release.outputs.released == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*