Created
August 5, 2019 13:18
-
-
Save Informatic/82c153d62b2c326fa984b9d101ca7c07 to your computer and use it in GitHub Desktop.
Quickly add git version tags for specified chef cookbook (could easily be adapted to any other piece of infrastructure, eg. npm package.json file, as long as one is able to extract unique version identifier on specified git ref)
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
#!/usr/bin/env bash | |
# Creates local version tags based on cookbook metadata.rb change history | |
# Usage: bash tagify-cookbook [cookbook_name] | |
cookbook=${1:-some_cookbook} | |
git log --pretty=format:"%h" cookbooks/$cookbook/metadata.rb | while read ref; do | |
tag="$cookbook-$(git show $ref:cookbooks/$cookbook/metadata.rb | grep "^version '" | sed -E "s/.* '(.*)'/\1/g" )" | |
echo "ref: $ref -> $tag"; | |
git tag $tag $ref | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment