Skip to content

Commit

Permalink
add release.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeardsley committed Mar 22, 2019
1 parent a158223 commit b573461
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
*.out

timeconverter
dist/timeconverter.rb
dist/timeconverter*.zip
Empty file added dist/.gitkeep
Empty file.
63 changes: 63 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

set -e

version="0.1.0"
package="timeconverter"
bin="timeconverter"
repo="https://github.com/bbeardsley/timeconverter"

platforms=(
"windows/amd64"
"windows/386"
"darwin/amd64"
"darwin/386"
"linux/amd64"
"linux/386"
"linux/arm"
)

rm -f dist/*

for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}

BIN="${bin}"
if [ $GOOS = "windows" ]; then
BIN="${bin}.exe"
fi
ZIP=$package'_v'$version'_'$GOOS'_'$GOARCH'.zip'

echo "Building for GOOS=$GOOS GOARCH=$GOARCH"

env GOOS=$GOOS GOARCH=$GOARCH go build -o dist/${BIN} &&
zip -q dist/${ZIP} -j dist/${BIN} &&
rm dist/${BIN}
done

DARWIN_AMD64=${package}_v${version}_darwin_amd64.zip
DARWIN_386=${package}_v${version}_darwin_386.zip

cat << EOF > dist/${package}.rb
# This file was generated by release.sh
require 'formula'
class TimeConverter < Formula
homepage '${repo}'
version '${version}'
if Hardware::CPU.is_64_bit?
url '${repo}/releases/download/v${version}/${DARWIN_AMD64}'
sha '$( sha256sum dist/${DARWIN_AMD64} | awk '{ print $1 }' | xargs printf )'
else
url '${repo}/releases/download/v${version}/${DARWIN_386}'
sha '$( sha256sum dist/${DARWIN_386} | awk '{ print $1 }' | xargs printf )'
end
def install
bin.install '${BIN}'
end
end
EOF

0 comments on commit b573461

Please sign in to comment.