Skip to content

Commit a4be1a3

Browse files
committed
Improve the release workflow (#3737)
* Try fixing the release workflow * Turn off safety * Fix CHANGELOG * Add OS * Use regex for better matches * Update instructions, add safety checks * checkout to the version branch for the final release
1 parent adda336 commit a4be1a3

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

.github/release_workflow.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ This file contains the workflow required to make a `PyBaMM` release on GitHub, P
2121

2222
## rcX releases (manual)
2323

24-
If a new release candidate is required after the release of `rc0` -
24+
If a new release candidate is required after the release of `rc{X-1}` -
2525

26-
1. Fix a bug in `vYY.MM` (no new features should be added to `vYY.MM` once `rc0` is released) and `develop` individually.
26+
1. Cherry-pick the bug fix (no new features should be added to `vYY.MM` once `rc{X-1}` is released) commit to `vYY.MM` branch once the fix is merged into `develop`. The CHANGELOG entry for such fixes should go under the `rc{X-1}` heading in `CHANGELOG.md`
2727

2828
2. Run `update_version.yml` manually while using `append_to_tag` to specify the release candidate version number (`rc1`, `rc2`, ...).
2929

@@ -36,7 +36,7 @@ If a new release candidate is required after the release of `rc0` -
3636
- `vcpkg.json`
3737
- `CHANGELOG.md`
3838

39-
These changes will be automatically pushed to the existing `vYY.MM` branch and a PR from `vvYY.MM` to `develop` will be created (to sync the branches).
39+
These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`.
4040

4141
4. Create a new GitHub _pre-release_ with the same tag (`vYY.MMrcX`) from the `vYY.MM` branch and a description copied from `CHANGELOG.md`.
4242

@@ -57,7 +57,7 @@ Once satisfied with the release candidates -
5757
- `vcpkg.json`
5858
- `CHANGELOG.md`
5959

60-
These changes will be automatically pushed to the existing `vYY.MM` branch and a PR from `vvYY.MM` to `develop` will be created (to sync the branches).
60+
These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`.
6161

6262
3. Next, a PR from `vYY.MM` to `main` will be generated that should be merged once all the tests pass.
6363

.github/workflows/publish_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
open_failure_issue:
214214
needs: [build_windows_wheels, build_macos_and_linux_wheels, build_sdist]
215215
name: Open an issue if build fails
216-
if: ${{ always() && contains(needs.*.result, 'failure') }}
216+
if: ${{ always() && contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}}
217217
runs-on: ubuntu-latest
218218
steps:
219219
- uses: actions/checkout@v4

.github/workflows/update_version.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
echo "VERSION=$(date +'v%y.%-m')${{ github.event.inputs.append_to_tag }}" >> $GITHUB_ENV
3030
echo "NON_RC_VERSION=$(date +'v%y.%-m')" >> $GITHUB_ENV
3131
32+
# the schedule workflow is for rc0 release
3233
- uses: actions/checkout@v4
3334
if: github.event_name == 'schedule'
3435
with:
3536
ref: 'develop'
3637

38+
# the dispatch workflow is for rcX and final releases
3739
- uses: actions/checkout@v4
3840
if: github.event_name == 'workflow_dispatch'
3941
with:
@@ -49,29 +51,55 @@ jobs:
4951
pip install wheel
5052
pip install --editable ".[all]"
5153
54+
# update all the version strings and add CHANGELOG headings
5255
- name: Update version
5356
run: python scripts/update_version.py
5457

58+
# create a new version branch for rc0 release and commit
5559
- uses: EndBug/add-and-commit@v9
5660
if: github.event_name == 'schedule'
5761
with:
5862
message: 'Bump to ${{ env.VERSION }}'
5963
new_branch: '${{ env.NON_RC_VERSION }}'
6064

65+
# use the already created release branch for rcX + final releases
66+
# and commit
6167
- uses: EndBug/add-and-commit@v9
6268
if: github.event_name == 'workflow_dispatch'
6369
with:
6470
message: 'Bump to ${{ env.VERSION }}'
6571

66-
- name: Make a PR from ${{ env.NON_RC_VERSION }} to develop
67-
uses: repo-sync/pull-request@v2
72+
# checkout to develop for updating versions in the same
73+
- uses: actions/checkout@v4
6874
with:
69-
source_branch: '${{ env.NON_RC_VERSION }}'
70-
destination_branch: "develop"
71-
pr_title: "Sync ${{ env.NON_RC_VERSION }} and develop"
72-
pr_body: "**Merge as soon as possible to avoid potential conflicts.**"
73-
github_token: ${{ secrets.GITHUB_TOKEN }}
75+
ref: 'develop'
76+
77+
# update all the version strings
78+
- name: Update version
79+
if: github.event_name == 'workflow_dispatch'
80+
run: python scripts/update_version.py
81+
82+
# create a pull request updating versions in develop
83+
- name: Create Pull Request
84+
id: version_pr
85+
uses: peter-evans/create-pull-request@v3
86+
with:
87+
delete-branch: true
88+
branch-suffix: short-commit-hash
89+
base: develop
90+
commit-message: Update version to ${{ env.VERSION }}
91+
title: Bump to ${{ env.VERSION }}
92+
body: |
93+
- [x] Update to ${{ env.VERSION }}
94+
- [ ] Check the [release workflow](https://github.com/pybamm-team/PyBaMM/blob/develop/.github/release_workflow.md)
95+
96+
# checkout to the version branch for the final release
97+
- uses: actions/checkout@v4
98+
if: github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.append_to_tag, 'rc')
99+
with:
100+
ref: '${{ env.NON_RC_VERSION }}'
74101

102+
# for final releases, create a PR from version branch to main
75103
- name: Make a PR from ${{ env.NON_RC_VERSION }} to main
76104
id: release_pr
77105
if: github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.append_to_tag, 'rc')

