Skip to content

Publish and Release (Manual) #7

Publish and Release (Manual)

Publish and Release (Manual) #7

Workflow file for this run

name: Publish and Release (Manual)
on:
# Enable execution directly from Actions page
workflow_dispatch:
inputs:
dry-run:
description: 'Dry Run?'
type: boolean
required: true
default: true
bump-version:
description: 'Bump Level?'
type: choice
options:
- 'auto'
- 'major'
- 'minor'
- 'patch'
- 'prerelease'
required: false
default: 'auto'
as-prerelease:
description: 'As pre-release?'
type: boolean
required: true
default: false
jobs:
publish:
name: Publish and Release (${{ github.event.inputs.dry-run == 'true' && 'Dry Run' || 'Prod' }})
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: poetry
- name: Set Poetry environment
run: |
poetry env use python
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Install dependencies
run: poetry install
- name: Semantic Release - Versioning
run: |
FORCE_BUMP=${{ github.event.inputs.bump-version }}
if [[ "$FORCE_BUMP" = "auto" ]]; then
FORCE_BUMP=""
fi
AS_PRERELEASE=${{ github.event.inputs.as-prerelease }}
if [[ "$AS_PRERELEASE" = "true" ]]; then
AS_PRERELEASE="--prerelease"
else
AS_PRERELEASE=""
fi
if [[ "${{ github.event.inputs.dry-run }}" = "true" ]]; then
DRY_RUN="-vv --noop"
fi
poetry run semantic-release $DRY_RUN version $FORCE_BUMP $AS_PRERELEASE
- name: Publish to PyPI
run: |
if [[ "${{ github.event.inputs.dry-run }}" = "true" ]]; then
DRY_RUN="--dry-run"
fi
poetry publish --build $DRY_RUN
- name: Semantic Release - Assets
run: |
if [[ "${{ github.event.inputs.dry-run }}" = "true" ]]; then
DRY_RUN="-vv --noop"
fi
poetry run semantic-release $DRY_RUN publish