From 58e303a85e0b221a92926d5de1c6db759967daa2 Mon Sep 17 00:00:00 2001 From: Sam Vente Date: Tue, 25 Jul 2023 16:49:09 +0200 Subject: [PATCH 1/3] add GHA for version updating --- .github/workflows/docs.yml | 2 +- .github/workflows/update_dev_version.yml | 28 ++++++++++++++++++++++++ docs/changelog.rst | 2 +- docs/dev/contributing.rst | 6 +++-- hydromt/__init__.py | 1 - 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/update_dev_version.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c1416e23f..2d6b179bc 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ on: jobs: # Build docs on Linux - Docs: + docs: timeout-minutes: 10 name: linux docs runs-on: ubuntu-latest diff --git a/.github/workflows/update_dev_version.yml b/.github/workflows/update_dev_version.yml new file mode 100644 index 000000000..6d87e97d0 --- /dev/null +++ b/.github/workflows/update_dev_version.yml @@ -0,0 +1,28 @@ + +on: + pull_request_review: + types: + - submitted + workflow_dispatch: + + +jobs: + update_version: + if: github.event.review.state == 'approved' + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: configure git + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + - name: update version + run: | + last_release=$(git tag --list | tail -n 1) + num_commits_since_release=$(($(git rev-list $last_release..main | wc -l) + 1 )) + sed -i "s/__version__\s*=\s*\"(\d+\.\d+\.\d+).dev(\d+)\"/__version__ = \"$1.dev$num_commits_since_release\"/" hydromt/__init__.py + git add hydromt/__init__.py + git commit -m "update version" + git push origin ${{ github.ref_name}} -f + gh pr comment ${{ github.ref_name }} -b "I've updated the version for you. Feel free to merge now!" diff --git a/docs/changelog.rst b/docs/changelog.rst index d8a07cbfb..16f10325a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,7 +11,7 @@ Unreleased Added ----- -- +- Versions of HydroMT between releases are now updated automatically when the PR is approved. (#455) Changed ------- diff --git a/docs/dev/contributing.rst b/docs/dev/contributing.rst index b192f0ba9..ae43e6081 100644 --- a/docs/dev/contributing.rst +++ b/docs/dev/contributing.rst @@ -37,7 +37,9 @@ If you found a bug or an issue you would like to tackle or contribute to a new d 4. Update docs/changelog.rst file with a summary of your changes and a link to your pull request. See for example the `hydromt changelog `_. 5. Push your commits to the github repository and open a draft pull request. The body of the pull request will be pre-filled with a template. Please fill out this template with the relevant information, and complete the checklist included. 6. Once you're satisfied with the changes mark the pull request as "as ready for review" and ask another contributor to review the code. The review should cover the implementation as well as steps 2-4. -7. Merge the pull request once the review has been approved. +7. Once your request has been approved, a bot will add a commit to your branch to automatically update the version number. Please wait for this to complete before you merge. Once it is done, a comment saying "You're free to merge now" will be added to your PR. +8. Note that if you want to make changes after this commit has been added, you should pull the branch first to avoid merge conflicts. +9. You are now free to merge your pull request. Do merge with a `squash` commit!! This is important to make sure the version counting stays accurate. .. _git-conventions: @@ -181,7 +183,7 @@ It's telling us we first need to tell it what we want to do with the current con Success! This is a simple introduction into a potentially very complicated subject. You can read more about the different possibilities here: -* `Merge Conflicts `_ +* `Merge Conflicts `_ * `Merge Strategies `_ diff --git a/hydromt/__init__.py b/hydromt/__init__.py index 6be7ef6b9..5dfad6eeb 100644 --- a/hydromt/__init__.py +++ b/hydromt/__init__.py @@ -1,6 +1,5 @@ """HydroMT: Automated and reproducible model building and analysis.""" -# version number without 'v' at start __version__ = "0.8.1.dev0" # Set environment variables (this will be temporary) From 2373345c2fd86529c6be8acee08991e378e95ede Mon Sep 17 00:00:00 2001 From: Sam Vente Date: Tue, 25 Jul 2023 16:50:35 +0200 Subject: [PATCH 2/3] auto approve GHA --- .github/workflows/auto_approve.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/auto_approve.yml diff --git a/.github/workflows/auto_approve.yml b/.github/workflows/auto_approve.yml new file mode 100644 index 000000000..1cfcb9d6b --- /dev/null +++ b/.github/workflows/auto_approve.yml @@ -0,0 +1,20 @@ +--- +name: Auto approve PR +on: + pull_request: + types: [opened, reopened] +jobs: + move-assigned-card: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: setup git + run: | + git config --global user.name "GH Actions bot" + git config --global user.email "<>" + - name: Auto approve PR + run: | + gh pr review --approve -b "You seem like a trust worthy individual. I'll just approve this for you, I'm sure it's fine. Right?" $PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR: ${{ github.event.pull_request.number }} From 606987d7116aac0e2d95ec4abd9f7adb7a1fd399 Mon Sep 17 00:00:00 2001 From: Sam Vente Date: Tue, 25 Jul 2023 16:51:05 +0200 Subject: [PATCH 3/3] add dummy file --- dirty.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 dirty.txt diff --git a/dirty.txt b/dirty.txt new file mode 100644 index 000000000..e69de29bb