Skip to content

Commit

Permalink
Merge pull request #54 from OpenMined/versioning
Browse files Browse the repository at this point in the history
Add versioning
  • Loading branch information
yashgorana authored Oct 8, 2024
2 parents 674e541 + 07da29f commit aae6c6d
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[bumpversion]
current_version = 0.1.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}

[bumpversion:file:pyproject.toml]

[bumpversion:file:syftbox/__version__.py]
73 changes: 73 additions & 0 deletions .github/workflows/cd-release.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,34 @@ deploy keyfile remote="[email protected]": 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')]
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion syftbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = "0.1.0"
11 changes: 11 additions & 0 deletions syftbox/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ____ __ _ ____
# / ___| _ _ / _| |_| __ ) _____ __
# \___ \| | | | |_| __| _ \ / _ \ \/ /
# ___) | |_| | _| |_| |_) | (_) > <
# |____/ \__, |_| \__|____/ \___/_/\_\
# |___/

__title__ = "SyftBox"
__description__ = ""
__url__ = "https://openmined.org"
__version__ = "0.1.0"
13 changes: 12 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aae6c6d

Please sign in to comment.