diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8850f8f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,44 @@ +name: Publish on PyPI +on: + release: + types: [published] +jobs: + pypi: + name: PyPI Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install setuptools --upgrade + python -m pip install packaging --upgrade + - name: Set pyproject version + run: | + echo "PACKAGE=$(python -c 'import setuptools; setuptools.setup()' --version)" >> $GITHUB_ENV + - name: Check package version (compare package version with tag) + id: check_package_version + shell: python + run: | + import os + from packaging.version import parse + package_version = os.getenv('PACKAGE') + if parse(package_version) != parse('${{ github.event.release.tag_name }}'): + print(f'version mismatch: {package_version} (in package) vs ${{ github.event.release.tag_name }} (GitHub tag)') + exit(1) + else: + print('version match') + exit(0) + - name: Create whl and tar.gz files in sdist + run: | + rm -rf docs/ Examples/ tests/ + make package + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + username: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + repository_url: https://upload.pypi.org/legacy/ \ No newline at end of file diff --git a/baytune/version.py b/baytune/version.py index 3d26edf..3d18726 100644 --- a/baytune/version.py +++ b/baytune/version.py @@ -1 +1 @@ -__version__ = "0.4.1" +__version__ = "0.5.0" diff --git a/release.md b/release.md new file mode 100644 index 0000000..584e891 --- /dev/null +++ b/release.md @@ -0,0 +1,55 @@ +# Release Process + +## 0. Pre-Release Checklist + +Before starting the release process, verify the following: + +- [GitHub Action for Unit Tests are green on main](https://github.com/MLBazaar/BTB/actions/workflows/tests.yml?query=branch:main) +- [GitHub Action for Install Tests are green on main](https://github.com/MLBazaar/BTB/actions/workflows/install_test.yaml?query=branch:main) +- Get agreement on the version number to use for the release. + +#### Version Numbering + +BTB uses [semantic versioning](https://semver.org/). Every release has a major, minor and patch version number, and are displayed like so: `..`. + +## 1. Create BTB release on GitHub + +#### Create Release Branch + +1. Branch off of BTB main. For the branch name, please use "release_vX.Y.Z" as the naming scheme (e.g. "release_v0.3.1"). + +#### Bump Version Number + +1. Bump `__version__` in `baytune/version.py`, and `tests/test_version.py`. + +#### Update Changelog + +1. Replace top most "What’s new in" in `docs/changelog.rst` with the current date + + ``` + What’s new in 0.3.1 (January 4, 2023) + ===================================== + ``` + +2. Remove any unused sections for this release (e.g. Enhancements, Fixes, Changes) +3. The release PR does not need to be mentioned in the list of changes + +#### Create Release PR + +A release PR should have **the version number as the title** and the notes for that release as the PR body text. + +Checklist before merging: + +- The title of the PR is the version number. +- All tests are currently green on checkin and on `main`. +- PR has been reviewed and approved. + +## 2. Create GitHub Release + +After the release pull request has been merged into the `main` branch, it is time draft [the GitHub release](https://github.com/HDI-Project/BTB/releases/new) + +- The target should be the `main` branch +- The tag should be the version number with a v prefix (e.g. v0.3.1) +- Release title is the same as the tag +- This is not a pre-release +- Publishing the release will automatically upload the package to PyPI \ No newline at end of file diff --git a/tests/test_version.py b/tests/test_version.py index 94dbf32..f3a1240 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -2,4 +2,4 @@ def test_version(): - assert __version__ == "0.4.1" + assert __version__ == "0.5.0"