#!/bin/bash

set -e

BP_NAME="jvm-common"

if [ ! -z "$1" ]; then
  pushd . > /dev/null 2>&1
  cd /tmp
  rm -rf heroku-buildpack-$BP_NAME
  git clone git@github.com:heroku/heroku-buildpack-$BP_NAME.git
  cd heroku-buildpack-$BP_NAME
  git checkout master
  headHash=$(git rev-parse HEAD)

  find . ! -name '.' ! -name '..' ! -name 'bin' ! -name 'opt' -maxdepth 1 -print0 | xargs -0 rm -rf --
  heroku buildpacks:publish $1/$BP_NAME

  if [ "$1" = "heroku" ]; then
    newTag=$(heroku buildpacks:revisions heroku/$BP_NAME | sed -n 2p | grep -o -e "v\d*")
  fi

  popd > /dev/null 2>&1
  echo "Cleaning up..."
  rm -rf /tmp/heroku-buildpack-$BP_NAME

  if [ "$1" = "heroku" ]; then
    if [ "$headHash" = "$(git rev-parse HEAD)" ]; then
      echo "Tagging commit $headHash with $newTag... "
      git tag $newTag
      git push --tags
    fi
  fi

  echo "Done."
else
  echo "You must provide a buildkit organization as an argument!"
  exit 1
fi

#!/bin/bash

set -e

BP_NAME="jvm-common"

if [ ! -z "$1" ]; then
  pushd . > /dev/null 2>&1
  cd /tmp
  rm -rf heroku-buildpack-$BP_NAME
  git clone git@github.com:heroku/heroku-buildpack-$BP_NAME.git
  cd heroku-buildpack-$BP_NAME
  git checkout master
  headHash=$(git rev-parse HEAD)

  find . ! -name '.' ! -name '..' ! -name 'bin' ! -name 'opt' -maxdepth 1 -print0 | xargs -0 rm -rf --
  heroku buildkits:publish $1/$BP_NAME

  if [ "$1" = "heroku" ]; then
    newTag=$(heroku buildpacks:revisions heroku/$BP_NAME | sed -n 2p | grep -o -e "v\d*")
  fi

  popd > /dev/null 2>&1
  echo "Cleaning up..."
  rm -rf /tmp/heroku-buildpack-$BP_NAME

  if [ "$1" = "heroku" ]; then
    if [ "$headHash" = "$(git rev-parse HEAD)" ]; then
      echo "Tagging commit $headHash with $newTag... "
      git tag $newTag
      git push --tags
    fi
  fi

  echo "Done."
else
  echo "You must provide a buildkit organization as an argument!"
  exit 1
fi

Change buildpacks command to buildkits
Change buildpacks command to buildkits [skip ci]
