diff --git a/.github/build b/.github/build new file mode 100755 index 0000000..6778fbc --- /dev/null +++ b/.github/build @@ -0,0 +1,46 @@ +#!/bin/bash + +# The basename of our binary +BASE="go.vm" + +# Get the dependencies +go mod init + +# +# We build on multiple platforms/archs +# +BUILD_PLATFORMS="linux windows darwin freebsd" +BUILD_ARCHS="amd64 386" + +# For each platform +for OS in ${BUILD_PLATFORMS[@]}; do + + # For each arch + for ARCH in ${BUILD_ARCHS[@]}; do + + # Setup a suffix for the binary + SUFFIX="${OS}" + + # i386 is better than 386 + if [ "$ARCH" = "386" ]; then + SUFFIX="${SUFFIX}-i386" + else + SUFFIX="${SUFFIX}-${ARCH}" + fi + + # Windows binaries should end in .EXE + if [ "$OS" = "windows" ]; then + SUFFIX="${SUFFIX}.exe" + fi + + echo "Building for ${OS} [${ARCH}] -> ${BASE}-${SUFFIX}" + + # Run the build + export GOARCH=${ARCH} + export GOOS=${OS} + export CGO_ENABLED=1 + + go build -ldflags "-X main.version=$(git describe --tags)" -o "${BASE}-${SUFFIX}" + + done +done diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..c05ca0e --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,38 @@ +# pushes trigger the testsuite +workflow "Push Event" { + on = "push" + resolves = ["Test"] +} + +# pull-requests trigger the testsuite +workflow "Pull Request" { + on = "pull_request" + resolves = ["Test"] +} + +# releases trigger new binary artifacts +workflow "Handle Release" { + on = "release" + resolves = ["Upload"] +} + +## +## The actions +## + + +## +## Run the test-cases, via .github/run-tests.sh +## +action "Test" { + uses = "skx/github-action-tester@master" +} + +## +## Build the binaries, via .github/build, then upload them. +## +action "Upload" { + uses = "skx/github-action-publish-binaries@master" + args = "go.vm-*" + secrets = ["GITHUB_TOKEN"] +} diff --git a/.github/run-tests.sh b/.github/run-tests.sh new file mode 100755 index 0000000..916d1b6 --- /dev/null +++ b/.github/run-tests.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# init modules +go mod init + +# Run golang tests +go test ./... +