-
-
Notifications
You must be signed in to change notification settings - Fork 22
217 lines (184 loc) · 6.33 KB
/
nightly-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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-linux-windows:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
goos: [linux, windows]
goarch: [amd64, arm64]
exclude:
- goarch: arm64
goos: windows
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 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 clang
- 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
# 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 }}
nightly-darwin:
runs-on: macos-14
strategy:
fail-fast: false
matrix:
goarch: [amd64, arm64]
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: Build BirdNET-Go
run: |
# Build the application
if [ "${{ matrix.goarch }}" = "amd64" ]; then
CGO_FLAGS="CGO_ENABLED=1 CGO_CFLAGS=\"-I${HOME}/src/tensorflow -target x86_64-apple-darwin\"" make darwin_amd64
else
CGO_FLAGS="CGO_ENABLED=1 CGO_CFLAGS=\"-I${HOME}/src/tensorflow -target arm64-apple-darwin\"" make darwin_arm64
fi
env:
GOOS: darwin
GOARCH: ${{ matrix.goarch }}
- name: Create Release Artifacts
run: |
# Create artifacts directory
mkdir -p artifacts
# Copy binary
cp bin/birdnet-go artifacts/
# Create tarball
cd artifacts
tar czf ../birdnet-go-darwin-${{ matrix.goarch }}.tar.gz *
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: birdnet-go-darwin-${{ matrix.goarch }}
path: birdnet-go-darwin-${{ matrix.goarch }}.tar.gz
- 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-darwin-${{ matrix.goarch }}.tar.gz
tag_name: nightly-${{ env.RELEASE_DATE }}
name: "Nightly Build ${{ env.RELEASE_DATE }}"
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
runs-on: ubuntu-22.04
needs: [nightly-linux-windows, nightly-darwin]
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
steps:
- 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=raw,value=nightly
type=raw,value=nightly-{{date 'YYYYMMDD'}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}