Skip to content

Run CI when tags are pushed #12

Run CI when tags are pushed

Run CI when tags are pushed #12

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:
jobs:
test_pyenv:
runs-on: ubuntu-latest
name: Test with pyenv
steps:
- name: Install python build tools
# Ref: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
run: |
sudo apt-get update -y
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
- name: Install pyenv
run: |
git clone https://github.com/pyenv/pyenv.git "$HOME/.pyenv"
PYENV_ROOT="$HOME/.pyenv"
PYENV_BIN="$PYENV_ROOT/bin"
echo "$PYENV_BIN" >> $GITHUB_PATH
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
- name: Check pyenv version
run: |
pyenv --version
- name: Cache pyenv installed version
uses: actions/cache@v4
with:
path: ~/.pyenv/versions
key: ${{ runner.os }}-pyenv-3.11.10-b
# Doing this beforehand should make the test itself faster
- name: Preinstall Python 3.11.10
run: |
pyenv install -v --skip-existing 3.11.10
- name: Checkout
uses: actions/checkout@v4
- name: Test with pytest
run: |
python3 -m pip install pytest
python3 -m pytest -v
publish:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: test_pyenv
permissions:
id-token: write # OIDC for uploading to PyPI
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Build packages
run: |
python3 -m pip install flit
flit build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1