| #!/bin/bash -e |
| |
| # settings.servers.github.privateKey |
| if [ "$GITHUB_TOKEN" == "" ]; then exit 1; fi |
| |
| # project.version |
| if [ "$VERSION" == "" ]; then exit 1; fi |
| |
| if [ ! -f ktlint/target/ktlint ]; then echo "ktlint/target/ktlint wasn't found"; exit 1; fi |
| |
| HASH=$(shasum -a 256 ktlint/target/ktlint | cut -d\ -f1) |
| |
| CHECKOUT_DIR=$(mktemp -d /tmp/homebrew-ktlint.XXXXXX) |
| git clone https://${GITHUB_TOKEN}@github.com/shyiko/homebrew-ktlint.git $CHECKOUT_DIR |
| |
| { |
| echo "class Ktlint < Formula" |
| echo " desc \"Kotlin linter\"" |
| echo " homepage \"https://github.com/shyiko/ktlint\"" |
| echo " url \"https://github.com/shyiko/ktlint/releases/download/$VERSION/ktlint\", :using => :nounzip" |
| echo " sha256 \"$HASH\"" |
| echo " def install" |
| echo " bin.install \"ktlint\"" |
| echo " end" |
| echo " test do" |
| echo " system bin/\"ktlint\", \"--version\"" |
| echo " end" |
| echo "end" |
| } > $CHECKOUT_DIR/ktlint.rb |
| |
| (cd $CHECKOUT_DIR && git commit -m $VERSION ktlint.rb && git tag $VERSION && git push origin master --tags) |