Skip to content

Commit 4c4a93e

Browse files
gshenisdv-teamgithub-actions[bot]rwedge
authored
Add create pull request and auto-merge PR to release workflow (#479)
Co-authored-by: SDV Team <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Roy Wedge <[email protected]>
1 parent 725688f commit 4c4a93e

File tree

7 files changed

+100
-142
lines changed

7 files changed

+100
-142
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name: Release
33
on:
44
release:
55
types: [published]
6-
6+
branches:
7+
- main
8+
- stable
9+
710
workflow_dispatch:
811
inputs:
912
candidate:
@@ -12,13 +15,15 @@ on:
1215
type: boolean
1316
default: true
1417
test_pypi:
15-
description: 'Test PyPi.'
18+
description: 'Test PyPI.'
1619
type: boolean
1720
default: false
1821

1922
jobs:
2023
release:
2124
runs-on: ubuntu-latest
25+
permissions:
26+
id-token: write
2227
steps:
2328
- uses: actions/checkout@v4
2429
with:
@@ -41,13 +46,38 @@ jobs:
4146
- name: Publish a Python distribution to PyPI
4247
uses: pypa/gh-action-pypi-publish@release/v1
4348
with:
44-
password: ${{ inputs.test_pypi && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
4549
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
4650

4751
- name: Bump version to next candidate
4852
if: ${{ inputs.candidate && !inputs.test_pypi }}
4953
run: |
5054
git config user.name "github-actions[bot]"
5155
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
52-
make bumpversion-candidate
53-
make git-push
56+
bump-my-version bump candidate --no-tag --no-commit
57+
58+
- name: Create pull request
59+
if: ${{ inputs.candidate && !inputs.test_pypi }}
60+
id: cpr
61+
uses: peter-evans/create-pull-request@v4
62+
with:
63+
token: ${{ secrets.GH_ACCESS_TOKEN }}
64+
commit-message: bumpversion-candidate
65+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
66+
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
67+
signoff: false
68+
delete-branch: true
69+
title: Automated Bump Version Candidate
70+
body: "This is an auto-generated PR that bumps the version to the next candidate."
71+
branch: bumpversion-candidate-update
72+
branch-suffix: short-commit-hash
73+
add-paths: |
74+
copulas/__init__.py
75+
pyproject.toml
76+
draft: false
77+
base: 'main'
78+
79+
- name: Enable Pull Request Automerge
80+
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
81+
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --admin
82+
env:
83+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.github/.tmp/
2+
tests/readme_test/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ install-test: clean-build clean-pyc ## install the package and test dependencies
8181
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
8282
pip install -e .[dev]
8383

84+
.PHONY: install-readme
85+
install-readme: clean-build clean-pyc ## install the package in editable mode and readme dependencies for developement
86+
pip install -e .[readme]
87+
8488
# LINT TARGETS
8589

8690
.PHONY: lint
@@ -117,10 +121,6 @@ test-tutorials: ## run the tutorials notebooks
117121
.PHONY: test
118122
test: test-unit test-numerical test-end-to-end test-tutorials test-readme ## run all the tests
119123

120-
.PHONY: test-all
121-
test-all: ## test everything using tox
122-
tox -r
123-
124124
.PHONY: coverage
125125
coverage: ## check code coverage quickly with the default Python
126126
coverage run --source copulas -m pytest
@@ -188,7 +188,7 @@ git-push-tags-stable: ## Push tags and stable to github
188188

189189
.PHONY: bumpversion-release
190190
bumpversion-release: ## Bump the version to the next release
191-
bump-my-version bump release
191+
bump-my-version bump release --no-tag
192192

193193
.PHONY: bumpversion-patch
194194
bumpversion-patch: ## Bump the version to the next patch

RELEASE.md

Lines changed: 55 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ The process of releasing a new version involves several steps:
1414

1515
6. [Milestone](#milestone)
1616

17-
7. [HISTORY.md](#history.md)
17+
7. [Update HISTORY](#update-history)
1818

19-
8. [Distribution](#distribution)
19+
8. [Check the release](#check-the-release)
2020

21-
9. [Making the release](#making-the-release)
21+
8. [Update stable branch and bump version](#update-stable-branch-and-bump-version)
2222

23-
9.1. [Tag and release to PyPi](#tag-and-release-to-pypi)
24-
25-
9.2. [Update the release on GitHub](#update-the-release-on-github)
23+
10. [Create the Release on GitHub](#create-the-release-on-github)
2624

25+
11. [Close milestone and create new milestone](#close-milestone-and-create-new-milestone)
2726

2827
## Install Copulas from source
2928

@@ -34,31 +33,12 @@ git clone https://github.com/sdv-dev/Copulas.git
3433
cd Copulas
3534
git checkout main
3635
make install-develop
36+
make install-readme
3737
```
3838

3939
## Linting and tests
4040

41-
Execute ALL the tests and linting, tests must end with no errors:
42-
43-
```bash
44-
make test-all
45-
```
46-
47-
This command will use tox to execute the unittests with different environments, see tox.ini configuration.
48-
49-
To be able to run this you will need the different python versions used in the tox.ini file.
50-
51-
At the end, you will see an output like this:
52-
53-
```
54-
_____________________________________________ summary ______________________________________________
55-
py35: commands succeeded
56-
py36: commands succeeded
57-
lint: commands succeeded
58-
docs: commands succeeded
59-
```
60-
61-
To run the tests over your python version:
41+
Execute the tests and linting. The tests must end with no errors:
6242

6343
```bash
6444
make test && make lint
@@ -67,13 +47,17 @@ make test && make lint
6747
And you will see something like this:
6848

6949
```
70-
============================ 169 passed, 1 skipped, 3 warnings in 7.10s ============================
71-
flake8 copulas tests examples
72-
isort -c copulas tests examples
50+
Coverage XML written to file ./integration_cov.xml
51+
====================== 81 passed, 7820 warnings in 23.54s ======================
52+
...
53+
invoke lint
54+
No broken requirements found.
55+
All checks passed!
56+
86 files already formatted
7357
```
7458

75-
The execution has finished with no errors, 1 test skipped and 3 warnings.
76-
59+
The execution has finished with no errors, 0 test skipped and 7820 warnings.
60+
7761
## Documentation
7862

7963
The documentation must be up to date and generated with:
@@ -94,8 +78,9 @@ make docs
9478

9579
1. On the Copulas GitHub page, navigate to the [Actions][actions] tab.
9680
2. Select the `Release` action.
97-
3. Run it on the main branch. Make sure `Release candidate` is checked and `Test PyPi` is not.
98-
4. Check on [PyPi][copulas-pypi] to assure the release candidate was successfully uploaded.
81+
3. Run it on the main branch. Make sure `Release candidate` is checked and `Test PyPI` is not.
82+
4. Check on [PyPI][copulas-pypi] to assure the release candidate was successfully uploaded.
83+
- You should see X.Y.ZdevN PRE-RELEASE
9984

10085
[actions]: https://github.com/sdv-dev/Copulas/actions
10186
[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
11297
git checkout -b test-copulas-X.Y.Z
11398
```
11499

115-
2. Update the pyproject.toml to set the minimum version of Copulas to be the same as the version of the release. For example,
100+
2. Update the pyproject.toml to set the minimum version of Copulas to be the same as the version of the release. For example,
116101

117102
```toml
118103
'copulas>=X.Y.Z.dev0'
@@ -130,7 +115,7 @@ git push --set-upstream origin test-copulas-X.Y.Z
130115

131116
## Milestone
132117

133-
It's important check that the git hub and milestone issues are up to date with the release.
118+
It's important check that the GitHub and milestone issues are up to date with the release.
134119

135120
You neet to check that:
136121

@@ -142,101 +127,69 @@ You neet to check that:
142127
- All the pull requests closed since the latest release are associated to an issue. If necessary, create issues
143128
and assign them to the milestone. Also assigne the person who opened the issue to them.
144129

145-
## HISTORY.md
130+
## Update HISTORY
131+
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
146132

147133
Make sure HISTORY.md is updated with the issues of the milestone:
148134

149135
```
150136
# History
151-
137+
152138
## X.Y.Z (YYYY-MM-DD)
153-
139+
154140
### New Features
155-
141+
156142
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver
157-
143+
158144
### General Improvements
159-
145+
160146
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver
161-
147+
162148
### Bug Fixed
163-
149+
164150
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/Copulas/issues/<issue>) by @resolver
165151
```
166152

167153
The issue list per milestone can be found [here][milestones].
168154

169155
[milestones]: https://github.com/sdv-dev/Copulas/milestones
170156

171-
## Distribution
157+
Put the pull request up for review and get 2 approvals to merge into `main`.
172158

173-
Generate the distribution executing:
159+
## Check the release
160+
Once HISTORY.md has been updated on `main`, check if the release can be made:
174161

175162
```bash
176-
make dist
177-
```
178-
179-
This will create a `dist` and `build` directories. The `dist` directory contains the library installer.
180-
181-
```
182-
dist/
183-
├── copulas-<version>-py2.py3-none-any.whl
184-
└── copulas-<version>.tar.gz
185-
```
186-
187-
Now, create a new virtualenv with the distributed file generated and run the README.md examples:
188-
189-
1. Create the copulas-test directory (out of the Copulas directory):
190-
191-
```bash
192-
mkdir copulas-test
193-
cd copulas-test
194-
```
195-
196-
2. Create a new virtuelenv and activate it:
197-
198-
```bash
199-
virtualenv -p $(which python3.6) .venv
200-
source .venv/bin/activate
201-
```
202-
203-
3. Install the wheel distribution:
204-
205-
```bash
206-
pip install /path/to/copulas/dist/<copulas-distribution-version-any>.whl
163+
make check-release
207164
```
208165

209-
4. Now you are ready to execute the README.md examples.
210-
211-
## Making the release
166+
## Update stable branch and bump version
167+
The `stable` branch needs to be updated with the changes from `main` and the version needs to be bumped.
168+
Depending on the type of release, run one of the following:
212169

213-
At the end, we need to make the release. First, check if the release can be made:
170+
* `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.
171+
* `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.
172+
* `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.
214173

215-
```bash
216-
make check-release
217-
```
174+
Running one of these will **push commits directly** to `main`.
175+
At the end, you should see the 2 commits on `main` on (from oldest to newest):
176+
- `make release-tag: Merge branch 'main' into stable`
177+
- `Bump version: X.Y.Z.devN → X.Y.Z`
218178

219-
### Tag and release to PyPi
179+
## Create the Release on GitHub
220180

221-
Once we are sure that the release can be made we can use different commands depending on
222-
the type of release that we want to make:
181+
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).
182+
- Create a new tag with the version number with a v prefix (e.g. v0.3.1)
183+
- The target should be the `main` branch
184+
- Release title is the same as the tag (e.g. v0.3.1)
185+
- This is not a pre-release (`Set as a pre-release` should be unchecked)
223186

224-
* `make release`: This will relase a patch, which is the most common type of release. Use this
225-
when the changes are bugfixes or enhancements that do not modify the existing user API. Changes
226-
that modify the user API to add new features but that do not modify the usage of the previous
227-
features can also be released as a patch.
228-
* `make release-minor`: This will release the next minor version. Use this if the changes modify
229-
the existing user API in any way, even if it is backwards compatible. Minor backwards incompatible
230-
changes can also be released as minor versions while the library is still in beta state.
231-
After the major version 1 has been released, minor version can only be used to add backwards
232-
compatible API changes.
233-
* `make release-major`: This will release the next major version. Use this to if the changes modify
234-
the user API in a backwards incompatible way after the major version 1 has been released.
187+
Click `Publish release`, which will kickoff the release workflow and automatically upload the package to public PyPI.
235188

189+
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:
190+
- `Bump version: X.Y.Z → X.Y.Z.dev0`
236191

237-
### Update the release on GitHub
192+
## Close milestone and create new milestone
238193

239-
Once the tag and the release to PyPi has been made, go to GitHub and edit the freshly created "tag" to
240-
add the title and release notes, which should be exactly the same that we added to the HISTORY.md file.
194+
Finaly, **close the milestone** and, if it does not exist, **create the next milestone**.
241195

242-
Finaly, close the milestone and, if it does not exit, create the next one.

copulas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = 'DataCebo, Inc.'
44
__email__ = '[email protected]'
5-
__version__ = '0.12.4.dev0'
5+
__version__ = '0.12.4.dev3'
66

77
import sys
88
import warnings

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ dev = [
9898

9999
# Advanced testing
100100
'coverage >= 7.7.1, <7.8',
101-
'tox >= 2.9.1,<4',
102101
'invoke',
103102

104103
# Large scale evaluation
@@ -152,7 +151,7 @@ namespaces = false
152151
]
153152

154153
[tool.bumpversion]
155-
current_version = "0.12.4.dev0"
154+
current_version = "0.12.4.dev3"
156155
commit = true
157156
tag = true
158157
parse = '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?'
@@ -181,7 +180,6 @@ src = ["copulas"]
181180
target-version = "py312"
182181
exclude = [
183182
"docs",
184-
".tox",
185183
".git",
186184
"__pycache__",
187185
".ipynb_checkpoints",

0 commit comments

Comments
 (0)