Merge pull request #19 from yurihartmann/develop #20
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 to PyPI | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'release' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: ⚙️ Install Poetry | |
run: pip install poetry | |
- name: ⚙️ Install Dependencies | |
run: poetry config virtualenvs.create false && poetry install | |
- name: ⚙️ Build library | |
run: poetry build | |
- name: ⚙️ Set Version Variable | |
run: | | |
VER=$(echo "$(poetry version)" | cut -d ' ' -f 2) | |
echo "VERSION=$VER" >> $GITHUB_ENV | |
- name: 🔵 Publish to Test PyPI | |
if: ${{ github.ref == 'refs/heads/release' }} | |
run: | | |
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.test-pypi ${{ secrets.POETRY_PYPI_TOKEN_TEST_PYPI }} | |
poetry publish -r test-pypi --skip-existing | |
# - name: ✏️ Create Pre-release | |
# if: ${{ github.ref == 'refs/heads/release' }} | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# tag: ${{ env.VERSION }}-rc.${{ github.sha }} | |
# run: | | |
# gh release create "$tag" \ | |
# --repo="$GITHUB_REPOSITORY" \ | |
# --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
# --generate-notes --prerelease | |
- name: 🟢 Publish to PyPI | |
if: ${{ github.ref == 'refs/heads/main' }} | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.POETRY_PYPI_TOKEN_PYPI }} | |
poetry publish |