-
Notifications
You must be signed in to change notification settings - Fork 6
285 lines (229 loc) · 9.13 KB
/
build.yaml
File metadata and controls
285 lines (229 loc) · 9.13 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Build and Release
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
inputs:
create_release:
description: 'Create a new release'
required: false
type: boolean
default: false
schedule:
# Check for updates daily at 2 AM UTC
- cron: '0 2 * * *'
env:
BUILD_TYPE: Release
jobs:
# First, check if there are new Binary Ninja versions
check-versions:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
versions_matrix: ${{ steps.check.outputs.versions_matrix }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
- name: Check for new versions
id: check
run: |
cd binaryninjaapi
git fetch --tags origin
# Always include dev
VERSIONS_JSON='[
{"name": "dev", "filename": "dev", "short_name": "dev", "full_version": "dev"}
]'
# Parse stable versions and filter for build numbers >= 7290
MIN_BUILD=7290
# Get all tags that match either format: v*-stable or stable/*
ALL_TAGS=$(git tag -l 'v*-stable' 'stable/*' | sort -V)
for tag in $ALL_TAGS; do
# Extract version number based on tag format
if [[ $tag == v*-stable ]]; then
# Old format: v5.0.7648-stable
VERSION=$(echo $tag | sed 's/^v//' | sed 's/-stable$//')
elif [[ $tag == stable/* ]]; then
# New format: stable/5.0.7648
VERSION=$(echo $tag | sed 's|stable/||')
else
continue
fi
# Extract last 4 digits (build number)
BUILD_NUM=$(echo $VERSION | grep -oE '[0-9]{4}$')
# Only include if build number >= 7290
if [[ ! -z "$BUILD_NUM" ]] && [[ $BUILD_NUM -ge $MIN_BUILD ]]; then
echo "Including version: $tag (build $BUILD_NUM, full version $VERSION)"
VERSIONS_JSON=$(echo $VERSIONS_JSON | jq --arg name "$tag" --arg filename "v$VERSION-stable" --arg short "$BUILD_NUM" --arg fullver "$VERSION" '. += [{"name": $name, "filename": $filename, "short_name": $short, "full_version": $fullver}]')
else
echo "Skipping version: $tag (build $BUILD_NUM < $MIN_BUILD)"
fi
done
echo "Final versions matrix:"
echo "$VERSIONS_JSON" | jq '.'
echo "versions_matrix<<EOF" >> $GITHUB_OUTPUT
echo "$VERSIONS_JSON" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Check if this is a scheduled run or manual dispatch with create_release
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ inputs.create_release }}" == "true" ]]; then
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build:
needs: check-versions
if: needs.check-versions.outputs.should_build == 'true' || github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- {
os: windows-latest,
name: windows,
ext: dll
}
- {
os: macos-15,
name: macos,
ext: dylib
}
- {
os: ubuntu-24.04,
name: ubuntu,
ext: so
}
version: ${{ fromJson(needs.check-versions.outputs.versions_matrix) }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: seanmiddleditch/gha-setup-ninja@master
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.config.name == 'windows'
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Update submodule
run: |
cd binaryninjaapi
git fetch --tags
git checkout --force ${{ matrix.version.name }}
git submodule update --init --recursive
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Rename artifacts (Windows)
if: matrix.config.name == 'windows'
shell: pwsh
run: |
$buildDir = "${{github.workspace}}\build"
Set-Location $buildDir
# Find the built DLL
$original = Get-ChildItem -Recurse -Filter "*NativePredicateSolver*.dll" | Select-Object -First 1
if ($null -eq $original) {
Write-Error "Error: Could not find built library"
exit 1
}
Write-Host "Found: $($original.FullName)"
# Determine new name based on version
if ("${{ matrix.version.full_version }}" -eq "dev") {
$newName = "NativePredicateSolver-dev.dll"
} else {
$newName = "NativePredicateSolver-${{ matrix.version.full_version }}.dll"
}
Write-Host "Copying to: $newName"
Copy-Item -Path $original.FullName -Destination $newName
# Set output for upload step
echo "artifact_name=$newName" >> $env:GITHUB_ENV
- name: Rename artifacts (Unix)
if: matrix.config.name != 'windows'
shell: bash
run: |
cd ${{github.workspace}}/build
# Find the built library
if [[ "${{ matrix.config.ext }}" == "so" ]]; then
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.so" -o -name "libNativePredicateSolver*.so" | head -n 1)
else
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.dylib" -o -name "libNativePredicateSolver*.dylib" | head -n 1)
fi
if [[ -z "$ORIGINAL" ]]; then
echo "Error: Could not find built library"
exit 1
fi
echo "Found: $ORIGINAL"
# Determine new name based on version
if [[ "${{ matrix.version.full_version }}" == "dev" ]]; then
NEW_NAME="NativePredicateSolver-dev.${{ matrix.config.ext }}"
else
NEW_NAME="NativePredicateSolver-${{ matrix.version.full_version }}.${{ matrix.config.ext }}"
fi
echo "Copying to: $NEW_NAME"
cp "$ORIGINAL" "$NEW_NAME"
echo "artifact_name=$NEW_NAME" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.name }}-${{ matrix.version.filename }}
path: ${{ github.workspace }}/build/${{ env.artifact_name }}
create-release:
needs: [check-versions, build]
if: needs.check-versions.outputs.should_build == 'true' || github.event.inputs.create_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Organize artifacts
run: |
mkdir -p release_files
find artifacts -type f \( -name "*.dll" -o -name "*.so" -o -name "*.dylib" \) -exec cp {} release_files/ \;
ls -la release_files/
- name: Generate release notes
id: release_notes
run: |
RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S UTC')
cat > release_notes.md << 'EOF'
## 🤖 Automated Build
This release was automatically generated by GitHub Actions.
**Build Date:** $RELEASE_DATE
**Trigger:** ${{ github.event_name }}
### 📦 Included Builds
This release contains builds for the following Binary Ninja versions:
EOF
# Add version info
echo "${{ needs.check-versions.outputs.versions_matrix }}" | jq -r '.[] | "- **Version \(.full_version)**: Build `\(.short_name)`"' >> release_notes.md
cat >> release_notes.md << 'EOF'
### 📥 Installation
1. Download the appropriate file for your platform and Binary Ninja version
2. Place it in your Binary Ninja plugins directory
3. Restart Binary Ninja
### 🔧 File Naming Convention
All platforms use the same naming format:
- **Stable versions**: `NativePredicateSolver-[full-version].[ext]`
- Example: `NativePredicateSolver-5.0.7290.dll`, `NativePredicateSolver-5.1.8104.so`
- **Dev version**: `NativePredicateSolver-dev.[ext]`
- Example: `NativePredicateSolver-dev.dll`, `NativePredicateSolver-dev.dylib`
---
**Commit:** ${{ github.sha }}
EOF
cat release_notes.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: build-${{ github.run_number }}-${{ github.sha }}
name: Automated Build ${{ github.run_number }}
body_path: release_notes.md
files: release_files/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}