<commit_before>name: ⏫ Version No.

on:
  push:
    branches:
      - release

jobs:
  build:
    name: Bump version
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        persist-credentials: false  # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
        fetch-depth: 0              # otherwise, you will failed to push refs to dest repo

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.7

    - name: Set env variables
      run: |
        git fetch --all --tags
        echo ::set-env name=TAG::$(git tag | sort -V | tail -1)
        echo ::set-env name=VER::$(python -c "import sys; sys.path.append('./openpnm'); from __version__ import __version__; print(__version__)")
        # echo ::set-env name=TAG::$(git describe --tags `git rev-list --tags --max-count=1`)   # alternative way of finding the most recent tag

    - name: Install dependencies
      run: |
        pip install bump2version
        echo $TAG $VER

    - name: Bump version (patch)
      if: contains(github.event.head_commit.message, '#patch')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER patch openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Bump version (minor)
      if: contains(github.event.head_commit.message, '#minor')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER minor openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Bump version (major)
      if: contains(github.event.head_commit.message, '#major')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER major openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Commit files
      if:
        contains(github.event.head_commit.message, '#patch') ||
        contains(github.event.head_commit.message, '#minor') ||
        contains(github.event.head_commit.message, '#major')
      run: |
        git config --local user.email "<EMAIL>"
        git config --local user.name "GitHub Action"
        git commit -m "Bump version number [ci skip]" -a
        REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
        remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"
        git push "${remote_repo}" release   # commit version bump to release
        git checkout dev
        git cherry-pick release             # this cherry-picks the most recent commit (version bump) on release
        # the next couple of lines are necessary in case of merge conflicts
        git checkout --theirs setup.cfg openpnm/__version__.py
        git add setup.cfg openpnm/__version__.py
        git commit -m "Bump version number [ci skip]"
        # git merge release                 # this breaks if dev contains code that release doesn't (e.g. hotfix directly pushed to release)
        git push "${remote_repo}" dev       # commit version bump to dev
        git checkout release                # checkout the Action branch (release)

    - name: Create new tag
      run: |
        REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
        remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"
        if [ -z "$TAG_NEW" ]
        then
            echo "New tag not created."
        else
            git tag $TAG_NEW
            git push "${remote_repo}" $TAG_NEW
            echo "Pushed a new tag: $TAG_NEW"
        fi

    # - name: Push changes
    #   uses: ad-m/github-push-action@master
    #   with:
    #     github_token: ${{ secrets.GITHUB_TOKEN }}
    #     branch: 'release'

    # - name: Push new tag
    #   uses: anothrNick/github-tag-action@1.22.0
    #   env:
    #     # If secrets.GITHUB_TOKEN is used, "Publish to PyPI" action will not be triggered
    #     WITH_V: true
    #     RELEASE_BRANCHES: release
    #     GITHUB_TOKEN: ${{ secrets.PUSH_ACTION_TOKEN }}
    #     DEFAULT_BUMP: none
<commit_msg>Crucial release for docrep incompatibility #patch<commit_after>name: ⏫ Version No.

on:
  push:
    branches:
      - release

jobs:
  build:
    name: Bump version
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        persist-credentials: false  # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
        fetch-depth: 0              # otherwise, you will failed to push refs to dest repo

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.7

    - name: Set env variables
      run: |
        git fetch --all --tags
        echo ::set-env name=TAG::$(git tag | sort -V | tail -1)
        echo ::set-env name=VER::$(python -c "import sys; sys.path.append('./openpnm'); from __version__ import __version__; print(__version__)")

    - name: Install dependencies
      run: |
        pip install bump2version
        echo $TAG $VER

    - name: Bump version (patch)
      if: contains(github.event.head_commit.message, '#patch')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER patch openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Bump version (minor)
      if: contains(github.event.head_commit.message, '#minor')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER minor openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Bump version (major)
      if: contains(github.event.head_commit.message, '#major')
      run: |
        echo ::set-env name=TAG_NEW::v$(bump2version --current-version $VER major openpnm/__version__.py --verbose | grep new_version | cut -d= -f2)

    - name: Commit files
      if:
        contains(github.event.head_commit.message, '#patch') ||
        contains(github.event.head_commit.message, '#minor') ||
        contains(github.event.head_commit.message, '#major')
      run: |
        REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
        remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"

        git config --local user.email "<EMAIL>"
        git config --local user.name "<NAME>"

        # commit version bump to release
        git commit -m "Bump version number [ci skip]" -a
        git push "${remote_repo}" release

        # commit the version bump back to the dev branch as well
        git checkout dev
        # cherry-pick the most recent commit (version bump) on release
        git cherry-pick release
        # the next couple of lines are necessary in case of merge conflicts
        git checkout --theirs setup.cfg openpnm/__version__.py
        git add setup.cfg openpnm/__version__.py
        # the first statement in the next line is to catch commit nothing error
        git diff-index --quiet HEAD || git commit -m "Bump version number [ci skip]"
        git push "${remote_repo}" dev

        # checkout the Action branch (release)
        git checkout release

    - name: Create new tag
      run: |
        REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
        remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"
        if [ -z "$TAG_NEW" ]
        then
            echo "New tag not created."
        else
            git tag $TAG_NEW
            git push "${remote_repo}" $TAG_NEW
            echo "Pushed a new tag: $TAG_NEW"
        fi
{'fraction_non_alphanumeric': 0.11311497148919242, 'fraction_numerical': 0.004110860628563851, 'mean_word_length': 2.380546839982071, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1537149', 'n_tokens_mistral': 2335, 'n_tokens_neox': 2274, 'n_words': 688}