Skip to content

Commit

Permalink
Create CF CLI plugin repository YAML in build_all.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasf committed Feb 2, 2017
1 parent e604ea2 commit b600d10
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ deploy:
api_key:
secure: ONgfa6uGlzqX9HKizki9Hemw2b68/0d+vlFsq+k6R0KQKhzmD7TnuUNewpAC4ELQtPUQtttknplwLpdPPhY/JcUxJ7/GHxuToeFRzT4Zz8aU6zuCeegM9rRRjPsRtYeB5OHLtiresmPng1OfEhWBoaeOS0aBHb/aQKORQTYr86Q6v7L2u43ikfXMzqFZtjdJnvNbRZqBY/8HfUKhGDhFeW8WXvXvyvFIHmoLKWgcznbW2bBh8GKdv+O/1JPqfAnSZhHrTYV/k+kW6zx8Qyq2VfvN/r97zfjxoDxTHumnyWmZyozXIoHlPxF8aR6OtmSybEV2QvWNwUkhBpKQtvvFn3+egQlfJjdRBizJXYgSwry4307WpY+cBz6rEdN8JajOAXff03uC1mLxsK527afengjuEI/d6lLAKuyz0985yTH/pqetowOwE8U8+BSRwc7/ja8VBAmCv7HS2sI0qsyoaDpunFBeRS8s/QVTsgoKsFtLzHI69vywo/rqUqOJFi3KxPVghdN3vE6f5IauvQeNuDIpV9+7kB9tBoGQjvq52m4woyv/gXWgQl8mS/naY33w4QA3XAQnO0WIoKBq6Et0/wVmpOByJpQGGFS6gvs5QmK+NlV012CAPskwPixuot5np8uJqjXAw1ynGQ1OGh+DvURBD2o+++ij0NLKLWCFacg=
file:
- output/cf-mysql-plugin-linux-amd64.zip
- output/cf-mysql-plugin-linux-386.zip
- output/cf-mysql-plugin-darwin-amd64.zip
- output/cf-mysql-plugin-windows-amd64.zip
- output/cf-mysql-plugin-windows-386.zip
- output/cf-mysql-plugin-linux-amd64
- output/cf-mysql-plugin-linux-386
- output/cf-mysql-plugin-darwin-amd64
- output/cf-mysql-plugin-amd64.exe
- output/cf-mysql-plugin-386.exe
on:
tags: true

68 changes: 60 additions & 8 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -o pipefail

BINARY="cf-mysql-plugin"

Expand All @@ -13,23 +14,26 @@ main() {

build_for_platform_and_arch windows amd64
build_for_platform_and_arch windows 386

print_release_yaml
}

build_for_platform_and_arch() {
platform="$1"
arch="$2"
destination="output/$platform-$arch"
binary=`binary_for_platform "$platform"`
mkdir -p "$destination"

mkdir -p output
build_filename=`build_filename_for_platform "$platform"`
release_name="output/`release_name_for_platform $platform $arch`"
GOOS="$platform" GOARCH="$arch" go build
mv "$binary" "$destination"
mv "$build_filename" "$release_name"

pushd "$destination" > /dev/null
zip ../"$BINARY-$platform-$arch.zip" *
popd > /dev/null
hash_val=`shasum ${release_name} | cut -f 1 -d" "`
hash_var_name="hash_${platform}_${arch}"
eval "$hash_var_name=${hash_val}"
}

binary_for_platform() {
build_filename_for_platform() {
platform="$1"
case "$platform" in
windows)
Expand All @@ -41,5 +45,53 @@ binary_for_platform() {
esac
}

release_name_for_platform() {
platform="$1"
case "$platform" in
windows)
echo "$BINARY-$arch.exe"
;;
*)
echo "$BINARY-$platform-$arch"
;;
esac
}

print_release_yaml() {
prefixed_version=$(git describe --tags)
version=${prefixed_version:1}
updated=$(date "+%Y-%m-%dT%H:%M:%S%z")

cat <<EOF
- name: mysql-plugin
description: Runs mysql and mysqldump clients against your CF database services. Use it to inspect, dump and restore your DB.
version: ${version}
created: 2017-02-02T09:30:00Z
updated: ${updated}
company:
authors:
- name: Andreas Fleig
homepage: https://github.com/andreasf
contact: [email protected]
homepage: https://github.com/andreasf/cf-mysql-plugin
binaries:
- platform: osx
url: https://github.com/andreasf/cf-mysql-plugin/releases/download/v${version}/${BINARY}-darwin-amd64
checksum: ${hash_darwin_amd64}
- platform: win64
url: https://github.com/andreasf/cf-mysql-plugin/releases/download/v${version}/${BINARY}-amd64.exe
checksum: ${hash_windows_amd64}
- platform: win32
url: https://github.com/andreasf/cf-mysql-plugin/releases/download/v${version}/${BINARY}-386.exe
checksum: ${hash_windows_386}
- platform: linux32
url: https://github.com/andreasf/cf-mysql-plugin/releases/download/v${version}/${BINARY}-linux-386
checksum: ${hash_linux_386}
- platform: linux64
url: https://github.com/andreasf/cf-mysql-plugin/releases/download/v${version}/${BINARY}-linux-amd64
checksum: ${hash_linux_amd64}
EOF
}

main

0 comments on commit b600d10

Please sign in to comment.