]> code.octet-stream.net Git - broadcaster/commitdiff
Configure CI
authorThomas Karpiniec <tom.karpiniec@outlook.com>
Wed, 28 May 2025 12:12:03 +0000 (22:12 +1000)
committerThomas Karpiniec <tom.karpiniec@outlook.com>
Wed, 28 May 2025 12:12:03 +0000 (22:12 +1000)
buildscripts/build.sh [new file with mode: 0755]
buildscripts/dist-generic.sh [new file with mode: 0755]
buildscripts/dist.sh [new file with mode: 0755]
buildscripts/init.sh [new file with mode: 0755]
buildscripts/lint.sh [new file with mode: 0755]
buildscripts/test.sh [new file with mode: 0755]
radio/files_machine.go

diff --git a/buildscripts/build.sh b/buildscripts/build.sh
new file mode 100755 (executable)
index 0000000..28c4afd
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+case $PLATFORM in
+linux-x86_64|linux-armhf|linux-arm64)
+    mkdir build && cd build
+    go build ../server/
+    go build ../radio/
+    ;;
+*)
+    echo "Skipping build on ${PLATFORM}"
+    exit 0
+    ;;
+esac
diff --git a/buildscripts/dist-generic.sh b/buildscripts/dist-generic.sh
new file mode 100755 (executable)
index 0000000..034d98e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+TAG=$1
+
+BASENAME="broadcaster-${TAG}"
+FILENAME="${BASENAME}.tar.xz"
+
+git archive "${TAG}" -o "${FILENAME}" --prefix="${BASENAME}/"
+
+echo "GENERIC_ARTIFACT|${FILENAME}|Source Code"
+echo "URL|Git Tag|https://code.octet-stream.net/broadcaster/shortlog/refs/tags/${TAG}|${TAG}"
diff --git a/buildscripts/dist.sh b/buildscripts/dist.sh
new file mode 100755 (executable)
index 0000000..3d93f69
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+APP=broadcaster
+
+PLATFORM=$1
+TAG=$2
+source buildscripts/init.sh "${PLATFORM}"
+
+BASENAME="${APP}-${TAG}-${PLATFORM}"
+
+case $PLATFORM in
+linux-x86_64|linux-armhf|linux-arm64)
+    FILENAME="${BASENAME}.tar.xz"
+    TARCMD="tar -Jcf ${FILENAME} ${BASENAME}"
+    ;;
+*)
+    echo "Skipping build on ${PLATFORM}"
+    exit 0
+    ;;
+esac
+
+mkdir build && cd build
+mkdir "${BASENAME}"
+go build ../server/
+go build ../radio/
+mv server "${BASENAME}/broadcast-server"
+mv radio "${BASENAME}/broadcast-radio"
+
+${TARCMD}
+
+echo "PLATFORM_ARTIFACT|build/${FILENAME}"
diff --git a/buildscripts/init.sh b/buildscripts/init.sh
new file mode 100755 (executable)
index 0000000..71baa9e
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+PLATFORM=$1
+
+case $PLATFORM in
+mac-x86_64)
+    GOOS=darwin
+    GOARCH=amd64
+    ;;
+mac-arm64)
+    GOOS=darwin
+    GOARCH=arm64
+    ;;
+linux-x86_64)
+    GOOS=linux
+    GOARCH=amd64
+    ;;
+linux-armhf)
+    GOOS=linux
+    GOARCH=arm
+    ;;
+linux-arm64)
+    GOOS=linux
+    GOARCH=arm64
+    ;;
+windows-x86_64)
+    GOOS=windows
+    GOARCH=amd64
+    ;;
+*)
+    echo "Unrecognised platform"
+    exit 1
+    ;;
+esac
+
+export PLATFORM
+export GOOS
+export GOARCH
diff --git a/buildscripts/lint.sh b/buildscripts/lint.sh
new file mode 100755 (executable)
index 0000000..9e633c4
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+case $PLATFORM in
+linux-x86_64|linux-armhf|linux-arm64)
+    cd server
+    files=$(gofmt -l .) && [ -z "$files" ]
+
+    cd ../radio
+    files=$(gofmt -l .) && [ -z "$files" ]
+    ;;
+*)
+    echo "Skipping build on ${PLATFORM}"
+    exit 0
+    ;;
+esac
+
diff --git a/buildscripts/test.sh b/buildscripts/test.sh
new file mode 100755 (executable)
index 0000000..5dbc31c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+case $PLATFORM in
+linux-x86_64|linux-armhf|linux-arm64)
+    cd server
+    go test
+
+    cd ../radio
+    go test
+    ;;
+*)
+    echo "Skipping build on ${PLATFORM}"
+    exit 0
+    ;;
+esac
+
+
+
index 143397a4b923274f8f9e43f6ae90ab73f5a3a678..f6bb98816beb3dd3a93f1a7a117fd7d2be865ea7 100644 (file)
@@ -1,7 +1,6 @@
 package main
 
 import (
 package main
 
 import (
-       "code.octet-stream.net/broadcaster/internal/protocol"
        "crypto/sha256"
        "encoding/hex"
        "io"
        "crypto/sha256"
        "encoding/hex"
        "io"
@@ -9,6 +8,8 @@ import (
        "net/http"
        "os"
        "path/filepath"
        "net/http"
        "os"
        "path/filepath"
+
+       "code.octet-stream.net/broadcaster/internal/protocol"
 )
 
 type FilesMachine struct {
 )
 
 type FilesMachine struct {