|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# bake_require github.com/kyleburton/bake-recipes/docker/docker.sh |
| 4 | + |
| 5 | +function build::curr-git-tag { |
| 6 | + local curr_tag="$(git tag -l | sort | head -n 1)" |
| 7 | + if [ -z "$curr_tag" ]; then |
| 8 | + echo "1.0.0" |
| 9 | + fi |
| 10 | + echo "$curr_tag" |
| 11 | +} |
| 12 | + |
| 13 | +function build::next-git-tag { |
| 14 | + local curr_tag="$(build::curr-git-tag)" |
| 15 | + |
| 16 | + # major.minor.patch <- lets increment the patch |
| 17 | + local vmajor="$(echo $curr_tag | cut -f1 -d.)" |
| 18 | + local vminor="$(echo $curr_tag | cut -f2 -d.)" |
| 19 | + local vpatch="$(echo $curr_tag | cut -f3 -d.)" |
| 20 | + |
| 21 | + echo "$vmajor.$vminor.$(($vpatch + 1))" |
| 22 | +} |
| 23 | + |
| 24 | +bake_task make-release "Cut a release" |
| 25 | +function make-release () { |
| 26 | + local no_op="${1:-}" |
| 27 | + local curr_tag="$(build::curr-git-tag)" |
| 28 | + local next_tag="$(build::next-git-tag)" |
| 29 | + |
| 30 | + local relname="bake-$next_tag" |
| 31 | + local bundle_name="$relname.tgz" |
| 32 | + |
| 33 | + bake_echo_green "curr_tag=$curr_tag" |
| 34 | + bake_echo_green "next_tag=$next_tag" |
| 35 | + |
| 36 | + if [ -n "$no_op" ]; then |
| 37 | + exit 0 |
| 38 | + fi |
| 39 | + |
| 40 | + ( |
| 41 | + cd .. |
| 42 | + git tag "$next_tag" |
| 43 | + test -d ./release || mkdir ./release |
| 44 | + test -d "./release/$relname/bin" || mkdir -p "./release/$relname/bin" |
| 45 | + |
| 46 | + cp README.md Changes "./release/$relname/" |
| 47 | + cp bake bake-completion.sh "./release/$relname/bin" |
| 48 | + |
| 49 | + tar -C ./release -czvf $bundle_name $relname |
| 50 | + bake_echo_yellow "TODO: update Changes using the current date + git log using curr ($curr_tag) vs next ($next_tag) tags" |
| 51 | + bake_echo_yellow "TODO: automate the process of creating the release in GH: https://help.github.com/articles/creating-releases/" |
| 52 | + ) |
| 53 | +} |
| 54 | + |
| 55 | +bake_task clean "Clean up release archives and working directory" |
| 56 | +function clean () { |
| 57 | + ( |
| 58 | + cd .. |
| 59 | + rm -rf ./release |
| 60 | + rm -f bake-*.*.*.tgz |
| 61 | + ) |
| 62 | +} |
0 commit comments