version update on develop #6
Workflow file for this run
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
name: Update Package.json Version | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
branches: [develop, main, stage] | |
permissions: write-all | |
jobs: | |
update_version_and_tag: | |
# if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Get and update git release tag | |
id: git-tag | |
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | |
# run: echo ::set-output name=tag::$(git describe --tags --abbrev=0 || 'latest') | |
- name: Print the tag | |
run: echo ${{ steps.git-tag.outputs.tag }} | |
- name: Update package.json version | |
id: update_pkg_version | |
run: | | |
npm version "${{ steps.git-tag.outputs.tag }}" --no-git-tag-version | |
echo "::set-output name=new_version::$(node -p -e "require('./package.json').version")" | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -am "Update package.json version to ${{ steps.update_pkg_version.outputs.new_version }}" | |
git push |