Skip to content

Bump pypa/gh-action-pypi-publish in /.github/workflows #21

Bump pypa/gh-action-pypi-publish in /.github/workflows

Bump pypa/gh-action-pypi-publish in /.github/workflows #21

name: publish distributions
on:
push:
branches:
- master
tags:
- v*
jobs:
build-and-publish:
name: Build and publish Python distro to (Test)PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install pep517 and twine
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pep517 --user
python -m pip install twine
- name: Build a binary wheel and a source tarball
run: |
python -m pep517.build --source --binary --out-dir dist/ .
- name: Verify untagged commits have dev versions
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
latest_tag=$(git describe --tags)
latest_tag_revlist_SHA=$(git rev-list -n 1 ${latest_tag})
master_SHA="$(git rev-parse --verify origin/master)"
wheel_name=$(find dist/ -iname "*.whl" -printf "%f\n")
if [[ "${latest_tag_revlist_SHA}" != "${master_SHA}" ]]; then # don't check master push events coming from tags
if [[ "${wheel_name}" == *"ads2inspire-0.1.dev"* || "${wheel_name}" != *"dev"* ]]; then
echo "pep517.build incorrectly named built distribution: ${wheel_name}"
echo "pep517 is lacking the history and tags required to determine version number"
echo "intentionally erroring with 'return 1' now"
return 1
fi
else
echo "Push event to origin/master was triggered by push of tag ${latest_tag}"
fi
echo "pep517.build named built distribution: ${wheel_name}"
- name: Verify tagged commits don't have dev versions
if: startsWith(github.ref, 'refs/tags')
run: |
wheel_name=$(find dist/ -iname "*.whl" -printf "%f\n")
if [[ "${wheel_name}" == *"dev"* ]]; then
echo "pep517.build incorrectly named built distribution: ${wheel_name}"
echo "this is incorrrectly being treated as a dev release"
echo "intentionally erroring with 'return 1' now"
return 1
fi
echo "pep517.build named built distribution: ${wheel_name}"
- name: Verify the distribution
run: twine check dist/*
- name: Publish distribution 📦 to Test PyPI
# every PR will trigger a push event on master, so check the push event is actually coming from master
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'duetosymmetry/ads2inspire'
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && github.repository == 'duetosymmetry/ads2inspire'
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
password: ${{ secrets.pypi_password }}