Skip to content

Instantly share code, notes, and snippets.

@mirismaili
Created March 12, 2023 20:36
Show Gist options
  • Save mirismaili/d87be835d380572aa35e6b20d033cb65 to your computer and use it in GitHub Desktop.
Save mirismaili/d87be835d380572aa35e6b20d033cb65 to your computer and use it in GitHub Desktop.
Auto tag current version (from package.json) after commit
#!/bin/bash
# Auto-tag version (if already not existed):
version=$(grep -oP '\"version\"\s*:\s*\"\K\d+\.\d+\.\d+' package.json) # extract `version` from "package.json". ex: 2.0.4
git tag v$version 2>/dev/null # ex: `git tag v2.0.4` (and ignore possible error)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment