From 04b199f84fb0f9e97d6c52f05984a2997f863a6a Mon Sep 17 00:00:00 2001 From: Mohamed Nasser Date: Thu, 29 Aug 2024 16:31:19 +0300 Subject: [PATCH] Adding release workflow --- .github/workflows/release.yaml | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c47ab06 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +name: Publish to PyPI + + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true + default: 'patch' + type: choice + options: + - 'major' + - 'minor' + - 'patch' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Poetry + uses: Gr1N/setup-poetry@v8 + with: + poetry-version: '1.8.3' + + - name: Install dependencies + run: poetry install + + - name: Bump version + run: | + python handle_versioning.py ${{ github.event.inputs.version }} + git add pyproject.toml + git commit -m "Bump version to ${{ github.event.inputs.version }}" + git push + + - name: Create tag + run: | + current_version=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])") + git tag current_version + git push origin current_version + + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }} + run: poetry publish --build