Skip to content

Commit

Permalink
chore: update GitHub Actions workflow for building and releasing Bird…
Browse files Browse the repository at this point in the history
…NET-Go

- Enhanced the release build workflow by adding steps to set up Go and install necessary system dependencies.
- Implemented a new build process for BirdNET-Go, including artifact creation and uploading.
- Updated Docker build steps to utilize the latest actions and improved metadata extraction for tagging.
- Ensured compatibility with multiple OS and architecture combinations for the release artifacts.

These changes streamline the build and release process, ensuring a more robust and efficient workflow.
  • Loading branch information
tphakala committed Jan 15, 2025
1 parent cf54985 commit 0a042c1
Showing 1 changed file with 106 additions and 42 deletions.
148 changes: 106 additions & 42 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,111 @@ jobs:
exclude:
- goarch: arm64
goos: windows

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

- name: Build and attach to Release
uses: tphakala/go-release-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://dl.google.com/go/go1.23.4.linux-amd64.tar.gz"
md5sum: false
sha256sum: false
compress_assets: auto
build_command: make ${{ matrix.goos }}_${{ matrix.goarch }}
extra_files: libtensorflowlite_c.so

docker-tagging:
runs-on: ubuntu-20.04
- 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 system dependencies
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/
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

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
runs-on: ubuntu-22.04
needs: build
strategy:
matrix:
platform: [linux/amd64, linux/arm64]

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: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.REPO }}
tags: |
type=semver,pattern={{version}}
- name: Tag docker image with release version
run: |
docker buildx imagetools create -t ghcr.io/${{ env.REPO }}:${{ steps.meta.outputs.version }} ghcr.io/${{ env.REPO }}:${{ github.sha }}
docker buildx imagetools create -t ghcr.io/${{ env.REPO }}:latest ghcr.io/${{ env.REPO }}:${{ github.sha }}
- name: Checkout code
uses: actions/checkout@v4

- 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=semver,pattern={{version}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 0a042c1

Please sign in to comment.