Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import re
import sys


def bump_type(commit_message: str) -> str:
first_line = commit_message.splitlines()[0].lower()

if "breaking change" in commit_message.lower() or "!:" in first_line or "!)" in first_line:
return "major"
if first_line.startswith("feat"):
return "minor"
return "patch"


def main() -> None:
commit_message = sys.argv[1]
print(bump_type(commit_message))


if __name__ == "__main__":
main()
43 changes: 40 additions & 3 deletions .github/workflows/ci-main-build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- master
- ci-test

permissions:
contents: write

jobs:
build-n-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -45,16 +48,50 @@ jobs:
with:
filters: |
pyemd_version:
- 'PyEMD/__init__.py'
- 'pyproject.toml'
- name: Check if version is updated
if: ${{ steps.version.outputs.pyemd_version == 'true'}}
run: echo "PyEMD version is updated"
- name: Check if version is not updated
if: ${{ steps.version.outputs.pyemd_version == 'false'}}
run: echo "PyEMD version is not updated"

bump-version:
if: ${{ github.actor != 'github-actions[bot]' }}
runs-on: ubuntu-latest
needs: build-n-test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install uv
uses: astral-sh/setup-uv@v6
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
code:
- 'PyEMD/**/*.py'
- 'pyproject.toml'
- '!PyEMD/__init__.py'
- name: Bump package version
id: bump
if: ${{ steps.changes.outputs.code == 'true' }}
run: |
BUMP=$(python .github/scripts/bump_version.py "${{ github.event.head_commit.message }}")
echo "bump=$BUMP" >> $GITHUB_OUTPUT
uv version --bump "$BUMP"
- name: Commit version bump
if: ${{ steps.changes.outputs.code == 'true' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "chore: bump package version"
git push

deploy:
# Run 'deploy' job only if `PyEMD/__init__.py` is modified
# Run 'deploy' job only if the package version is modified
if: needs.version-updated.outputs.pyemd_version == 'true'
needs: version-updated
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,7 +125,7 @@ jobs:
- name: Get version
id: get_version
run: |
VERSION=$(grep -oP '__version__ = "\K[^"]+' PyEMD/__init__.py)
VERSION=$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
Expand Down
7 changes: 6 additions & 1 deletion PyEMD/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import logging
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("EMD-signal")
except PackageNotFoundError:
__version__ = "0+unknown"

__version__ = "1.9.0"
logger = logging.getLogger("pyemd")

from PyEMD.CEEMDAN import CEEMDAN # noqa
Expand Down
5 changes: 1 addition & 4 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 = "EMD-signal"
dynamic = ["version"]
version = "1.10.0"
description = "Implementation of the Empirical Mode Decomposition (EMD) and its variations"
readme = "README.md"
license = { text = "Apache-2.0" }
Expand Down Expand Up @@ -49,9 +49,6 @@ test = [
Homepage = "https://github.com/laszukdawid/PyEMD"
Repository = "https://github.com/laszukdawid/PyEMD"

[tool.setuptools.dynamic]
version = { attr = "PyEMD.__version__" }

[tool.setuptools.packages.find]
include = ["PyEMD*"]

Expand Down
Loading