Skip to content

updated runner, python setup action and checkout actions for PyPI pub… #55

updated runner, python setup action and checkout actions for PyPI pub…

updated runner, python setup action and checkout actions for PyPI pub… #55

Workflow file for this run

name: Publish package to PyPI
on:
push:
tags:
- "*"
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensures full history/tags are available if you ever need them
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Get release version
shell: bash
run: |
echo "CHANGELOG_VERSION=$(grep -oP '(?<=###\s)(.*)(?=\s\-)' CHANGELOG.md | head -n 1 | sed 's/Version\s/v/')" >> "$GITHUB_ENV"
echo "TAG_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
- name: Check changelog release version
shell: bash
run: |
if [[ "${TAG_VERSION}" != "${CHANGELOG_VERSION}" ]]; then
echo "CHANGELOG_VERSION(${CHANGELOG_VERSION}) is different from TAG_VERSION(${TAG_VERSION})"
exit 1
fi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build --sdist --wheel
- name: Check package size (100MB max)
shell: bash
run: |
PKG_SIZE="$(find dist -maxdepth 1 -name '*.tar.gz' -print0 | xargs -0 stat --format='%s' | head -n 1)"
echo "PKG_SIZE=${PKG_SIZE}" >> "$GITHUB_ENV"
if [[ -n "${PKG_SIZE}" ]] && (( PKG_SIZE > 100000000 )); then
echo "PKG_SIZE(${PKG_SIZE} bytes) is greater than 100MB"
exit 1
fi
- name: Publish package
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true