Skip to content

Node.js Update package.json version #5

Node.js Update package.json version

Node.js Update package.json version #5

name: Node.js Update package.json version
on:
release:
types: [created]
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Extract tag version from release event payload
- name: Extract tag version
id: extract-tag
run: echo "tag_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# Update package.json version
- name: Update package version
run: |
TAG_VERSION=${{ env.tag_version }}
jq ".version = \"$TAG_VERSION\"" package.json > temp.json
mv temp.json package.json
# Commit and push changes
- name: Commit and push version bump
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git commit -am "Bump version to $TAG_VERSION [skip ci]"
git push origin HEAD:${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}