Skip to content

Instantly share code, notes, and snippets.

@biroplane
Created April 19, 2023 15:01
Show Gist options
  • Save biroplane/93051b62babc3135ce849201a113cd3b to your computer and use it in GitHub Desktop.
Save biroplane/93051b62babc3135ce849201a113cd3b to your computer and use it in GitHub Desktop.
Update your package.json file version attribute from latest git tag
#!/bin/bash
# Get the latest git tag
latest_git_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
# Update the package.json version
jq ".version = \"$latest_git_tag\"" package.json > package.json.tmp && mv package.json.tmp package.json
# Display the updated version
echo "Updated package.json version to $latest_git_tag"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment