Skip to content

Commit

Permalink
Added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Feb 24, 2019
1 parent bcd479e commit 9e21825
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/build
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions .github/main.workflow
Original file line number Diff line number Diff line change
@@ -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"]
}
8 changes: 8 additions & 0 deletions .github/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# init modules
go mod init

# Run golang tests
go test ./...

0 comments on commit 9e21825

Please sign in to comment.