Skip to content

Commit 08fde50

Browse files
committed
add release workflow
1 parent 9292b9c commit 08fde50

File tree

5 files changed

+288
-46
lines changed

5 files changed

+288
-46
lines changed

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [published]
5+
branches:
6+
- main
7+
- stable
8+
9+
workflow_dispatch:
10+
inputs:
11+
candidate:
12+
description: 'Release candidate.'
13+
required: true
14+
type: boolean
15+
default: true
16+
test_pypi:
17+
description: 'Test PyPI.'
18+
type: boolean
19+
default: false
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
id-token: write
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.candidate && 'main' || 'stable' }}
29+
30+
- name: Set up latest Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version-file: 'pyproject.toml'
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install .[dev]
39+
40+
- name: Create wheel
41+
run: |
42+
make dist
43+
44+
- name: Publish a Python distribution to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
48+
49+
- name: Bump version to next candidate
50+
if: ${{ inputs.candidate && !inputs.test_pypi }}
51+
run: |
52+
git config user.name "github-actions[bot]"
53+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
54+
bump-my-version bump candidate --no-tag --no-commit
55+
56+
- name: Create pull request
57+
if: ${{ inputs.candidate && !inputs.test_pypi }}
58+
id: cpr
59+
uses: peter-evans/create-pull-request@v4
60+
with:
61+
token: ${{ secrets.GH_ACCESS_TOKEN }}
62+
commit-message: bumpversion-candidate
63+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
64+
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
65+
signoff: false
66+
delete-branch: true
67+
title: Automated Bump Version Candidate
68+
body: "This is an auto-generated PR that bumps the version to the next candidate."
69+
branch: bumpversion-candidate-update
70+
branch-suffix: short-commit-hash
71+
add-paths: |
72+
deepecho/__init__.py
73+
pyproject.toml
74+
draft: false
75+
base: main
76+
77+
- name: Enable Pull Request Automerge
78+
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
79+
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --auto
80+
env:
81+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

Makefile

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ clean-coverage: ## remove coverage artifacts
5555

5656
.PHONY: clean-test
5757
clean-test: ## remove test artifacts
58-
rm -fr .tox/
5958
rm -fr .pytest_cache
6059

6160
.PHONY: clean
@@ -76,6 +75,9 @@ install-test: clean-build clean-pyc ## install the package and test dependencies
7675
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
7776
pip install -e .[dev]
7877

78+
.PHONY: install-readme
79+
install-readme: clean-build clean-pyc ## install the package in editable mode and readme dependencies for developement
80+
pip install -e .[readme]
7981

8082
# LINT TARGETS
8183

@@ -116,10 +118,6 @@ test: test-unit test-integration test-readme test-tutorials ## test everything t
116118
.PHONY: test-devel
117119
test-devel: lint ## test everything that needs development dependencies
118120

119-
.PHONY: test-all
120-
test-all: ## run tests on every Python version with tox
121-
tox -r
122-
123121
.PHONY: coverage
124122
coverage: ## check code coverage quickly with the default Python
125123
coverage run --source deepecho -m pytest
@@ -154,41 +152,47 @@ publish-test: dist publish-confirm ## package and upload a release on TestPyPI
154152
publish: dist publish-confirm ## package and upload a release
155153
twine upload dist/*
156154

157-
.PHONY: bumpversion-release
158-
bumpversion-release: ## Merge main to stable and bumpversion release
155+
.PHONY: git-merge-main-stable
156+
git-merge-main-stable: ## Merge main into stable
159157
git checkout stable || git checkout -b stable
160158
git merge --no-ff main -m"make release-tag: Merge branch 'main' into stable"
161-
bump-my-version bump release
159+
160+
.PHONY: git-merge-stable-main
161+
git-merge-stable-main: ## Merge stable into main
162+
git checkout main
163+
git merge stable
164+
165+
.PHONY: git-push
166+
git-push: ## Simply push the repository to github
167+
git push
168+
169+
.PHONY: git-push-tags-stable
170+
git-push-tags-stable: ## Push tags and stable to github
162171
git push --tags origin stable
163172

164-
.PHONY: bumpversion-release-test
165-
bumpversion-release-test: ## Merge main to stable and bumpversion release
166-
git checkout stable || git checkout -b stable
167-
git merge --no-ff main -m"make release-tag: Merge branch 'main' into stable"
173+
.PHONY: bumpversion-release
174+
bumpversion-release: ## Bump the version to the next release
168175
bump-my-version bump release --no-tag
169-
@echo git push --tags origin stable
170176

171177
.PHONY: bumpversion-patch
172-
bumpversion-patch: ## Merge stable to main and bumpversion patch
173-
git checkout main
174-
git merge stable
175-
bump-my-version bump patch --no-tag
176-
git push
178+
bumpversion-patch: ## Bump the version to the next patch
179+
bump-my-version bump --no-tag patch
177180

178181
.PHONY: bumpversion-candidate
179182
bumpversion-candidate: ## Bump the version to the next candidate
180183
bump-my-version bump candidate --no-tag
181184

182185
.PHONY: bumpversion-minor
183186
bumpversion-minor: ## Bump the version the next minor skipping the release
184-
bump-my-version bump minor --no-tag
187+
bump-my-version bump --no-tag minor
185188

186189
.PHONY: bumpversion-major
187190
bumpversion-major: ## Bump the version the next major skipping the release
188-
bump-my-version bump major --no-tag
191+
bump-my-version bump --no-tag major
189192

190193
.PHONY: bumpversion-revert
191194
bumpversion-revert: ## Undo a previous bumpversion-release
195+
git tag --delete $(shell git tag --points-at HEAD)
192196
git checkout main
193197
git branch -D stable
194198

@@ -231,13 +235,20 @@ check-release: check-clean check-candidate check-main check-history ## Check if
231235
@echo "A new release can be made"
232236

233237
.PHONY: release
234-
release: check-release bumpversion-release publish bumpversion-patch
238+
release: check-release git-merge-main-stable bumpversion-release git-push-tags-stable \
239+
git-merge-stable-main bumpversion-patch git-push
235240

236241
.PHONY: release-test
237-
release-test: check-release bumpversion-release-test publish-test bumpversion-revert
242+
release-test: check-release git-merge-main-stable bumpversion-release bumpversion-revert
238243

239244
.PHONY: release-candidate
240245
release-candidate: check-main publish bumpversion-candidate git-push
241246

242247
.PHONY: release-candidate-test
243248
release-candidate-test: check-clean check-main publish-test
249+
250+
.PHONY: release-minor
251+
release-minor: check-release bumpversion-minor release
252+
253+
.PHONY: release-major
254+
release-major: check-release bumpversion-major release

RELEASE.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Release workflow
2+
3+
The process of releasing a new version involves several steps:
4+
5+
1. [Install DeepEcho from source](#install-deepecho-from-source)
6+
7+
2. [Linting and tests](#linting-and-tests)
8+
9+
3. [Make a release candidate](#make-a-release-candidate)
10+
11+
4. [Integration with SDV](#integration-with-sdv)
12+
13+
5. [Milestone](#milestone)
14+
15+
6. [Update HISTORY](#update-history)
16+
17+
7. [Check the release](#check-the-release)
18+
19+
8. [Update stable branch and bump version](#update-stable-branch-and-bump-version)
20+
21+
9. [Create the Release on GitHub](#create-the-release-on-github)
22+
23+
10. [Close milestone and create new milestone](#close-milestone-and-create-new-milestone)
24+
25+
## Install DeepEcho from source
26+
27+
Clone the project and install the development requirements before start the release process. Alternatively, with your virtualenv activated.
28+
29+
```bash
30+
git clone https://github.com/sdv-dev/DeepEcho.git
31+
cd DeepEcho
32+
git checkout main
33+
make install-develop
34+
```
35+
36+
## Linting and tests
37+
38+
Execute the tests and linting. The tests must end with no errors:
39+
40+
```bash
41+
make test && make lint
42+
```
43+
44+
And you will see something like this:
45+
46+
```
47+
Coverage XML written to file ./integration_cov.xml
48+
============ 242 passed, 166 warnings, 134 subtests passed in 9.88s ============
49+
....
50+
invoke lint
51+
No broken requirements found.
52+
All checks passed!
53+
80 files already formatted
54+
```
55+
56+
The execution has finished with no errors, 0 test skipped and 166 warnings.
57+
58+
## Make a release candidate
59+
60+
1. On the DeepEcho GitHub page, navigate to the [Actions][actions] tab.
61+
2. Select the `Release` action.
62+
3. Run it on the main branch. Make sure `Release candidate` is checked and `Test PyPI` is not.
63+
4. Check on [PyPI][deepecho-pypi] to assure the release candidate was successfully uploaded.
64+
- You should see X.Y.ZdevN PRE-RELEASE
65+
66+
[actions]: https://github.com/sdv-dev/DeepEcho/actions
67+
[deepecho-pypi]: https://pypi.org/project/DeepEcho/#history
68+
69+
## Integration with SDV
70+
71+
### Create a branch on SDV to test the candidate
72+
73+
Before doing the actual release, we need to test that the candidate works with SDV. To do this, we can create a branch on SDV that points to the release candidate we just created using the following steps:
74+
75+
1. Create a new branch on the SDV repository.
76+
77+
```bash
78+
git checkout -b test-deepecho-X.Y.Z
79+
```
80+
81+
2. Update the pyproject.toml to set the minimum version of DeepEcho to be the same as the version of the release. For example,
82+
83+
```toml
84+
'deepecho>=X.Y.Z.dev0'
85+
```
86+
87+
3. Push this branch. This should trigger all the tests to run.
88+
89+
```bash
90+
git push --set-upstream origin test-deepecho-X.Y.Z
91+
```
92+
93+
4. Check the [Actions][sdv-actions] tab on SDV to make sure all the tests pass.
94+
95+
[sdv-actions]: https://github.com/sdv-dev/SDV/actions
96+
97+
## Milestone
98+
99+
It's important to check that the GitHub and milestone issues are up to date with the release.
100+
101+
You neet to check that:
102+
103+
- The milestone for the current release exists.
104+
- All the issues closed since the latest release are associated to the milestone. If they are not, associate them
105+
- All the issues associated to the milestone are closed. If there are open issues but the milestone needs to
106+
be released anyway, move them to the next milestone.
107+
- All the issues in the milestone are assigned to at least one person.
108+
- All the pull requests closed since the latest release are associated to an issue. If necessary, create issues
109+
and assign them to the milestone. Also assign the person who opened the issue to them.
110+
111+
## Update HISTORY
112+
Run the [Release Prep](https://github.com/sdv-dev/DeepEcho/actions/workflows/prepare_release.yml) workflow. This workflow will create a pull request with updates to HISTORY.md
113+
114+
Make sure HISTORY.md is updated with the issues of the milestone:
115+
116+
```
117+
# History
118+
119+
## X.Y.Z (YYYY-MM-DD)
120+
121+
### New Features
122+
123+
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/DeepEcho/issues/<issue>) by @resolver
124+
125+
### General Improvements
126+
127+
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/DeepEcho/issues/<issue>) by @resolver
128+
129+
### Bug Fixed
130+
131+
* <ISSUE TITLE> - [Issue #<issue>](https://github.com/sdv-dev/DeepEcho/issues/<issue>) by @resolver
132+
```
133+
134+
The issue list per milestone can be found [here][milestones].
135+
136+
[milestones]: https://github.com/sdv-dev/DeepEcho/milestones
137+
138+
Put the pull request up for review and get 2 approvals to merge into `main`.
139+
140+
## Check the release
141+
Once HISTORY.md has been updated on `main`, check if the release can be made:
142+
143+
144+
```bash
145+
make check-release
146+
```
147+
148+
## Update stable branch and bump version
149+
The `stable` branch needs to be updated with the changes from `main` and the version needs to be bumped.
150+
Depending on the type of release, run one of the following:
151+
152+
* `make release`: This will release the version that has already been bumped (patch, minor, or major). By default, this is typically a patch 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.
153+
* `make release-minor`: This will bump and 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 v1.0.0 has been released, minor version can only be used to add backwards compatible API changes.
154+
* `make release-major`: This will bump and release the next major version. Use this if the changes modify the user API in a backwards incompatible way after the major version v1.0.0 has been released.
155+
156+
Running one of these will **push commits directly** to `main`.
157+
At the end, you should see the 3 commits on `main` (from oldest to newest):
158+
- `make release-tag: Merge branch 'main' into stable`
159+
- `Bump version: X.Y.Z.devN → X.Y.Z`
160+
- `Bump version: X.Y.Z -> X.Y.A.dev0`
161+
162+
## Create the Release on GitHub
163+
164+
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/DeepEcho/releases/new).
165+
- Create a new tag with the version number with a v prefix (e.g. v0.3.1)
166+
- The target should be the `stable` branch
167+
- Release title is the same as the tag (e.g. v0.3.1)
168+
- This is not a pre-release (`Set as a pre-release` should be unchecked)
169+
170+
Click `Publish release`, which will kickoff the release workflow and automatically upload the package to [public PyPI](https://pypi.org/project/deepecho/).
171+
172+
## Close milestone and create new milestone
173+
174+
Finaly, **close the milestone** and, if it does not exist, **create the next milestone**.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ dev = [
7272

7373
# Advanced testing
7474
'coverage>=4.5.1,<6',
75-
'tox>=2.9.1,<4',
7675

7776
# Invoking test commands
7877
'invoke'

0 commit comments

Comments
 (0)