Skip to content

Merge pull request #23 from bbergerud/pypi_workflow #12

Merge pull request #23 from bbergerud/pypi_workflow

Merge pull request #23 from bbergerud/pypi_workflow #12

Workflow file for this run

name: tenops (tensor operations)
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Poetry
run: pipx install poetry
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install
- name: Run tests
run: |
poetry run coverage run -m pytest -v
poetry run coverage report
poetry run coverage html
- name: Achive code coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: htmlcov
release:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
contents: write
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Poetry
run: pipx install poetry
- name: Run semantic release
uses: python-semantic-release/python-semantic-release@master
id: semantic
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
if: steps.semantic.outputs.new_release_published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry build
- name: Publish to TestPyPI
if: steps.semantic.outputs.new_release_published == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: steps.semantic.outputs.new_release_published == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}