-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create CF CLI plugin repository YAML in build_all.sh
- Loading branch information
Showing
2 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
|
@@ -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) | ||
|
@@ -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 | ||
|