Explorar o código

Added github actions

Steve Kemp %!s(int64=5) %!d(string=hai) anos
pai
achega
1bcde1caf5
Modificáronse 3 ficheiros con 91 adicións e 0 borrados
  1. 46 0
      .github/build
  2. 38 0
      .github/main.workflow
  3. 7 0
      .github/run-tests.sh

+ 46 - 0
.github/build

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# The basename of our binary
+BASE="rss2hook"
+
+# Get the dependencies
+go mod init
+
+#
+# We build on only a single platform/arch.
+#
+BUILD_PLATFORMS="linux"
+BUILD_ARCHS="amd64"
+
+# 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 - 0
.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 = "rss2hook-*"
+  secrets = ["GITHUB_TOKEN"]
+}

+ 7 - 0
.github/run-tests.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# init modules
+go mod init
+
+# Run golang tests
+go test ./...