-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update workflow based on off-screen testing
- Loading branch information
Showing
1 changed file
with
27 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
|
||
name: Update Version | ||
on: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
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!" | ||
if: github.event_name == 'workflow_dispatch' || github.event.review.state == 'approved' | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
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: Fetch last release | ||
run: echo "LAST_RELEASE=$(git tag --list | tail -n 1)" >> $GITHUB_ENV | ||
- name: calculate number of commist since last release | ||
run: echo "NUM_COMMITS=$(($(git rev-list ${{ env.LAST_RELEASE }}..main | wc -l) + 1 ))" >> $GITHUB_ENV | ||
- name: update version | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
sed -i "s/__version__\s*=\s*\"\([0-9]\+\.[0-9]\+\.[0-9]\+\).dev[0-9]\+\"/__version__ = \"\1.dev1\"/" hydromt/__init__.py | ||
git add hydromt/__init__.py | ||
git commit -m "update version" | ||
git push origin ${{ github.ref_name}} | ||
gh pr comment ${{ github.ref_name }} -b "I've updated the version for you. Feel free to merge now!" |