Skip to content

Always Upgrade on Init #281

Always Upgrade on Init

Always Upgrade on Init #281

---
name: Test and Optionally Publish
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
test:
name: Check code against linter/unit tests
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install tox tox-gh-actions
- name: Test with Tox
run: tox
version-check:
name: Verify that version was updated
runs-on: ubuntu-22.04
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Check version updated
run: bash bin/versionCheck.sh ${GITHUB_BASE_REF##*/} "true"
build-publish:
name: Build and publish Python distributions
runs-on: ubuntu-22.04
needs: [test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Update GIT_HASH
run: sed --expression "s|GIT_HASH|$GITHUB_SHA|g" --in-place **/version.py
- name: Build tarball
run: python setup.py sdist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}