[pre-commit.ci] pre-commit autoupdate #520
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 and Tag | |
# Runs on every push to run the unit tests. | |
# Additionally, if on main, reads the current version from setup.py and then creates a new tag and release named | |
# for that version. | |
# If a tag already exists with that name, the Create Release step is skipped. | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- "**/README.md" | |
jobs: | |
run-unit-tests: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup python | |
id: setup_python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Run tests | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate && python -m pip install --upgrade pip && pip install -r requirements-dev.txt | |
pytest | |
create-release: | |
runs-on: ubuntu-latest | |
needs: run-unit-tests | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup python | |
id: setup_python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Get package version | |
id: package_version | |
run: echo "app_version="$(python setup.py --version) >> $GITHUB_OUTPUT | |
- name: Check if tag exists | |
uses: mukunku/tag-exists-action@v1.0.0 | |
id: check_tag | |
with: | |
tag: ${{ steps.package_version.outputs.app_version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: ncipollo/release-action@v1 | |
name: Create Release | |
id: create_release | |
if: ${{ steps.check_tag.outputs.exists == 'false' }} | |
with: | |
commit: main | |
tag: ${{ steps.package_version.outputs.app_version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
publish-release: | |
runs-on: ubuntu-latest | |
needs: create-release | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup python | |
id: setup_python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Build for publish | |
id: build_dist | |
run: | | |
python -m pip install --upgrade pip && pip install build | |
python -m build | |
echo workspace dir $GITHUB_WORKSPACE | |
- name: Publish to PyPI | |
id: publish-to-pypi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |