Skip to content

Commit

Permalink
Adds contrib, licence, release script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Dec 30, 2017
1 parent 15f768c commit a7831bf
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ suffixes
domains
out
*.swp

*.tgz
*.zip
*.exe
23 changes: 23 additions & 0 deletions CONTRIBUTING.mkd
Original file line number Diff line number Diff line change
@@ -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
```

22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.

74 changes: 74 additions & 0 deletions script/release
Original file line number Diff line number Diff line change
@@ -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} <version>"
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

0 comments on commit a7831bf

Please sign in to comment.