Skip to content

Build and Deploy Package and Docs #18

Build and Deploy Package and Docs

Build and Deploy Package and Docs #18

name: Build and Deploy Package and Docs
on:
workflow_dispatch:
inputs:
version_type:
description: 'Select the version type to bump'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
permissions:
contents: write
pull-requests: write
packages: write
id-token: write
attestations: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
# Checkout the repository
- name: Check out repository
uses: actions/checkout@v4
# Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch twine mkdocs mkdocs-material "mkdocstrings[python]" bump2version
# Configure Git author identity
- name: Configure Git author
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Bump version based on input
- name: Bump version
run: |
bump2version ${{ github.event.inputs.version_type }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# Push changes
- name: Push changes
run: |
git push origin --tags
git push origin
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# Build the package distributables
- name: Build package
run: |
hatch build
# Publish the distributables to PyPI
- name: Publish package to PyPI
run: twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# Buil mkdocs
- name: Build mkdocs
run: |
mkdocs build
# Build and deploy mkdocs to GitHub Pages
- name: Deploy mkdocs
run: |
mkdocs gh-deploy --force