Test #133
Workflow file for this run
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: GH | |
on: | |
pull_request: | |
push: | |
branches: [master] | |
release: | |
types: [released, prereleased] | |
workflow_dispatch: # allows running workflow manually from the Actions tab | |
jobs: | |
CI: | |
runs-on: ubuntu-20.04 | |
permissions: | |
id-token: write # codecov/codecov-action | |
strategy: | |
matrix: | |
python-version: ['2.7', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
if: matrix.python-version != '2.7' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up Python 2 | |
if: matrix.python-version == '2.7' | |
run: | | |
sudo rm -f $(which python) $(which pip) | |
sudo apt-get install python2.7-dev | |
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py | |
python2.7 get-pip.py | |
sudo ln -sf "$(which python2.7)" "$(dirname $(which python2.7))/python" | |
- name: Pip cache | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements/*.txt') }} | |
- name: Pre-commit cache | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: ~/.cache/pre-commit | |
key: ${{ runner.os }}-pre-commit-${{ matrix.python-version }}-${{ hashFiles('**/requirements/ci.txt') }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Expose github environment as shell variables | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) || '{}' }} | |
VARS_CONTEXT: ${{ toJson(vars) || '{}' }} | |
run: | | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
to_envs() { jq -r "to_entries[] | \"\(.key)<<$EOF\n\(.value)\n$EOF\n\""; } | |
echo "$VARS_CONTEXT" | to_envs >> $GITHUB_ENV | |
echo "$SECRETS_CONTEXT" | to_envs >> $GITHUB_ENV | |
env | |
- name: Install dependencies | |
run: | | |
pip install -U pip setuptools wheel | |
make install | |
- name: Lint | |
if: matrix.python-version == 3.12 | |
run: make lint | |
- name: Test | |
run: make test | |
- name: Docs | |
if: matrix.python-version == 3.12 | |
run: SPHINXOPTS=-W make builddocs | |
- uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
use_oidc: true | |
CD: | |
needs: [CI] | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # softprops/action-gh-release | |
id-token: write # pypa/gh-action-pypi-publish | |
issues: write # apexskier/github-release-commenter | |
pull-requests: write # apexskier/github-release-commenter | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Build | |
run: | | |
pip install -U pip setuptools wheel | |
python setup.py sdist bdist_wheel --universal | |
- name: Upload release assets | |
uses: softprops/action-gh-release@v2.0.8 | |
with: | |
files: dist/* | |
# https://github.com/pypa/gh-action-pypi-publish#trusted-publishing | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.10.2 | |
- uses: apexskier/github-release-commenter@v1 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
comment-template: | | |
Released {release_link} |