Skip to content

Prep PR for 0.4.0 Release (#801) #53

Prep PR for 0.4.0 Release (#801)

Prep PR for 0.4.0 Release (#801) #53

Workflow file for this run

name: Publish package to PyPI
on:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Get release version
run: |
echo "CHANGELOG_VERSION=$(cat CHANGELOG.md | grep -oP '(?<=###\s)(.*)(?=\s\-)' | head -n 1 | sed 's/Version\s/v/')" >> $GITHUB_ENV
echo "TAG_VERSION=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
- name: Check changelog release version
if: ${{ env.TAG_VERSION != env.CHANGELOG_VERSION }}
run: |
echo "CHANGELOG_VERSION($CHANGELOG_VERSION) is different from TAG_VERSION($TAG_VERSION)"
exit 1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Get all git tags
run: git fetch --tags -f
- name: Build package
run: |
python -m build --sdist --wheel
- name: Get package size
run: echo "PKG_SIZE=$(find dist -maxdepth 1 -regex '.*gz' | xargs stat --format='%s')" >> $GITHUB_ENV
- name: Check package size
if: ${{ env.PKG_SIZE > 1e+8 }}
run: |
echo "PKG_SIZE($PKG_SIZE bytes) is greater than 100MB"
exit 1
- name: Publish package
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
password: ${{ secrets.PYPI_API_TOKEN }}