Skip to content

Instantly share code, notes, and snippets.

@Informatic
Created August 5, 2019 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Informatic/82c153d62b2c326fa984b9d101ca7c07 to your computer and use it in GitHub Desktop.
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)
#!/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