From: Thomas Karpiniec Date: Wed, 28 May 2025 12:12:03 +0000 (+1000) Subject: Configure CI X-Git-Tag: v1.1.0~3 X-Git-Url: https://code.octet-stream.net/broadcaster/commitdiff_plain/f7fc7180de1b1c47a90e0acc3ab60ace465d0bde Configure CI --- diff --git a/buildscripts/build.sh b/buildscripts/build.sh new file mode 100755 index 0000000..28c4afd --- /dev/null +++ b/buildscripts/build.sh @@ -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 index 0000000..034d98e --- /dev/null +++ b/buildscripts/dist-generic.sh @@ -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 index 0000000..3d93f69 --- /dev/null +++ b/buildscripts/dist.sh @@ -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 index 0000000..71baa9e --- /dev/null +++ b/buildscripts/init.sh @@ -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 index 0000000..9e633c4 --- /dev/null +++ b/buildscripts/lint.sh @@ -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 index 0000000..5dbc31c --- /dev/null +++ b/buildscripts/test.sh @@ -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 + + + diff --git a/radio/files_machine.go b/radio/files_machine.go index 143397a..f6bb988 100644 --- a/radio/files_machine.go +++ b/radio/files_machine.go @@ -1,7 +1,6 @@ package main import ( - "code.octet-stream.net/broadcaster/internal/protocol" "crypto/sha256" "encoding/hex" "io" @@ -9,6 +8,8 @@ import ( "net/http" "os" "path/filepath" + + "code.octet-stream.net/broadcaster/internal/protocol" ) type FilesMachine struct {