Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #97 from getantibody/releaser
Browse files Browse the repository at this point in the history
rewrote the entire release script
  • Loading branch information
caarlos0 committed Mar 28, 2016
2 parents c9d5d39 + b56cab3 commit 7b010ea
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ coverage.out
*.pdf
*.pprof
vendor
dist
99 changes: 69 additions & 30 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,77 @@
#!/bin/bash
#!/bin/sh
set -e

# enables go 1.5 vendor expirement
export GO15VENDOREXPERIMENT=1

CURRENT="$(git describe --tags --abbrev=0)"
PREVIOUS=$(git describe --tags --abbrev=0 ${CURRENT}^)
cleanup() {
rm -rf dist
}

# normalize Golang's OS and Arch to uname compatibles
normalize() {
echo "$1" | sed \
-e 's/darwin/Darwin/' \
-e 's/linux/Linux/' \
-e 's/freebsd/FreeBSD/' \
-e 's/openbsd/OpenBSD/' \
-e 's/netbsd/NetBSD/' \
-e 's/386/i386/' \
-e 's/amd64/x86_64/'
}

echo "Installing needed tools..."
go get github.com/mitchellh/gox
go get github.com/aktau/github-release
# builds the binaries with gox
build() {
echo "Building $CURRENT..."
go get github.com/mitchellh/gox
gox -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}/antibody" \
-os="linux darwin freebsd openbsd netbsd" \
-ldflags="-X main.version $CURRENT" \
./cmd/antibody/
}

echo "Creating release $CURRENT..."
gox \
-output="./bin/{{.Dir}}_{{.OS}}_{{.Arch}}" \
-os="linux darwin freebsd openbsd netbsd" \
-ldflags="-X main.version $CURRENT" \
./cmd/antibody/
LOG="$(git log --pretty=oneline --abbrev-commit "$PREVIOUS".."$CURRENT")"
DESCRIPTION="$LOG\n\nCompiled with: $(go version)"
github-release release \
--user getantibody \
--repo antibody \
--tag "$CURRENT" \
--description "$DESCRIPTION" \
--pre-release
# package the binaries in .tar.gz files
package() {
echo "Packaging $CURRENT..."
for folder in ./dist/*; do
local filename="$(normalize "$folder").tar.gz"
tar -cvzf "$filename" "${folder}/antibody" antibody.zsh README.md LICENSE
done
}

for file in ./bin/*; do
filename="$(grep "$file" ./scripts/version_map | cut -f2 -d'=').tar.gz"
tar \
--transform="s/${file}/antibody/" \
-cvzf "$filename" \
"bin/${file}" antibody.zsh README.md LICENSE
github-release upload \
# release it to github
release() {
echo "Releasing $CURRENT..."
local -r log="$(git log --pretty=oneline --abbrev-commit "$PREVIOUS".."$CURRENT")"
local -r description="${log}\n\nBuilt with: $(go version)"
go get github.com/aktau/github-release
echo "Creating release $CURRENT..."
github-release release \
--user getantibody \
--repo antibody \
--tag "$CURRENT" \
--name "$filename" \
--file "$filename"
done
--description "$description" \
--pre-release ||
github-release edit \
--user getantibody \
--repo antibody \
--tag "$CURRENT" \
--description "$description" \
--pre-release
for file in ./dist/*.tar.gz; do
echo "--> Uploading $file..."
github-release upload \
--user getantibody \
--repo antibody \
--tag "$CURRENT" \
--name "$(echo $file | sed 's/\.\/dist\///')" \
--file "$file"
done
}

cleanup
CURRENT="$(git describe --tags --abbrev=0)"
PREVIOUS=$(git describe --tags --abbrev=0 ${CURRENT}^)
build
package
release
15 changes: 0 additions & 15 deletions scripts/version_map

This file was deleted.

0 comments on commit 7b010ea

Please sign in to comment.