Update version #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update version | |
on: | |
workflow_dispatch: | |
inputs: | |
append_to_tag: | |
description: 'Leave blank for an actual release or "rc1", "rc2", ..., for release candidates."' | |
default: "" | |
schedule: | |
# Run at 10 am UTC on day-of-month 1 in January, May, and September. | |
- cron: "0 10 1 1,5,9 *" | |
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 | |
steps: | |
- name: Get current date for the first release candidate | |
if: github.event_name == 'schedule' | |
run: | | |
echo "VERSION=$(date +'v%y.%-m')rc0" >> $GITHUB_ENV | |
echo "NON_RC_VERSION=$(date +'v%y.%-m')" >> $GITHUB_ENV | |
- name: Get current date for a manual release | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
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: | |
ref: '${{ env.NON_RC_VERSION }}' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
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 }}' | |
# checkout to develop for updating versions in the same | |
- uses: actions/checkout@v4 | |
with: | |
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@v6 | |
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) | |
# 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 | |
if: github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.append_to_tag, 'rc') | |
uses: repo-sync/pull-request@v2 | |
with: | |
source_branch: '${{ env.NON_RC_VERSION }}' | |
destination_branch: "main" | |
pr_title: "Make release ${{ env.NON_RC_VERSION }}" | |
pr_body: "**Check the [release workflow](https://github.com/pybamm-team/PyBaMM/blob/develop/.github/release_workflow.md)**" | |
github_token: ${{ secrets.GITHUB_TOKEN }} |