Skip to content

Maintaining a version string in a project and using it for creating releases #26905

Discussion options

You must be logged in to vote

@sayakmukhopadhyay ,

You can try like as this:
In the workflow, use the ‘sed’ command to replace the variable name with the actual version number in the ‘package.json’.

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
  - name: Set Version ENV
    run: echo "::set-env name=VERSION::'$(cat VERSION)"

  - name: Update version in 'package.json' and push changes
    run: |
      old_str="\"version\": \"1.2.3\""
      new_str="\"version\": \"1.3.0\""
      sed -i 's/$old_str/$new_str/g' package.json

      git config --global user.name "you username"
      git config --global user.email "you email"
      git add package.json
      git commit -m "Update version"
      gi…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants