Skip to content

Build and Publish

Build and Publish #16

name: Build and Publish
on:
workflow_dispatch: # Only manual trigger and only for the main branch
branches:
- main
inputs:
bump_level:
type: choice
description: Select bump level
required: true
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.2.2
- name: Build and publish
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euv
BUMP_LEVEL=${{ github.event.inputs.bump_level }}
echo "bump level: ${BUMP_LEVEL}"
git config --local user.email "Bumpversion"
git config --local user.name "Bumpversion"
# Version bump
NEW_VERSION=$(poetry version -s ${BUMP_LEVEL})
echo ${NEW_VERSION}
git add pyproject.toml poetry.lock
git commit -m "Bump version to ${NEW_VERSION}"
git tag "v${NEW_VERSION}"
git push -f
git push --tags -f
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV