Skip to content

Commit

Permalink
Adds GH publish workflow.
Browse files Browse the repository at this point in the history
Moves version back to pyproject.toml
Uses importlib to provide __version__ in package __init__
  • Loading branch information
gadamc committed Feb 7, 2023
1 parent 610d384 commit 6b96b16
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "nipiezojenapy"
dynamic = ["version"] # version is defined in __init__.py
version = "1.0.1.dev2"

description = "A package for controlling Jena PiezoSystem NV40 3CLE amplifier vi NIDAQMX."
readme = "README.md"
Expand Down Expand Up @@ -56,5 +56,3 @@ dependencies = [
[project.scripts]
qt3piezo = "applications.tkcontrollerapp:main"

[tool.setuptools.dynamic]
version = {attr = "nipiezojenapy.__version__"}
4 changes: 2 additions & 2 deletions src/nipiezojenapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .controller import PiezoControl, BaseControl

__version__ = '1.0.1.dev0'
from importlib.metadata import version
__version__ = version(__package__)

0 comments on commit 6b96b16

Please sign in to comment.