BirdNET-Go Nightly Build #129
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: BirdNET-Go Nightly Build | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
ACTIONS_STEP_DEBUG: true | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
nightly: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- goos: linux | |
goarch: amd64 | |
os: ubuntu-22.04 | |
- goos: linux | |
goarch: arm64 | |
os: ubuntu-22.04 | |
- goos: windows | |
goarch: amd64 | |
os: ubuntu-22.04 | |
- goos: darwin | |
goarch: arm64 | |
os: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
check-latest: true | |
- name: Install Linux system dependencies | |
if: matrix.os == 'ubuntu-22.04' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential pkg-config gcc-aarch64-linux-gnu gcc-mingw-w64-x86-64 | |
- name: Build BirdNET-Go | |
run: | | |
# Build the application | |
make ${{ matrix.goos }}_${{ matrix.goarch }} | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
CGO_ENABLED: 1 | |
- name: Create Release Artifacts | |
run: | | |
# Create artifacts directory | |
mkdir -p artifacts | |
# Set binary name based on OS | |
BINARY_NAME=birdnet-go | |
if [ "${{ matrix.goos }}" = "windows" ]; then | |
BINARY_NAME=birdnet-go.exe | |
fi | |
# Copy binary | |
cp bin/$BINARY_NAME artifacts/ | |
# Copy required library files based on OS and architecture | |
if [ "${{ matrix.goos }}" = "linux" ]; then | |
if [ "${{ matrix.goarch }}" = "amd64" ]; then | |
cp /usr/lib/libtensorflowlite_c.so artifacts/ | |
elif [ "${{ matrix.goarch }}" = "arm64" ]; then | |
cp /usr/aarch64-linux-gnu/lib/libtensorflowlite_c.so artifacts/ | |
fi | |
elif [ "${{ matrix.goos }}" = "windows" ]; then | |
cp /usr/x86_64-w64-mingw32/lib/tensorflowlite_c.dll artifacts/ | |
elif [ "${{ matrix.goos }}" = "darwin" ]; then | |
cp /opt/homebrew/lib/libtensorflowlite_c.dylib artifacts/ | |
fi | |
# Create tarball | |
cd artifacts | |
tar czf ../birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz * | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
# Optional: Create a GitHub release for tagged builds | |
- name: Create Release | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
DATE=$(date +'%Y%m%d') | |
echo "RELEASE_DATE=$DATE" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
if: github.event_name == 'workflow_dispatch' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
tag_name: nightly-${{ env.RELEASE_DATE }} | |
name: "Nightly Build ${{ env.RELEASE_DATE }}" | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Delete old releases | |
uses: dev-drprasad/delete-older-releases@v0.3.2 | |
with: | |
keep_latest: 14 | |
delete_tags: true | |
delete_tag_pattern: ^nightly- | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker: | |
runs-on: ubuntu-24.04 | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags | |
- name: Get version | |
id: get_version | |
run: | | |
VERSION=$(git describe --tags --always) | |
echo "VERSION=${VERSION}" >> ${GITHUB_ENV} | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate downcase repository name | |
run: | | |
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ env.REPO }} | |
tags: | | |
type=raw,value=${{ steps.get_version.outputs.version }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} | |
type=raw,value=nightly-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}-{{date 'YYYYMMDD'}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: ${{ matrix.platform }} | |
build-args: | | |
BUILD_VERSION=${{ steps.get_version.outputs.version }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: false | |
create-manifest: | |
needs: docker | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate downcase repository name | |
run: | | |
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
- name: Create and push manifest | |
run: | | |
DATE=$(date +'%Y%m%d') | |
# Create and push the version-specific manifest | |
docker manifest create ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }} \ | |
ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }}-amd64 \ | |
ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }}-arm64 | |
docker manifest push ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }} | |
# Create and push the dated manifest | |
docker manifest create ghcr.io/${{ env.REPO }}:nightly-${DATE} \ | |
ghcr.io/${{ env.REPO }}:nightly-amd64-${DATE} \ | |
ghcr.io/${{ env.REPO }}:nightly-arm64-${DATE} | |
docker manifest push ghcr.io/${{ env.REPO }}:nightly-${DATE} | |
# Add inspect commands for debugging | |
echo "Inspecting available images..." | |
docker manifest inspect ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }}-amd64 || true | |
docker manifest inspect ghcr.io/${{ env.REPO }}:${{ needs.docker.outputs.version }}-arm64 || true |