File: release

package info (click to toggle)
gron 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,740 kB
  • sloc: sh: 74; makefile: 17
file content (63 lines) | stat: -rwxr-xr-x 1,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
PROJDIR=$(cd `dirname $0`/.. && pwd)

VERSION="${1}"
TAG="v${VERSION}"
USER="tomnomnom"
REPO="gron"
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

FILELIST=""

for ARCH in "amd64" "386"; do
    for OS in "darwin" "linux" "windows" "freebsd"; do

        if [[ "${OS}" == "darwin" && "${ARCH}" == "386" ]]; then
            continue
        fi

        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}
            rm ${BINFILE}
        else
            ARCHIVE="${BINARY}-${OS}-${ARCH}-${VERSION}.tgz"
            tar --create --gzip --file=${ARCHIVE} ${BINFILE}
        fi

        FILELIST="${FILELIST} ${PROJDIR}/${ARCHIVE}"
    done
done

gh release create ${TAG} ${FILELIST}
rm ${FILELIST}