Skip to content

Настройка github workflow #9

Настройка github workflow

Настройка github workflow #9

Workflow file for this run

name: Publish Python Package
on:
push:
branches:
- main
jobs:
check_version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Get current version
id: get_version
run: |
echo "VERSION=$(poetry version -s)" >> $GITHUB_ENV
- name: Check if version is pre-release
id: check_prerelease
run: |
if [[ "${{ env.VERSION }}" == *"alpha"* || "${{ env.VERSION }}" == *"beta"* ]]; then
echo "Pre-release version ${{ env.VERSION }} detected. Skipping publish."
exit 0
fi
- name: Check if version exists on PyPI
id: check_version
run: |
if curl -s https://pypi.org/pypi/manimextra/json | jq -e ".releases | has(\"${{ env.VERSION }}\")"; then
echo "Version ${{ env.VERSION }} already exists on PyPI. Failing the workflow."
exit 1
fi
- name: Output check_prerelease outcome
run: echo "check_prerelease.outcome=${{ steps.check_prerelease.outcome }}"
- name: Output check_version outcome
run: echo "check_version.outcome=${{ steps.check_version.outcome }}"
- name: Publish to PyPI
if: steps.check_prerelease.outcome == 'success' && steps.check_version.outcome != 'failure'
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config pypi-token.pypi $POETRY_PYPI_TOKEN_PYPI
poetry build
poetry publish