diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 00000000..7a02aa92 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,9 @@ +[bumpversion] +current_version = 0.1.0 +parse = (?P\d+)\.(?P\d+)\.(?P\d+) +serialize = + {major}.{minor}.{patch} + +[bumpversion:file:pyproject.toml] + +[bumpversion:file:syftbox/__version__.py] diff --git a/.github/workflows/cd-release.yaml b/.github/workflows/cd-release.yaml new file mode 100644 index 00000000..3d6b028d --- /dev/null +++ b/.github/workflows/cd-release.yaml @@ -0,0 +1,73 @@ +name: CD - SyftBox + +on: + workflow_dispatch: + inputs: + bump_type: + description: "Version bump type" + type: choice + default: patch + options: + - patch + - minor + - major + + test_bump: + description: "Perform a test bump version without pushing to pypi and repo" + type: boolean + default: false + +# Prevents concurrent runs of the same workflow +# while the previous run is still in progress +concurrency: + group: "CD - SyftBox" + cancel-in-progress: false + +jobs: + deploy-syftbox: + runs-on: ubuntu-latest + + steps: + - name: Checkout SyftBox repo with github token + uses: actions/checkout@v4 + with: + token: ${{ secrets.SYFTBOX_BOT_COMMIT_TOKEN }} + + - name: Configure git user + run: | + git config user.name "${{ secrets.OM_BOT_NAME }}" + git config user.email "${{ secrets.OM_BOT_EMAIL }}" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install uv==0.4.19 twine + uv --version + + - name: Install Just + uses: extractions/setup-just@v2 + with: + just-version: "1.36.0" + + - name: Bump the Version + run: | + just bump-version ${{ inputs.bump_type }} + + - name: Build syftbox + run: | + just build + + - name: Push to pypi + if: ${{ inputs.test_bump == false }} + run: | + twine upload -u __token__ -p ${{ secrets.OM_SYFTBOX_PYPI_TOKEN }} dist/* + + - name: Push changes to SyftBox repo + if: ${{ inputs.test_bump == false }} + run: | + git push origin main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d29e38f..66996fb5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: always_run: true - id: trailing-whitespace always_run: true + exclude: .bumpversion.cfg - id: check-docstring-first always_run: true - id: check-json diff --git a/justfile b/justfile index 6ee621ff..7f4ac44b 100644 --- a/justfile +++ b/justfile @@ -107,6 +107,34 @@ deploy keyfile remote="azureuser@20.168.10.234": build echo -e "{{ _green }}Deploy successful!{{ _nc }}" +# Bump version, commit and tag +[group('build')] +bump-version level="patch": + #!/bin/bash + # We need to uv.lock before we can commit the whole thing in the repo. + # DO not bump the version on the uv.lock file, else other packages with same version might get updated + + set -eou pipefail + + # sync everything + uv sync --extra dev + + # get the current and new version + BUMPVERS_CHANGES=$(uv run bump2version --dry-run --allow-dirty --list {{ level }}) + CURRENT_VERSION=$(echo "$BUMPVERS_CHANGES" | grep current_version | cut -d'=' -f2) + NEW_VERSION=$(echo "$BUMPVERS_CHANGES" | grep new_version | cut -d'=' -f2) + echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION" + + # first bump version + uv run bump2version {{ level }} + + # update uv.lock file to reflect new package version + uv lock + + # commit the changes + git commit -am "Bump version $CURRENT_VERSION -> $NEW_VERSION" + git tag -a $NEW_VERSION -m "Release $NEW_VERSION" + # --------------------------------------------------------------------------------------------------------------------- [group('utils')] diff --git a/pyproject.toml b/pyproject.toml index 89499cd3..fe85da9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,15 @@ syftbox = "syftbox.main:main" pythonpath = ["."] [project.optional-dependencies] -dev = ["pytest", "pytest-xdist[psutil]", "pytest-cov", "mypy", "uv", "ruff"] +dev = [ + "pytest", + "pytest-xdist[psutil]", + "pytest-cov", + "mypy", + "uv", + "ruff", + "bump2version", +] [tool.ruff] diff --git a/syftbox/__init__.py b/syftbox/__init__.py index 3dc1f76b..e69de29b 100644 --- a/syftbox/__init__.py +++ b/syftbox/__init__.py @@ -1 +0,0 @@ -__version__ = "0.1.0" diff --git a/syftbox/__version__.py b/syftbox/__version__.py new file mode 100644 index 00000000..222439bb --- /dev/null +++ b/syftbox/__version__.py @@ -0,0 +1,11 @@ +# ____ __ _ ____ +# / ___| _ _ / _| |_| __ ) _____ __ +# \___ \| | | | |_| __| _ \ / _ \ \/ / +# ___) | |_| | _| |_| |_) | (_) > < +# |____/ \__, |_| \__|____/ \___/_/\_\ +# |___/ + +__title__ = "SyftBox" +__description__ = "" +__url__ = "https://openmined.org" +__version__ = "0.1.0" diff --git a/uv.lock b/uv.lock index 2ded3862..1f642e21 100644 --- a/uv.lock +++ b/uv.lock @@ -45,6 +45,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/13/b5/7af0cb920a476dccd612fbc9a21a3745fb29b1fcd74636078db8f7ba294c/APScheduler-3.10.4-py3-none-any.whl", hash = "sha256:fb91e8a768632a4756a585f79ec834e0e27aad5860bac7eaa523d9ccefd87661", size = 59303 }, ] +[[package]] +name = "bump2version" +version = "1.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/29/2a/688aca6eeebfe8941235be53f4da780c6edee05dbbea5d7abaa3aab6fad2/bump2version-1.0.1.tar.gz", hash = "sha256:762cb2bfad61f4ec8e2bdf452c7c267416f8c70dd9ecb1653fd0bbb01fa936e6", size = 36236 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/e3/fa60c47d7c344533142eb3af0b73234ef8ea3fb2da742ab976b947e717df/bump2version-1.0.1-py2.py3-none-any.whl", hash = "sha256:37f927ea17cde7ae2d7baf832f8e80ce3777624554a653006c9144f8017fe410", size = 22030 }, +] + [[package]] name = "certifi" version = "2024.8.30" @@ -433,7 +442,7 @@ name = "importlib-metadata" version = "8.5.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "zipp" }, + { name = "zipp", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/cd/12/33e59336dca5be0c398a7482335911a33aa0e20776128f038019f1a95f1b/importlib_metadata-8.5.0.tar.gz", hash = "sha256:71522656f0abace1d072b9e5481a48f07c138e00f079c38c8f883823f9c26bd7", size = 55304 } wheels = [ @@ -1100,6 +1109,7 @@ dependencies = [ [package.optional-dependencies] dev = [ + { name = "bump2version" }, { name = "mypy" }, { name = "pytest" }, { name = "pytest-cov" }, @@ -1111,6 +1121,7 @@ dev = [ [package.metadata] requires-dist = [ { name = "apscheduler", specifier = ">=3.10.4" }, + { name = "bump2version", marker = "extra == 'dev'" }, { name = "cryptography", specifier = ">=43.0.1" }, { name = "fastapi", specifier = ">=0.114.0" }, { name = "jinja2", specifier = ">=3.1.4" },