closes #173. Improved prefix management. Requested functionality alr… #17
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
name: Upload Python Package | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
check_version: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
outputs: | |
version_changed: ${{ steps.check.outputs.version_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check if version has been incremented | |
id: check | |
run: | | |
if git rev-parse --verify main^ >/dev/null 2>&1; then | |
git checkout main^ | |
VERSION_MASTER=$(grep -oP '(?<=version = ")[^"]*' pyproject.toml) | |
else | |
VERSION_MASTER="" | |
fi | |
echo "Version on previous commit: $VERSION_MASTER" | |
git checkout main | |
VERSION_OLD=$(grep -oP '(?<=version = ")[^"]*' pyproject.toml) | |
echo "Version on current commit: $VERSION_OLD" | |
if [ "$VERSION_MASTER" != "$VERSION_OLD" ]; then | |
echo "version_changed=true" >> $GITHUB_ENV | |
echo "::set-output name=version_changed::true" | |
fi | |
shell: bash | |
deploy: | |
needs: check_version | |
if: needs.check_version.outputs.version_changed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Poetry | |
run: | | |
pip install poetry==1.5.0 | |
- name: Install dependencies | |
run: | | |
poetry install --all-extras --no-interaction --no-root | |
- name: Build package | |
run: poetry build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |