From f44bce5c7afb972c51346ea4c2735091b1937d37 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:18:43 +0100 Subject: [PATCH 1/7] Try fixing the release workflow --- .github/release_workflow.md | 6 ++--- .github/workflows/update_version.yml | 36 ++++++++++++++++++++++------ scripts/update_version.py | 15 +++++++++--- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/.github/release_workflow.md b/.github/release_workflow.md index 690f7fa407..3a52d55bcd 100644 --- a/.github/release_workflow.md +++ b/.github/release_workflow.md @@ -21,9 +21,9 @@ This file contains the workflow required to make a `PyBaMM` release on GitHub, P ## rcX releases (manual) -If a new release candidate is required after the release of `rc0` - +If a new release candidate is required after the release of `rc{X-1}` - -1. Fix a bug in `vYY.MM` (no new features should be added to `vYY.MM` once `rc0` is released) and `develop` individually. +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` 2. Run `update_version.yml` manually while using `append_to_tag` to specify the release candidate version number (`rc1`, `rc2`, ...). @@ -36,7 +36,7 @@ If a new release candidate is required after the release of `rc0` - - `vcpkg.json` - `CHANGELOG.md` - 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). + These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`. Updation in CHANGELOG will not be included in this PR (to avoid conflicts); hence, it must be updated manually in this PR. 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`. diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index a6c35c0333..ba67922a66 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -29,11 +29,13 @@ jobs: echo "VERSION=$(date +'v%y.%-m')${{ github.event.inputs.append_to_tag }}" >> $GITHUB_ENV echo "NON_RC_VERSION=$(date +'v%y.%-m')" >> $GITHUB_ENV + # the schedule workflow is for rc0 release - uses: actions/checkout@v4 if: github.event_name == 'schedule' with: ref: 'develop' + # the dispatch workflow is for rcX and final releases - uses: actions/checkout@v4 if: github.event_name == 'workflow_dispatch' with: @@ -49,29 +51,49 @@ jobs: pip install wheel pip install --editable ".[all]" + # update all the version strings and add CHANGELOG headings - name: Update version run: python scripts/update_version.py + # create a new version branch for rc0 release and commit - uses: EndBug/add-and-commit@v9 if: github.event_name == 'schedule' with: message: 'Bump to ${{ env.VERSION }}' new_branch: '${{ env.NON_RC_VERSION }}' + # use the already created release branch for rcX + final releases + # and commit - uses: EndBug/add-and-commit@v9 if: github.event_name == 'workflow_dispatch' with: message: 'Bump to ${{ env.VERSION }}' - - name: Make a PR from ${{ env.NON_RC_VERSION }} to develop - uses: repo-sync/pull-request@v2 + # checkout to develop for updating versions in the same + - uses: actions/checkout@v4 with: - source_branch: '${{ env.NON_RC_VERSION }}' - destination_branch: "develop" - pr_title: "Sync ${{ env.NON_RC_VERSION }} and develop" - pr_body: "**Merge as soon as possible to avoid potential conflicts.**" - github_token: ${{ secrets.GITHUB_TOKEN }} + ref: 'develop' + + # update all the version strings + - name: Update version + if: github.event_name == 'workflow_dispatch' + run: python scripts/update_version.py + + # create a pull request updating versions in develop + - name: Create Pull Request + id: version_pr + uses: peter-evans/create-pull-request@v3 + with: + delete-branch: true + branch-suffix: short-commit-hash + base: develop + commit-message: Update version to ${{ env.VERSION }} + title: Bump to ${{ env.VERSION }} + body: | + - [x] Update to ${{ env.VERSION }} + - [ ] Check the [release workflow](https://github.com/pybamm-team/PyBaMM/blob/develop/.github/release_workflow.md) + # for final releases, create a PR from version branch to main - name: Make a PR from ${{ env.NON_RC_VERSION }} to main id: release_pr if: github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.append_to_tag, 'rc') diff --git a/scripts/update_version.py b/scripts/update_version.py index 30d2240e9c..16e3977f6f 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -17,7 +17,11 @@ def update_version(): Opens file and updates the version number """ release_version = os.getenv("VERSION")[1:] - last_day_of_month = date.today() + relativedelta(day=31) + release_date = ( + date.today() + if "rc" in release_version + else date.today() + relativedelta(day=31) + ) # pybamm/version.py with open(os.path.join(pybamm.root_dir(), "pybamm", "version.py"), "r+") as file: @@ -70,16 +74,21 @@ def update_version(): file.write(replace_commit_id) changelog_line1 = "# [Unreleased](https://github.com/pybamm-team/PyBaMM/)\n" - changelog_line2 = f"# [v{release_version}](https://github.com/pybamm-team/PyBaMM/tree/v{release_version}) - {last_day_of_month}\n\n" + changelog_line2 = f"# [v{release_version}](https://github.com/pybamm-team/PyBaMM/tree/v{release_version}) - {release_date}\n\n" # CHANGELOG.md with open(os.path.join(pybamm.root_dir(), "CHANGELOG.md"), "r+") as file: output_list = file.readlines() output_list[0] = changelog_line1 + # add a new heading for rc0 releases if "rc0" in release_version: output_list.insert(2, changelog_line2) else: - output_list[2] = changelog_line2 + # for rcX and final releases, update the already existing rc + # release heading + for i in range(0, len(output_list)): + if "rc" in output_list[i]: + output_list[i] = changelog_line2[:-1] file.truncate(0) file.seek(0) file.writelines(output_list) From 8023fdf174933d72ec25487d55cee0bdc2f3e7f8 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:20:21 +0100 Subject: [PATCH 2/7] Turn off safety --- .github/workflows/update_version.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index ba67922a66..07b91c45c7 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -13,8 +13,8 @@ on: jobs: update-version: # This workflow is only of value to PyBaMM and would always be skipped in forks - if: github.repository_owner == 'pybamm-team' - runs-on: ubuntu-latest + # if: github.repository_owner == 'pybamm-team' + # runs-on: ubuntu-latest steps: - name: Get current date for the first release candidate From 520ddababea3df66a72a6ae249372cefaf270280 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:22:22 +0100 Subject: [PATCH 3/7] Fix CHANGELOG --- CHANGELOG.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0692d152ca..20559a11d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,5 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) -## Bug fixes - -- 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)) -- Fixed a bug where the lumped thermal model conflates cell volume with electrode volume ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707)) - -## Breaking changes -- 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)) - # [v24.1rc0](https://github.com/pybamm-team/PyBaMM/tree/v24.1rc0) - 2024-01-31 ## Features @@ -26,6 +18,8 @@ ## Bug fixes +- 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)) +- Fixed a bug where the lumped thermal model conflates cell volume with electrode volume ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707)) - 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)) - 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)) - 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 @@ ## Breaking changes +- 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)) - 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)) # [v23.9](https://github.com/pybamm-team/PyBaMM/tree/v23.9) - 2023-10-31 From 4e0c8c00f83d4548240b45a016f8364eec92770b Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:24:03 +0100 Subject: [PATCH 4/7] Add OS --- .github/workflows/update_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 07b91c45c7..337129b855 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -14,7 +14,7 @@ jobs: update-version: # This workflow is only of value to PyBaMM and would always be skipped in forks # if: github.repository_owner == 'pybamm-team' - # runs-on: ubuntu-latest + runs-on: ubuntu-latest steps: - name: Get current date for the first release candidate From 2198ad77d60acc957b03993e22275c3aab53b6ed Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:40:09 +0100 Subject: [PATCH 5/7] Use regex for better matches --- scripts/update_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_version.py b/scripts/update_version.py index b95ddf1343..dfc6b7f32e 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -89,7 +89,7 @@ def update_version(): # for rcX and final releases, update the already existing rc # release heading for i in range(0, len(output_list)): - if "rc" in output_list[i]: + if re.search("[v]\d\d\.\drc\d", output_list[i]): output_list[i] = changelog_line2[:-1] file.truncate(0) file.seek(0) From b60690ab91bb595450ad57600bf1d6d01854bd56 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:45:38 +0100 Subject: [PATCH 6/7] Update instructions, add safety checks --- .github/release_workflow.md | 4 ++-- .github/workflows/publish_pypi.yml | 2 +- .github/workflows/update_version.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/release_workflow.md b/.github/release_workflow.md index 3a52d55bcd..89a22e7d38 100644 --- a/.github/release_workflow.md +++ b/.github/release_workflow.md @@ -36,7 +36,7 @@ If a new release candidate is required after the release of `rc{X-1}` - - `vcpkg.json` - `CHANGELOG.md` - These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`. Updation in CHANGELOG will not be included in this PR (to avoid conflicts); hence, it must be updated manually in this PR. + These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`. 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`. @@ -57,7 +57,7 @@ Once satisfied with the release candidates - - `vcpkg.json` - `CHANGELOG.md` - 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). + These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`. 3. Next, a PR from `vYY.MM` to `main` will be generated that should be merged once all the tests pass. diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 8a8126b0e4..ce930733db 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -213,7 +213,7 @@ jobs: open_failure_issue: needs: [build_windows_wheels, build_macos_and_linux_wheels, build_sdist] name: Open an issue if build fails - if: ${{ always() && contains(needs.*.result, 'failure') }} + if: ${{ always() && contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 337129b855..ba67922a66 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -13,7 +13,7 @@ on: jobs: update-version: # This workflow is only of value to PyBaMM and would always be skipped in forks - # if: github.repository_owner == 'pybamm-team' + if: github.repository_owner == 'pybamm-team' runs-on: ubuntu-latest steps: From 851d378bddcdfd2de90847493f151b8273f4d732 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 16 Jan 2024 20:51:44 +0100 Subject: [PATCH 7/7] checkout to the version branch for the final release --- .github/workflows/update_version.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index ba67922a66..f04b033272 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -93,6 +93,12 @@ jobs: - [x] Update to ${{ env.VERSION }} - [ ] Check the [release workflow](https://github.com/pybamm-team/PyBaMM/blob/develop/.github/release_workflow.md) + # checkout to the version branch for the final release + - uses: actions/checkout@v4 + if: github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.append_to_tag, 'rc') + with: + ref: '${{ env.NON_RC_VERSION }}' + # for final releases, create a PR from version branch to main - name: Make a PR from ${{ env.NON_RC_VERSION }} to main id: release_pr