Bump up version in Github workflow won't change the code

Viewed 25

I'm using python poetry as package management. For bump up the patch version, I simply run poetry version patch. I moved this function to workflow and it won't change the version string at all!

name: Bump version

on:   workflow_dispatch:
    inputs:
      version:     
        description: 'Semver type of new version (major / minor / patch)'
        required: true
        type: choice
        options: 
        - patch
        - minor
        - major

jobs:   bump-version:
    runs-on: ubuntu-latest
    steps:

    - name: checkout repo
      uses: actions/checkout@v2.4.0

    - name: setup python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
        architecture: 'x64'
        
    - name: setup poetry
      run: |
        python -m pip install -U pip
        pip install poetry 
  
    - name: Setup Git
      run: |
        git config user.name "${GITHUB_ACTOR}"
        git config user.email "${GITHUB_ACTOR}@teamname.com"

    - name: bump version
      run: poetry version ${{ github.event.inputs.version }} #the action is not update the code

I do have the bump up version step as showing above, however, the version string was kept still after pulled and checked, can someone help me?

Possible reason: Since the workflow needs to checkout (copy the repo) fist, all changes are enter to the copied repo. If so how can I copy back?

1 Answers

As I mentioned, the workflow simulate what you have locally, therefore it checkout first(copy) the solution is after the version bump up just commit and push it

- name: bump up version
  run: |
    poetry version ${{ github.event.inputs.version }}
    git add pyproject.toml
    git commit -m "bump up ${{ github.event.inputs.version }} version from workflow"
    git push
Related