Skip to content

Commit

Permalink
Merge pull request #56 from tphakala/dev
Browse files Browse the repository at this point in the history
Add dependabot.yml and binary build workflow
  • Loading branch information
tphakala authored Mar 16, 2024
2 parents 3de992a + 446f891 commit 743a88e
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
88 changes: 88 additions & 0 deletions .github/workflows/binary-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build Binaries for BirdNET-Go

on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- platform: windows_amd64
go-version: '1.22'
make-target: windows
binary-suffix: .exe
tflite-lib: tflite_c_v2.14.0_windows_amd64.zip
- platform: linux_amd64
go-version: '1.22'
make-target: linux_amd64
binary-suffix: ''
tflite-lib: tflite_c_v2.14.0_linux_amd64.tar.gz
- platform: linux_arm64
go-version: '1.22'
make-target: linux_arm64
binary-suffix: ''
tflite-lib: tflite_c_v2.14.0_linux_arm64.tar.gz

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
check-latest: true

- name: Install dependencies for Windows build
if: matrix.platform == 'windows_amd64'
run: |
sudo apt update && sudo apt install -y mingw-w64-tools gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 unzip
- name: Install dependencies for Linux arm64 build
if: matrix.platform == 'linux_arm64'
run: |
sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu unzip
- name: Download & Set up TensorFlow Lite C library
run: |
wget https://github.com/tphakala/tflite_c/releases/download/v2.14.0/${{ matrix.tflite-lib }}
mkdir tflite_c
if [[ "${{ matrix.tflite-lib }}" == *.zip ]]; then
unzip ${{ matrix.tflite-lib }} -d tflite_c
else
tar -xzf ${{ matrix.tflite-lib }} -C tflite_c
fi
- name: Install TensorFlow Lite C library to system path (Linux)
if: matrix.platform == 'linux_amd64' || matrix.platform == 'linux_arm64'
run: |
sudo cp tflite_c/libtensorflowlite_c.so /usr/lib/
sudo ldconfig
- name: Install TensorFlow Lite C library to system path (Windows)
if: matrix.platform == 'windows_amd64'
run: |
sudo cp tflite_c/libtensorflowlite_c.dll /usr/x86_64-w64-mingw32/lib/
- name: Clone TensorFlow repository
run: |
mkdir -p ~/src
git clone --branch v2.14.0 --depth 1 https://github.com/tensorflow/tensorflow.git ~/src/tensorflow
- name: Build BirdNET-Go
run: make ${{ matrix.make-target }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: birdnet-go_${{ matrix.platform }}
path: |
bin/birdnet-go${{ matrix.binary-suffix }}
tflite_c/libtensorflowlite_c.so
retention-days: 30
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ ifeq ($(TARGETPLATFORM),linux/arm64)
endif

# Common flags
#CGO_FLAGS := CGO_ENABLED=1 CGO_CFLAGS="-I$(HOME)/src/tensorflow -DMA_NO_PULSEAUDIO"
CGO_FLAGS := CGO_ENABLED=1 CGO_CFLAGS="-I$(HOME)/src/tensorflow"
LDFLAGS := -ldflags "-s -w"

# Detect host architecture
UNAME_M := $(shell uname -m)

# Default build for local development
build:
$(CGO_FLAGS) go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)
Expand All @@ -24,9 +26,15 @@ build:
linux_amd64:
GOOS=linux GOARCH=amd64 $(CGO_FLAGS) go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)

# Build for Linux arm64
# Build for Linux arm64, with cross-compilation setup if on amd64
linux_arm64:
GOOS=linux GOARCH=arm64 $(CGO_FLAGS) go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)
ifeq ($(UNAME_M),x86_64)
@# Cross-compilation setup for amd64 to arm64
CC=aarch64-linux-gnu-gcc $(CGO_FLAGS) GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)
else
@# Native compilation for arm64
$(CGO_FLAGS) GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)
endif

# Windows build
windows:
Expand All @@ -42,4 +50,4 @@ macos_arm:

clean:
go clean
rm -rf $(BINARY_DIR)/$(BINARY_NAME) $(BINARY_DIR)/$(BINARY_NAME).exe
rm -rf $(BINARY_DIR)/*

0 comments on commit 743a88e

Please sign in to comment.