diff --git a/.gitignore b/.gitignore index 65baf8f..10b16c9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ suffixes domains out *.swp - +*.tgz +*.zip +*.exe diff --git a/CONTRIBUTING.mkd b/CONTRIBUTING.mkd new file mode 100644 index 0000000..5d0b0ab --- /dev/null +++ b/CONTRIBUTING.mkd @@ -0,0 +1,23 @@ +# Contributing + +* Raise an issue if appropriate +* Fork the repo +* Make your changes +* Use [gofmt](https://golang.org/cmd/gofmt/) +* Issue a pull request + +## Commit Messages +I'd prefer it if commit messages describe what the *commit does*, not what *you did*. + +For example, I'd prefer: + +``` +Adds lint; removes fluff +``` + +Over: + +``` +Added lint; removed fluff +``` + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..60777df --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2018 Tom Hudson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/script/release b/script/release new file mode 100755 index 0000000..bcb0589 --- /dev/null +++ b/script/release @@ -0,0 +1,74 @@ +#!/bin/bash +PROJDIR=$(cd `dirname $0`/.. && pwd) + +VERSION="${1}" +TAG="v${VERSION}" +USER="tomnomnom" +REPO="meg" +BINARY="${REPO}" + +if [[ -z "${VERSION}" ]]; then + echo "Usage: ${0} " + exit 1 +fi + +if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "You forgot to set your GITHUB_TOKEN" + exit 2 +fi + +cd ${PROJDIR} + +# Run the tests +go test +if [ $? -ne 0 ]; then + echo "Tests failed. Aborting." + exit 3 +fi + +# Check if tag exists +git fetch --tags +git tag | grep "^${TAG}$" + +if [ $? -ne 0 ]; then + github-release release \ + --user ${USER} \ + --repo ${REPO} \ + --tag ${TAG} \ + --name "${REPO} ${TAG}" \ + --description "${TAG}" \ + --pre-release +fi + + +for ARCH in "amd64" "386"; do + for OS in "darwin" "linux" "windows" "freebsd"; do + + BINFILE="${BINARY}" + + if [[ "${OS}" == "windows" ]]; then + BINFILE="${BINFILE}.exe" + fi + + rm -f ${BINFILE} + + GOOS=${OS} GOARCH=${ARCH} go build github.com/${USER}/${REPO} + + if [[ "${OS}" == "windows" ]]; then + ARCHIVE="${BINARY}-${OS}-${ARCH}-${VERSION}.zip" + zip ${ARCHIVE} ${BINFILE} + else + ARCHIVE="${BINARY}-${OS}-${ARCH}-${VERSION}.tgz" + tar --create --gzip --file=${ARCHIVE} ${BINFILE} + fi + + echo "Uploading ${ARCHIVE}..." + github-release upload \ + --user ${USER} \ + --repo ${REPO} \ + --tag ${TAG} \ + --name "${ARCHIVE}" \ + --file ${PROJDIR}/${ARCHIVE} + done +done +