Skip to content

bump version

bump version #154

Workflow file for this run

# Deployment workflow
# This is a GitHub Actions workflow that tests, builds, and deploys this package.
# Workflow syntax for GitHub Actions
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Python package automatic deployment
# This workflow will run when the following conditions are met
on:
# Pushes to the main branch
push:
branches: [ "main" ]
# Pull requests that target the main branch
pull_request:
branches: [ "main" ]
release:
types: [ published ]
defaults:
run:
working-directory: ./backend/
jobs:
test-backend:
name: Test backend
# # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
runs-on: "ubuntu-22.04"
strategy:
fail-fast: false
matrix:
# https://devguide.python.org/versions/
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -e .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Check command line interface
run: |
btviewer --version
build-backend:
name: Build backend
runs-on: ubuntu-22.04
needs:
- test-backend
- build-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tool
run: |
python -m pip install --upgrade pip
python -m pip install build --user
- name: Get frontend distributable files
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: backend/btviewer/static/
- name: Copy files
run: |
cp --verbose ../README* .
cp --verbose ../LICENSE .
cp --verbose ../CITATION.cff .
- name: Build a binary wheel and a source tarball
run: python -m build . --outdir ./dist/
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: backend/dist/
if-no-files-found: error
# Build frontend user interface
build-frontend:
name: Build frontend
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./frontend/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.4'
- name: Clean install the npm project
run: npm ci
# TODO
#- run: npm run lint
#- run: npm test
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist/
if-no-files-found: error
# OpenID Connect token that the pypi-publish actions needs to implement secretless trusted publishing to PyPI
# https://docs.pypi.org/trusted-publishers/
publish-to-test-pypi:
name: Publish to test PyPI
needs:
- build-backend
- build-frontend
runs-on: ubuntu-22.04
# https://test.pypi.org/manage/project/btviewer/settings/publishing/
environment:
name: testpypi
url: https://test.pypi.org/project/btviewer/
permissions:
# IMPORTANT: mandatory for trusted publishing
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
# https://github.com/marketplace/actions/pypi-publish
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# Don't complain on repeat uploads for the same package version
# https://github.com/marketplace/actions/pypi-publish#tolerating-release-package-file-duplicates
skip-existing: true
verbose: true
publish-to-pypi:
name: Publish to PyPI
# Only publish on tag pushes (releases)
if: startsWith(github.ref, 'refs/tags/')
needs:
- publish-to-test-pypi
runs-on: ubuntu-22.04
environment:
name: pypi
url: https://pypi.org/project/btviewer/
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
# https://github.com/marketplace/actions/pypi-publish
# https://stackoverflow.com/questions/72661025/github-action-publishing-to-both-testpypi-and-pypi-fails#:~:text=PyPI%20doesn't%20allow%20to,get%20File%20already%20exists%20error.&text=GitHub%20actions%20will%20upload%20the,you%20push%20to%20the%20repository.
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1