Skip to content

Commit

Permalink
chore: Setup automated semver bumps (#2118)
Browse files Browse the repository at this point in the history
* bump init

* bump init

* bump more config

* bump more config

* bump more config

* more comments

* init

* init

* init

* init

* update patcher

* update patcher

* testing

* testing

* testing

* prep for merge

* prep for merge
  • Loading branch information
tssweeney authored Sep 11, 2024
1 parent 5f734c3 commit e72440e
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: bump-python-sdk-version

# This workflow is used to bump the version of the Weave Python SDK.
# It will take 2 steps:
# 1. Drop the pre-release tag and push a new commit to the main branch.
# 2. Bump the version to the next pre-release version and push a new commit to the main branch.
#
# see weave/version.py for more details on the versioning scheme.

on:
workflow_dispatch:
inputs:
bump_type:
description: "Version bump type (major, minor, patch)"
required: true
default: "patch"
options:
- "patch"
- "minor"
- "major"

jobs:
build-assets:
name: Build frontend assets
runs-on: ubuntu-8core
timeout-minutes: 10
environment:
name: release
permissions:
contents: "write"
id-token: "write"
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.WANDBMACHINE_GITHUB_TOKEN }}
fetch-depth: 0
- id: "Setup Git"
run: |
git config --global user.name 'Weave Build Bot'
git config --global user.email [email protected]
- id: "Bump the version"
run: |
bump-my-version bump ${{ github.event.inputs.bump_type }} ./weave/version.py --tag --commit
git push
git push --tags
- id: "Start the next development cycle"
# This might seem weird to bump patch and then pre_n, but since semver
# dictates that pre-release versions have lower precedence, this ensures
# that the next commit on main will have a pre-release version.
run: |
bump-my-version bump patch ./weave/version.py
bump-my-version bump pre_n ./weave/version.py --commit
git push
git push --tags
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,37 @@ exclude = [
"weave/legacy/**/*.py",
"examples",
]

[tool.bumpversion]
current_version = "0.51.2-dev1"
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
(?P<patch>0|[1-9]\\d*)
(?:
- # dash separator for pre-release section
(?P<pre_l>[a-zA-Z-]+) # pre-release label
(?P<pre_n>0|[1-9]\\d*) # pre-release version number
)? # pre-release section is optional
"""
serialize = [
"{major}.{minor}.{patch}-{pre_l}{pre_n}",
"{major}.{minor}.{patch}",
]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
ignore_missing_files = false
tag = false
sign_tags = false
tag_name = "v{new_version}"
tag_message = "Release version: {current_version} → {new_version}"
allow_dirty = false
commit = false
message = "Release version: {current_version} → {new_version}"
commit_args = ""

[tool.bumpversion.parts.pre_l]
values = ["dev"]

1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ build
twine
lazydocs
nbconvert
bump-my-version
48 changes: 47 additions & 1 deletion weave/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
VERSION = "0.51.2"
"""Contains the version of the Weave SDK.
This version is used by pyproject.toml to specify the version of the Weave SDK and
imported by the library for runtime access. It must be kept in sync with pyproject.toml,
specifically the [tool.bumpversion] section:
```
[tool.bumpversion]
current_version = "M.m.p-dev0"
```
We use Semantic Versioning (https://semver.org/). The version number is in the format
MAJOR.MINOR.PATCH[-PRERELEASE].
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
For the most part, we are incrementing PATCH until we complete the core functionality.
As specified by Semantic Versioning, the PRERELEASE version is optional and can be
appended to the PATCH version. Specifically:
```
When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version:
Example: 1.0.0-alpha < 1.0.0.
```
The intention is to have a PRERELEASE version of the form of `dev0` for nearly every commit
on the main branch. However, the released commit will not have a PRERELEASE version. For example:
* Development happens on X.Y.Z-dev0
* Release commit bumps the version to >=X.Y.Z, noted X'.Y'.Z', tagging such commit
* Development continues on (>X.Y.Z)-dev0.
* Note: if X' == X, Y' == Y, and Z' == Z, then the version is bumped to X'.Y'.(Z'+1)-dev0. Else, the version is bumped to X'.Y'.Z'-dev0.
This is all facilitated using `make bumpversion` which is a wrapper around `bump-my-version`.
Please see the `bump-my-version` documentation for more information:
https://github.com/callowayproject/bump-my-version. Additional configuration can be found in
`pyproject.toml`.
"""

VERSION = "0.51.2-dev1"

0 comments on commit e72440e

Please sign in to comment.