Update ubuntu version in GitHub action workflow #189
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Build and Publish | |
on: [ push, pull_request ] | |
jobs: | |
build-test: | |
name: Test and Build | |
runs-on: ubuntu-20.04 | |
env: | |
PY_COLORS: 1 | |
TOX_PARALLEL_NO_SPINNER: 1 | |
steps: | |
- name: Dump select GitHub event context | |
run: | | |
echo "github.ref=${{ github.ref }}" | |
echo "github.event.head_commit=$HEAD_COMMIT" | |
env: | |
HEAD_COMMIT: ${{ toJson(github.event.head_commit) }} | |
- name: Check out src from GitHub | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.10 | |
- uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-activate-base: true | |
python-version: 3.10 | |
auto-update-conda: true | |
- name: Install dependencies | |
run: | | |
conda config --set always_yes yes --set changeps1 no | |
python3 -m pip install tox setuptools>=42 setuptools_scm wheel twine | |
[ -f requirements.txt ] && python3 -m pip install -Ur requirements.txt | |
[ -f test-requirements.txt ] && python3 -m pip install -Ur test-requirements.txt | |
echo "VERSION=$(python3 setup.py --version)" | |
make bats-libraries | |
# Useful for debugging any issues with conda | |
conda info -a | |
- name: Get variables | |
id: get_vars | |
run: | | |
REPO=$(basename ${{ github.repository }}) | |
echo "REPO=${REPO}" | |
echo ::set-output name=REPO::${REPO} | |
BRANCH=${GITHUB_REF##*/} | |
echo "BRANCH=${BRANCH}" | |
echo ::set-output name=BRANCH::${BRANCH} | |
VERSION=$(python3 setup.py --version 2>/dev/null) | |
echo "VERSION=${VERSION}" | |
echo ::set-output name=VERSION::${VERSION} | |
TAG_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || true) | |
echo "TAG_VERSION=${TAG_VERSION}" | |
echo ::set-output name=TAG_VERSION::${TAG_VERSION} | |
ARTIFACT="${REPO}-${BRANCH}" | |
echo "ARTIFACT=${ARTIFACT}" | |
echo ::set-output name=ARTIFACT::${REPO}-${BRANCH} | |
# [1-test-build-publish] | |
- name: Run tests | |
run: make test | |
# ![1-test-build-publish] | |
- name: Build artifacts | |
run: make bdist_wheel sdist twine-check | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
- name: Display artifacts | |
run: ls -lR dist | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
- name: Store artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ steps.get_vars.outputs.ARTIFACT }} | |
path: dist/* | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
deploy: | |
name: Publish | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
needs: | |
- build-test | |
runs-on: ubuntu-20.04 | |
env: | |
PY_COLORS: 1 | |
TOX_PARALLEL_NO_SPINNER: 1 | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
- name: Get variables | |
id: get_vars | |
run: | | |
REPO=$(basename ${{ github.repository }}) | |
echo "REPO=${REPO}" | |
echo ::set-output name=REPO::${REPO} | |
BRANCH=${GITHUB_REF##*/} | |
echo "BRANCH=${BRANCH}" | |
echo ::set-output name=BRANCH::${BRANCH} | |
ARTIFACT="${REPO}-${BRANCH}" | |
echo "ARTIFACT=${ARTIFACT}" | |
echo ::set-output name=ARTIFACT::${REPO}-${BRANCH} | |
- name: Display artifacts | |
run: | | |
ls -lR | |
# [2-test-build-publish] | |
- name: Publish release candidate artifacts to TestPyPI | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') && | |
contains(github.ref, 'rc') == true | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository_url: https://test.pypi.org/legacy/ | |
user: __token__ | |
password: ${{ secrets.PSEC_TEST_PYPI_PASSWORD }} | |
packages_dir: ${{ steps.get_vars.outputs.ARTIFACT }} | |
verify_metadata: false | |
- name: Publish tagged artifacts to PyPI | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') && | |
contains(github.ref, 'rc') == false | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PSEC_PYPI_PASSWORD }} | |
packages_dir: ${{ steps.get_vars.outputs.ARTIFACT }} | |
verify_metadata: false | |
# ![2-test-build-publish] | |