CHANGELOG.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)
22

3-
## Bug fixes
4-
5-
- Fixed a bug where if the first step(s) in a cycle are skipped then the cycle solution started from the model's initial conditions instead of from the last state of the previous cycle ([#3708](https://github.com/pybamm-team/PyBaMM/pull/3708))
6-
- Fixed a bug where the lumped thermal model conflates cell volume with electrode volume ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))
7-
8-
## Breaking changes
9-
- The parameters `GeometricParameters.A_cooling` and `GeometricParameters.V_cell` are now automatically computed from the electrode heights, widths and thicknesses if the "cell geometry" option is "pouch" and from the parameters "Cell cooling surface area [m2]" and "Cell volume [m3]", respectively, otherwise. When using the lumped thermal model we recommend using the "arbitrary" cell geometry and specifying the parameters "Cell cooling surface area [m2]", "Cell volume [m3]" and "Total heat transfer coefficient [W.m-2.K-1]" directly. ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))
10-
113
# [v24.1rc0](https://github.com/pybamm-team/PyBaMM/tree/v24.1rc0) - 2024-01-31
124

135
## Features
@@ -26,6 +18,8 @@
2618

2719
## Bug fixes
2820

21+
- Fixed a bug where if the first step(s) in a cycle are skipped then the cycle solution started from the model's initial conditions instead of from the last state of the previous cycle ([#3708](https://github.com/pybamm-team/PyBaMM/pull/3708))
22+
- Fixed a bug where the lumped thermal model conflates cell volume with electrode volume ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))
2923
- Reverted a change to the coupled degradation example notebook that caused it to be unstable for large numbers of cycles ([#3691](https://github.com/pybamm-team/PyBaMM/pull/3691))
3024
- Fixed a bug where simulations using the CasADi-based solvers would fail randomly with the half-cell model ([#3494](https://github.com/pybamm-team/PyBaMM/pull/3494))
3125
- Fixed bug that made identical Experiment steps with different end times crash ([#3516](https://github.com/pybamm-team/PyBaMM/pull/3516))
@@ -38,6 +32,7 @@
3832

3933
## Breaking changes
4034

35+
- The parameters `GeometricParameters.A_cooling` and `GeometricParameters.V_cell` are now automatically computed from the electrode heights, widths and thicknesses if the "cell geometry" option is "pouch" and from the parameters "Cell cooling surface area [m2]" and "Cell volume [m3]", respectively, otherwise. When using the lumped thermal model we recommend using the "arbitrary" cell geometry and specifying the parameters "Cell cooling surface area [m2]", "Cell volume [m3]" and "Total heat transfer coefficient [W.m-2.K-1]" directly. ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))
4136
- Dropped support for the `[jax]` extra, i.e., the Jax solver when running on Python 3.8. The Jax solver is now available on Python 3.9 and above ([#3550](https://github.com/pybamm-team/PyBaMM/pull/3550))
4237

4338
# [v23.9](https://github.com/pybamm-team/PyBaMM/tree/v23.9) - 2023-10-31

scripts/update_version.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def update_version():
1717
Opens file and updates the version number
1818
"""
1919
release_version = os.getenv("VERSION")[1:]
20-
last_day_of_month = date.today() + relativedelta(day=31)
20+
release_date = (
21+
date.today()
22+
if "rc" in release_version
23+
else date.today() + relativedelta(day=31)
24+
)
2125

2226
# pybamm/version.py
2327
with open(os.path.join(pybamm.root_dir(), "pybamm", "version.py"), "r+") as file:
@@ -72,16 +76,21 @@ def update_version():
7276
file.write(replace_commit_id)
7377

7478
changelog_line1 = "# [Unreleased](https://github.com/pybamm-team/PyBaMM/)\n"
75-
changelog_line2 = f"# [v{release_version}](https://github.com/pybamm-team/PyBaMM/tree/v{release_version}) - {last_day_of_month}\n\n"
79+
changelog_line2 = f"# [v{release_version}](https://github.com/pybamm-team/PyBaMM/tree/v{release_version}) - {release_date}\n\n"
7680

7781
# CHANGELOG.md
7882
with open(os.path.join(pybamm.root_dir(), "CHANGELOG.md"), "r+") as file:
7983
output_list = file.readlines()
8084
output_list[0] = changelog_line1
85+
# add a new heading for rc0 releases
8186
if "rc0" in release_version:
8287
output_list.insert(2, changelog_line2)
8388
else:
84-
output_list[2] = changelog_line2
89+
# for rcX and final releases, update the already existing rc
90+
# release heading
91+
for i in range(0, len(output_list)):
92+
if re.search("[v]\d\d\.\drc\d", output_list[i]):
93+
output_list[i] = changelog_line2[:-1]
8594
file.truncate(0)
8695
file.seek(0)
8796
file.writelines(output_list)

0 commit comments

Comments
 (0)