Skip to content

Commit

Permalink
Add configuration to publish library to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
XaF committed Sep 9, 2024
1 parent c955f04 commit 77f3e85
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,32 @@ jobs:
skipIfReleaseExists: true


push_library:
name: Push library to PyPI
runs-on: ubuntu-latest

needs:
- prepare-env
- push_release

steps:
- name: Checkout current commit
uses: "actions/checkout@v4"

- name: Install Hatch
uses: pypa/hatch@install

- name: Create version file
env:
VERSION: ${{ needs.prepare-env.outputs.release_version }}
run: |
echo "__version__ = \"${VERSION}\"" | tee build_version.py
- name: Publish to PyPI
run: |
hatch publish
auto-merge:
name: "Auto-merge Dependabot pull requests"
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.*.swp
.coverage
__pycache__/

# Library file to store version number
/build_version.py
# Library dist directory
/dist
33 changes: 33 additions & 0 deletions .omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ up:
- ./tests/requirements-tools.txt
- ./tests/requirements.txt
- ./tests/end-to-end/requirements.txt
- github-releases:
pypa/hatch: latest

commands:
test:
Expand All @@ -21,3 +23,34 @@ commands:
e2e:
desc: Run end-to-end tests
run: pytest --cache-clear tests/end-to-end/

build:
desc: Build the package
run: |
# Empty the build directory
rm -rf dist/
# Get the latest git tag
git_version=$(git describe --tags --dirty --always)
# Replace the first dash by a plus
version=$(echo ${git_version} | sed 's/-/+/')
# Write the version to the build version file
echo "__version__ = \"${version}\"" > build_version.py
# Build the package
hatch build
# Clean up
rm build_version.py
publish:
desc: Publish the package
run: |
# Get the latest git tag
git_version=$(git describe --tags --dirty --always)
clean_version=$(git describe --tags --abbrev=0)
# Check if the version values are the same
if [ "${git_version}" != "${clean_version}" ]; then
echo "The current version is not clean."
exit 1
fi
omni build
hatch publish
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "qolsys"
description = "Qolsys IQ Panel 2+ gateway API"
dynamic = ["version"]
dependencies = []
requires-python = ">=3.8"
authors = [
{name = "Raphaël Beamonte", email = "[email protected]"},
]
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["qolsys", "iq panel", "gateway", "api"]
classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",

# Indicate who your project is intended for
"Intended Audience :: Developers",

# Pick your license as you wish (see also "license" above)
"License :: OSI Approved :: MIT License",

# Specify the Python versions you support here.
"Programming Language :: Python :: 3",
]

[project.urls]
Homepage = "https://github.com/xaf/qolsysgw"
Documentation = "https://github.com/xaf/qolsysgw"
Repository = "https://github.com/xaf/qolsysgw.git"
Issues = "https://github.com/xaf/qolsysgw/issues"
Changelog = "https://github.com/xaf/qolsysgw/commits/main/"

[tool.hatch.version]
path = "build_version.py"

[tool.hatch.build]
skip-excluded-dirs = true

[tool.hatch.build.targets.sdist]
packages = ["apps/qolsysgw/qolsys"]
only-include = ["apps/qolsysgw/qolsys"]
sources = ["apps/qolsysgw"]

[tool.hatch.build.targets.wheel]
packages = ["apps/qolsysgw/qolsys"]
only-include = ["apps/qolsysgw/qolsys"]
sources = ["apps/qolsysgw"]

0 comments on commit 77f3e85

Please sign in to comment.