This repository has been archived by the owner on May 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from getantibody/releaser
rewrote the entire release script
- Loading branch information
Showing
3 changed files
with
70 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ coverage.out | |
*.pprof | ||
vendor | ||
dist |
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,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 |
This file was deleted.
Oops, something went wrong.