Skip to content

GitHub Actions: Deprecating set-output commands #191

GitHub Actions: Deprecating set-output commands

GitHub Actions: Deprecating set-output commands #191

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
uses: actions/setup-python@v3
with:
python-version: 3.9.16
- uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
python-version: 3.9.16
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}" >> $GITHUB_OUTPUT
BRANCH=${GITHUB_REF##*/}
echo "BRANCH=${BRANCH}" >> $GITHUB_OUTPUT
VERSION=$(python3 setup.py --version 2>/dev/null)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
TAG_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || true)
echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_OUTPUT
ARTIFACT="${REPO}-${BRANCH}"
echo "ARTIFACT=${ARTIFACT}" >> $GITHUB_OUTPUT
# [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}" >> $GITHUB_OUTPUT
BRANCH=${GITHUB_REF##*/}
echo "BRANCH=${BRANCH}" >> $GITHUB_OUTPUT
ARTIFACT="${REPO}-${BRANCH}"
echo "ARTIFACT=${ARTIFACT}" >> $GITHUB_OUTPUT
- 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]