Skip to content

Return workflow name when finished workflows are called (#55) #18

Return workflow name when finished workflows are called (#55)

Return workflow name when finished workflows are called (#55) #18

Workflow file for this run

name: Release
on:
push:
# The CI job is triggered after merged to branch, so the version between last commits are compared
branches: [main]
workflow_dispatch:
inputs:
force_release:
type: boolean
description: 'Force release regardless of version changes'
default: false
env:
PYTHONVERSION: "3.12"
jobs:
release:
runs-on: macos-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
uv sync
uv pip install twine build toml
- name: Compare versions
id: compare-versions
run: |
source .venv/bin/activate
FORCE_RELEASE="${{ github.event.inputs.force_release }}"
CUR_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
git switch --detach HEAD^
MAIN_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
git switch -
echo "Current version in pyproject.toml: $CUR_VERSION"
echo "Version on main branch: $MAIN_VERSION"
echo "FORCE_RELEASE: $FORCE_RELEASE"
if [ "$FORCE_RELEASE" == "true" ]; then
echo "Force release is enabled. Proceeding with the release."
echo "SKIP_RELEASE=false" >> $GITHUB_ENV
elif [ "$CUR_VERSION" == "$MAIN_VERSION" ]; then
echo "The version hasn't changed. Skipping release."
echo "SKIP_RELEASE=true" >> $GITHUB_ENV
else
echo "Versions differ. Proceed with the release."
echo "SKIP_RELEASE=false" >> $GITHUB_ENV
fi
- name: Release to PyPI
if: env.SKIP_RELEASE != 'true'
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISHER_TOKEN }}
run: |
uv run python -m build --sdist
uv run twine upload -r pypi dist/*