diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ca565ca..c3159ced 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,10 @@ name: Release on: release: types: [published] - + branches: + - main + - stable + workflow_dispatch: inputs: candidate: @@ -12,13 +15,15 @@ on: type: boolean default: true test_pypi: - description: 'Test PyPi.' + description: 'Test PyPI.' type: boolean default: false jobs: release: runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v4 with: @@ -41,7 +46,6 @@ jobs: - name: Publish a Python distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ inputs.test_pypi && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }} repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} - name: Bump version to next candidate @@ -49,5 +53,31 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - make bumpversion-candidate - make git-push + bump-my-version bump candidate --no-tag --no-commit + + - name: Create pull request + if: ${{ inputs.candidate && !inputs.test_pypi }} + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GH_ACCESS_TOKEN }} + commit-message: bumpversion-candidate + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + signoff: false + delete-branch: true + title: Automated Bump Version Candidate + body: "This is an auto-generated PR that bumps the version to the next candidate." + branch: bumpversion-candidate-update + branch-suffix: short-commit-hash + add-paths: | + copulas/__init__.py + pyproject.toml + draft: false + base: 'main' + + - name: Enable Pull Request Automerge + if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }} + run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --admin + env: + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} diff --git a/.gitignore b/.gitignore index 9f2f0274..3a922f41 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.github/.tmp/ +tests/readme_test/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/Makefile b/Makefile index 2093dbdd..8ad757a9 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,10 @@ install-test: clean-build clean-pyc ## install the package and test dependencies install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development pip install -e .[dev] +.PHONY: install-readme +install-readme: clean-build clean-pyc ## install the package in editable mode and readme dependencies for developement + pip install -e .[readme] + # LINT TARGETS .PHONY: lint @@ -117,10 +121,6 @@ test-tutorials: ## run the tutorials notebooks .PHONY: test test: test-unit test-numerical test-end-to-end test-tutorials test-readme ## run all the tests -.PHONY: test-all -test-all: ## test everything using tox - tox -r - .PHONY: coverage coverage: ## check code coverage quickly with the default Python coverage run --source copulas -m pytest @@ -188,7 +188,7 @@ git-push-tags-stable: ## Push tags and stable to github .PHONY: bumpversion-release bumpversion-release: ## Bump the version to the next release - bump-my-version bump release + bump-my-version bump release --no-tag .PHONY: bumpversion-patch bumpversion-patch: ## Bump the version to the next patch diff --git a/RELEASE.md b/RELEASE.md index 0b4ec462..9c581e0d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -14,16 +14,15 @@ The process of releasing a new version involves several steps: 6. [Milestone](#milestone) -7. [HISTORY.md](#history.md) +7. [Update HISTORY](#update-history) -8. [Distribution](#distribution) +8. [Check the release](#check-the-release) -9. [Making the release](#making-the-release) +8. [Update stable branch and bump version](#update-stable-branch-and-bump-version) -9.1. [Tag and release to PyPi](#tag-and-release-to-pypi) - -9.2. [Update the release on GitHub](#update-the-release-on-github) +10. [Create the Release on GitHub](#create-the-release-on-github) +11. [Close milestone and create new milestone](#close-milestone-and-create-new-milestone) ## Install Copulas from source @@ -34,31 +33,12 @@ git clone https://github.com/sdv-dev/Copulas.git cd Copulas git checkout main make install-develop +make install-readme ``` ## Linting and tests -Execute ALL the tests and linting, tests must end with no errors: - -```bash -make test-all -``` - -This command will use tox to execute the unittests with different environments, see tox.ini configuration. - -To be able to run this you will need the different python versions used in the tox.ini file. - -At the end, you will see an output like this: - -``` -_____________________________________________ summary ______________________________________________ - py35: commands succeeded - py36: commands succeeded - lint: commands succeeded - docs: commands succeeded -``` - -To run the tests over your python version: +Execute the tests and linting. The tests must end with no errors: ```bash make test && make lint @@ -67,13 +47,17 @@ make test && make lint And you will see something like this: ``` -============================ 169 passed, 1 skipped, 3 warnings in 7.10s ============================ -flake8 copulas tests examples -isort -c copulas tests examples +Coverage XML written to file ./integration_cov.xml +====================== 81 passed, 7820 warnings in 23.54s ====================== +... +invoke lint +No broken requirements found. +All checks passed! +86 files already formatted ``` -The execution has finished with no errors, 1 test skipped and 3 warnings. - +The execution has finished with no errors, 0 test skipped and 7820 warnings. + ## Documentation The documentation must be up to date and generated with: @@ -94,8 +78,9 @@ make docs 1. On the Copulas GitHub page, navigate to the [Actions][actions] tab. 2. Select the `Release` action. -3. Run it on the main branch. Make sure `Release candidate` is checked and `Test PyPi` is not. -4. Check on [PyPi][copulas-pypi] to assure the release candidate was successfully uploaded. +3. Run it on the main branch. Make sure `Release candidate` is checked and `Test PyPI` is not. +4. Check on [PyPI][copulas-pypi] to assure the release candidate was successfully uploaded. + - You should see X.Y.ZdevN PRE-RELEASE [actions]: https://github.com/sdv-dev/Copulas/actions [copulas-pypi]: https://pypi.org/project/copulas/#history @@ -112,7 +97,7 @@ Before doing the actual release, we need to test that the candidate works with S git checkout -b test-copulas-X.Y.Z ``` -2. Update the pyproject.toml to set the minimum version of Copulas to be the same as the version of the release. For example, +2. Update the pyproject.toml to set the minimum version of Copulas to be the same as the version of the release. For example, ```toml 'copulas>=X.Y.Z.dev0' @@ -130,7 +115,7 @@ git push --set-upstream origin test-copulas-X.Y.Z ## Milestone -It's important check that the git hub and milestone issues are up to date with the release. +It's important check that the GitHub and milestone issues are up to date with the release. You neet to check that: @@ -142,25 +127,26 @@ You neet to check that: - All the pull requests closed since the latest release are associated to an issue. If necessary, create issues and assign them to the milestone. Also assigne the person who opened the issue to them. -## HISTORY.md +## Update HISTORY +Run the [Release Prep](https://github.com/sdv-dev/Copulas/actions/workflows/prepare_release.yml) workflow. This workflow will create a pull request with updates to HISTORY.md Make sure HISTORY.md is updated with the issues of the milestone: ``` # History - + ## X.Y.Z (YYYY-MM-DD) - + ### New Features - + * - [Issue #](https://github.com/sdv-dev/Copulas/issues/) by @resolver - + ### General Improvements - + * - [Issue #](https://github.com/sdv-dev/Copulas/issues/) by @resolver - + ### Bug Fixed - + * - [Issue #](https://github.com/sdv-dev/Copulas/issues/) by @resolver ``` @@ -168,75 +154,42 @@ The issue list per milestone can be found [here][milestones]. [milestones]: https://github.com/sdv-dev/Copulas/milestones -## Distribution +Put the pull request up for review and get 2 approvals to merge into `main`. -Generate the distribution executing: +## Check the release +Once HISTORY.md has been updated on `main`, check if the release can be made: ```bash -make dist -``` - -This will create a `dist` and `build` directories. The `dist` directory contains the library installer. - -``` -dist/ -├── copulas--py2.py3-none-any.whl -└── copulas-.tar.gz -``` - -Now, create a new virtualenv with the distributed file generated and run the README.md examples: - -1. Create the copulas-test directory (out of the Copulas directory): - -```bash -mkdir copulas-test -cd copulas-test -``` - -2. Create a new virtuelenv and activate it: - -```bash -virtualenv -p $(which python3.6) .venv -source .venv/bin/activate -``` - -3. Install the wheel distribution: - -```bash -pip install /path/to/copulas/dist/.whl +make check-release ``` -4. Now you are ready to execute the README.md examples. - -## Making the release +## Update stable branch and bump version +The `stable` branch needs to be updated with the changes from `main` and the version needs to be bumped. +Depending on the type of release, run one of the following: -At the end, we need to make the release. First, check if the release can be made: +* `make release`: This will release a patch, which is the most common type of release. Use this when the changes are bugfixes or enhancements that do not modify the existing user API. Changes that modify the user API to add new features but that do not modify the usage of the previous features can also be released as a patch. +* `make release-minor`: This will release the next minor version. Use this if the changes modify the existing user API in any way, even if it is backwards compatible. Minor backwards incompatible changes can also be released as minor versions while the library is still in beta state. After the major version 1 has been released, minor version can only be used to add backwards compatible API changes. +* `make release-major`: This will release the next major version. Use this to if the changes modify the user API in a backwards incompatible way after the major version 1 has been released. -```bash -make check-release -``` +Running one of these will **push commits directly** to `main`. +At the end, you should see the 2 commits on `main` on (from oldest to newest): +- `make release-tag: Merge branch 'main' into stable` +- `Bump version: X.Y.Z.devN → X.Y.Z` -### Tag and release to PyPi +## Create the Release on GitHub -Once we are sure that the release can be made we can use different commands depending on -the type of release that we want to make: +After the update to HISTORY.md is merged into `main` and the version is bumped, it is time to [create the release GitHub](https://github.com/sdv-dev/Copulas/releases/new). +- Create a new tag with the version number with a v prefix (e.g. v0.3.1) +- The target should be the `main` branch +- Release title is the same as the tag (e.g. v0.3.1) +- This is not a pre-release (`Set as a pre-release` should be unchecked) -* `make release`: This will relase a patch, which is the most common type of release. Use this - when the changes are bugfixes or enhancements that do not modify the existing user API. Changes - that modify the user API to add new features but that do not modify the usage of the previous - features can also be released as a patch. -* `make release-minor`: This will release the next minor version. Use this if the changes modify - the existing user API in any way, even if it is backwards compatible. Minor backwards incompatible - changes can also be released as minor versions while the library is still in beta state. - After the major version 1 has been released, minor version can only be used to add backwards - compatible API changes. -* `make release-major`: This will release the next major version. Use this to if the changes modify - the user API in a backwards incompatible way after the major version 1 has been released. +Click `Publish release`, which will kickoff the release workflow and automatically upload the package to public PyPI. +The release workflow will create a pull request and auto-merge it into `main` that bumps to the next development release. You should see 1 commit on main on: +- `Bump version: X.Y.Z → X.Y.Z.dev0` -### Update the release on GitHub +## Close milestone and create new milestone -Once the tag and the release to PyPi has been made, go to GitHub and edit the freshly created "tag" to -add the title and release notes, which should be exactly the same that we added to the HISTORY.md file. +Finaly, **close the milestone** and, if it does not exist, **create the next milestone**. -Finaly, close the milestone and, if it does not exit, create the next one. diff --git a/copulas/__init__.py b/copulas/__init__.py index 60760735..addc9f84 100644 --- a/copulas/__init__.py +++ b/copulas/__init__.py @@ -2,7 +2,7 @@ __author__ = 'DataCebo, Inc.' __email__ = 'info@sdv.dev' -__version__ = '0.12.4.dev0' +__version__ = '0.12.4.dev3' import sys import warnings diff --git a/pyproject.toml b/pyproject.toml index 7d979c05..bb5633af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,6 @@ dev = [ # Advanced testing 'coverage >= 7.7.1, <7.8', - 'tox >= 2.9.1,<4', 'invoke', # Large scale evaluation @@ -152,7 +151,7 @@ namespaces = false ] [tool.bumpversion] -current_version = "0.12.4.dev0" +current_version = "0.12.4.dev3" commit = true tag = true parse = '(?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))?' @@ -181,7 +180,6 @@ src = ["copulas"] target-version = "py312" exclude = [ "docs", - ".tox", ".git", "__pycache__", ".ipynb_checkpoints", diff --git a/tox.ini b/tox.ini deleted file mode 100644 index b3583190..00000000 --- a/tox.ini +++ /dev/null @@ -1,26 +0,0 @@ -[tox] -envlist = py39-lint, py3{8,9,10,11,12,13}-{readme,unit,end_to_end,numerical,minimum,tutorials} - -[testenv] -skipsdist = false -skip_install = false -deps = - invoke - readme: rundoc - tutorials: jupyter -extras = - lint: dev - minimum: test - unit: test - end_to_end: test - numerical: test - tutorials: tutorials -commands = - lint: invoke lint - readme: invoke readme - unit: invoke unit - end_to_end: invoke end-to-end - numerical: invoke numerical - minimum: invoke minimum - tutorials: invoke tutorials - invoke rmdir --path {envdir}