Skip to content

Instantly share code, notes, and snippets.

@scarolan
Created January 14, 2014 20:24
Show Gist options
  • Save scarolan/8425022 to your computer and use it in GitHub Desktop.
Save scarolan/8425022 to your computer and use it in GitHub Desktop.
Uses the 'knife spork' plugin and git to accomplish the following: * Bump the cookbook version using "knife spork bump" * Commit changes to git, push to remote repo * Tag the commit with the cookbook version * Upload the cookbook to your chef server
#!/bin/bash
usage="This script should be run from the main directory of your cookbook.\n Usage: $0 cookbookname"
# Did the user supply a cookbook name? Are we in a cookbook directory?
if [ $# -ne 1 ] || [ ! -f metadata.rb ]; then
echo -e $usage; exit 1
fi
cookbook=$1
knife spork bump $cookbook
git add .
git commit -m "New cookbook version $version"
git push
version=$(awk '/version/ {print $2}' metadata.rb | tr -d "'")
git tag -a "v$version" -m "$cookbook Cookbook Version $version"
git push --tags
knife spork upload $cookbook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment