Skip to content

Add create pull request and auto-merge PR to release workflow #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
3c176c8
Update release.yml
gsheni Jun 16, 2025
5c1df72
Update release.yml
gsheni Jun 17, 2025
17ea360
Update release.yml
gsheni Jun 17, 2025
fc82621
Update .gitignore
gsheni Jun 17, 2025
3290a67
Update release.yml
gsheni Jun 17, 2025
a8c9024
Update __init__.py
gsheni Jun 17, 2025
a12b2f6
Update release.yml
gsheni Jun 17, 2025
14326f8
Update release.yml
gsheni Jun 17, 2025
5844bf0
Update release.yml
gsheni Jun 17, 2025
a388543
Update release.yml
gsheni Jun 17, 2025
2b3b194
Update release.yml
gsheni Jun 17, 2025
2c157ed
Update release.yml
gsheni Jun 17, 2025
c554077
Update release.yml
gsheni Jun 17, 2025
47edeaa
Update release.yml
gsheni Jun 17, 2025
361ec38
Update __init__.py
gsheni Jun 17, 2025
9ba49d4
Update release.yml
gsheni Jun 17, 2025
1d0d521
Update release.yml
gsheni Jun 17, 2025
041ea99
Update __init__.py
gsheni Jun 17, 2025
e7f3e82
Update release.yml
gsheni Jun 17, 2025
b12f613
Update __init__.py
gsheni Jun 17, 2025
3bbf439
Update pyproject.toml
gsheni Jun 17, 2025
db846f1
Update __init__.py
gsheni Jun 17, 2025
3e5e3cc
Automated Bump Version Candidate (#481)
sdv-team Jun 17, 2025
b8287b1
Update release.yml
gsheni Jun 17, 2025
ba4dc1e
Update release.yml
gsheni Jun 17, 2025
72d7168
Update __init__.py
gsheni Jun 17, 2025
dd6f141
Update pyproject.toml
gsheni Jun 17, 2025
64ff1c8
Update pyproject.toml
gsheni Jun 17, 2025
94ebbbb
Update pyproject.toml
gsheni Jun 17, 2025
5a47d2f
Update release.yml
gsheni Jun 17, 2025
db17054
Update release.yml
gsheni Jun 17, 2025
5501f31
Update release.yml
gsheni Jun 17, 2025
dc44de4
Update release.yml
gsheni Jun 17, 2025
b6bc140
Update release.yml
gsheni Jun 17, 2025
33e08d6
Update __init__.py
gsheni Jun 17, 2025
e2349eb
Update pyproject.toml
gsheni Jun 17, 2025
163d135
Update pyproject.toml
gsheni Jun 17, 2025
08759b8
Update pyproject.toml
gsheni Jun 17, 2025
5a2c36a
Update pyproject.toml
gsheni Jun 17, 2025
cc14f43
Update __init__.py
gsheni Jun 17, 2025
1baeab5
Update release.yml
gsheni Jun 17, 2025
738060b
Update release.yml
gsheni Jun 17, 2025
e6055d1
Update pyproject.toml
gsheni Jun 17, 2025
e20772c
Update __init__.py
gsheni Jun 17, 2025
24b5ea6
Update release.yml
gsheni Jun 17, 2025
a896676
Update __init__.py
gsheni Jun 17, 2025
a4ccf79
Update pyproject.toml
gsheni Jun 17, 2025
cc0b5d1
Update release.yml
gsheni Jun 17, 2025
bc85fa4
Update __init__.py
gsheni Jun 17, 2025
5157fbb
Update pyproject.toml
gsheni Jun 17, 2025
bd92ae2
Update release.yml
gsheni Jun 17, 2025
6c35701
Update release.yml
gsheni Jun 17, 2025
6fcbef6
Update release.yml
gsheni Jun 17, 2025
29dab7f
Update __init__.py
gsheni Jun 17, 2025
0e40591
Update pyproject.toml
gsheni Jun 17, 2025
115ea74
Update release.yml
gsheni Jun 18, 2025
4b530b7
Update pyproject.toml
gsheni Jun 18, 2025
4edc7c5
Update __init__.py
gsheni Jun 18, 2025
2985d52
Update __init__.py
gsheni Jun 18, 2025
34596a0
Update __init__.py
gsheni Jun 18, 2025
d2a9333
Update pyproject.toml
gsheni Jun 18, 2025
50465b3
Update pyproject.toml
gsheni Jun 18, 2025
d0870f2
Update __init__.py
gsheni Jun 18, 2025
8b68d8d
Update RELEASE.md
gsheni Jun 18, 2025
313d5d7
Update Makefile
gsheni Jun 20, 2025
dfaeea8
update release.md
gsheni Jun 20, 2025
c7c6d12
cleanup
gsheni Jun 20, 2025
5eb0245
cleanup 2
gsheni Jun 20, 2025
bda6684
better header
gsheni Jun 20, 2025
9ac98b0
better text
gsheni Jun 20, 2025
8c373eb
better text
gsheni Jun 20, 2025
55fc673
better text
gsheni Jun 20, 2025
b227a70
remove tox
gsheni Jun 20, 2025
024dce7
remove tox 2
gsheni Jun 20, 2025
08d1ece
final cleanup
gsheni Jun 20, 2025
6e38d15
Update RELEASE.md
gsheni Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: Release
on:
release:
types: [published]

branches:
- main
- stable

workflow_dispatch:
inputs:
candidate:
Expand All @@ -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:
Expand All @@ -41,13 +46,38 @@ jobs:
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password can be removed because Copulas has been added as a trusted publisher for Test PyPI.

Note: For real PyPI, this is still a WIP.

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
if: ${{ inputs.candidate && !inputs.test_pypi }}
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'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the base branch (target branch) should be main always.


- 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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.github/.tmp/
tests/readme_test/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
157 changes: 55 additions & 102 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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:

Expand All @@ -142,101 +127,69 @@ 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 TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver

### General Improvements

* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver

### Bug Fixed

* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver
```

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-<version>-py2.py3-none-any.whl
└── copulas-<version>.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/<copulas-distribution-version-any>.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.
2 changes: 1 addition & 1 deletion copulas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'DataCebo, Inc.'
__email__ = '[email protected]'
__version__ = '0.12.4.dev0'
__version__ = '0.12.4.dev3'

import sys
import warnings
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ dev = [

# Advanced testing
'coverage >= 7.7.1, <7.8',
'tox >= 2.9.1,<4',
'invoke',

# Large scale evaluation
Expand Down Expand Up @@ -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<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?'
Expand Down Expand Up @@ -181,7 +180,6 @@ src = ["copulas"]
target-version = "py312"
exclude = [
"docs",
".tox",
".git",
"__pycache__",
".ipynb_checkpoints",
Expand Down
Loading
Loading