Skip to content

Commit 8559af2

Browse files
committed
polished cmake for automated building
1 parent 3184ea9 commit 8559af2

File tree

1 file changed

+35
-102
lines changed

1 file changed

+35
-102
lines changed

.github/workflows/build.yaml

Lines changed: 35 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ on:
1313
type: boolean
1414
default: false
1515
schedule:
16-
# Check for updates daily at 2 AM UTC
1716
- cron: '0 2 * * *'
1817

1918
env:
2019
BUILD_TYPE: Release
20+
MIN_BUILD_NUMBER: 7290
2121

2222
jobs:
23-
# First, check if there are new Binary Ninja versions
2423
check-versions:
2524
runs-on: ubuntu-latest
2625
outputs:
@@ -38,49 +37,31 @@ jobs:
3837
cd binaryninjaapi
3938
git fetch --tags origin
4039
41-
# Always include dev
42-
VERSIONS_JSON='[
43-
{"name": "dev", "filename": "dev", "short_name": "dev", "full_version": "dev"}
44-
]'
40+
VERSIONS_JSON='[{"name": "dev", "filename": "dev", "short_name": "dev", "full_version": "dev"}]'
4541
46-
# Parse stable versions and filter for build numbers >= 7290
47-
MIN_BUILD=7290
48-
49-
# Get all tags that match either format: v*-stable or stable/*
5042
ALL_TAGS=$(git tag -l 'v*-stable' 'stable/*' | sort -V)
5143
5244
for tag in $ALL_TAGS; do
53-
# Extract version number based on tag format
5445
if [[ $tag == v*-stable ]]; then
55-
# Old format: v5.0.7648-stable
5646
VERSION=$(echo $tag | sed 's/^v//' | sed 's/-stable$//')
5747
elif [[ $tag == stable/* ]]; then
58-
# New format: stable/5.0.7648
5948
VERSION=$(echo $tag | sed 's|stable/||')
6049
else
6150
continue
6251
fi
6352
64-
# Extract last 4 digits (build number)
6553
BUILD_NUM=$(echo $VERSION | grep -oE '[0-9]{4}$')
6654
67-
# Only include if build number >= 7290
68-
if [[ ! -z "$BUILD_NUM" ]] && [[ $BUILD_NUM -ge $MIN_BUILD ]]; then
69-
echo "Including version: $tag (build $BUILD_NUM, full version $VERSION)"
55+
if [[ ! -z "$BUILD_NUM" ]] && [[ $BUILD_NUM -ge $MIN_BUILD_NUMBER ]]; then
56+
echo "Including version: $tag (build $BUILD_NUM)"
7057
VERSIONS_JSON=$(echo $VERSIONS_JSON | jq -c --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}]')
71-
else
72-
echo "Skipping version: $tag (build $BUILD_NUM < $MIN_BUILD)"
7358
fi
7459
done
7560
76-
echo "Final versions matrix:"
77-
echo "$VERSIONS_JSON" | jq '.'
78-
7961
echo "versions_matrix<<EOF" >> $GITHUB_OUTPUT
8062
echo "$VERSIONS_JSON" >> $GITHUB_OUTPUT
8163
echo "EOF" >> $GITHUB_OUTPUT
8264
83-
# Check if this is a scheduled run or manual dispatch with create_release
8465
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ inputs.create_release }}" == "true" ]]; then
8566
echo "should_build=true" >> $GITHUB_OUTPUT
8667
else
@@ -94,21 +75,9 @@ jobs:
9475
strategy:
9576
matrix:
9677
config:
97-
- {
98-
os: windows-latest,
99-
name: windows,
100-
ext: dll
101-
}
102-
- {
103-
os: macos-15,
104-
name: macos,
105-
ext: dylib
106-
}
107-
- {
108-
os: ubuntu-24.04,
109-
name: ubuntu,
110-
ext: so
111-
}
78+
- { os: windows-latest, name: windows, ext: dll }
79+
- { os: macos-15, name: macos, ext: dylib }
80+
- { os: ubuntu-24.04, name: ubuntu, ext: so }
11281
version: ${{ fromJson(needs.check-versions.outputs.versions_matrix) }}
11382

11483
steps:
@@ -134,77 +103,63 @@ jobs:
134103
git submodule update --init --recursive
135104
136105
- name: Configure CMake
137-
run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON
106+
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON
138107

139108
- name: Build
140-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
109+
run: cmake --build build --config ${{env.BUILD_TYPE}}
141110

142111
- name: Rename artifacts (Windows)
143112
if: matrix.config.name == 'windows'
144113
shell: pwsh
145114
run: |
146-
$buildDir = "${{github.workspace}}\build"
147-
Set-Location $buildDir
148-
149-
# Find the built DLL
115+
cd build
150116
$original = Get-ChildItem -Recurse -Filter "*NativePredicateSolver*.dll" | Select-Object -First 1
151117
152118
if ($null -eq $original) {
153-
Write-Error "Error: Could not find built library"
119+
Write-Error "Built library not found"
154120
exit 1
155121
}
156122
157-
Write-Host "Found: $($original.FullName)"
158-
159-
# Determine new name based on version
160123
if ("${{ matrix.version.full_version }}" -eq "dev") {
161124
$newName = "NativePredicateSolver-dev.dll"
162125
} else {
163126
$newName = "NativePredicateSolver-${{ matrix.version.full_version }}.dll"
164127
}
165128
166-
Write-Host "Copying to: $newName"
167129
Copy-Item -Path $original.FullName -Destination $newName
168-
169-
# Set output for upload step
170130
echo "artifact_name=$newName" >> $env:GITHUB_ENV
171131
172132
- name: Rename artifacts (Unix)
173133
if: matrix.config.name != 'windows'
174134
shell: bash
175135
run: |
176-
cd ${{github.workspace}}/build
136+
cd build
177137
178-
# Find the built library
179138
if [[ "${{ matrix.config.ext }}" == "so" ]]; then
180-
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.so" -o -name "libNativePredicateSolver*.so" | head -n 1)
139+
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.so*" | head -n 1)
181140
else
182-
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.dylib" -o -name "libNativePredicateSolver*.dylib" | head -n 1)
141+
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.dylib*" | head -n 1)
183142
fi
184143
185144
if [[ -z "$ORIGINAL" ]]; then
186-
echo "Error: Could not find built library"
145+
echo "Built library not found"
187146
exit 1
188147
fi
189148
190-
echo "Found: $ORIGINAL"
191-
192-
# Determine new name based on version
193149
if [[ "${{ matrix.version.full_version }}" == "dev" ]]; then
194150
NEW_NAME="NativePredicateSolver-dev.${{ matrix.config.ext }}"
195151
else
196152
NEW_NAME="NativePredicateSolver-${{ matrix.version.full_version }}.${{ matrix.config.ext }}"
197153
fi
198154
199-
echo "Copying to: $NEW_NAME"
200155
cp "$ORIGINAL" "$NEW_NAME"
201156
echo "artifact_name=$NEW_NAME" >> $GITHUB_ENV
202157
203158
- name: Upload artifact
204159
uses: actions/upload-artifact@v4
205160
with:
206161
name: ${{ matrix.config.name }}-${{ matrix.version.filename }}
207-
path: ${{ github.workspace }}/build/${{ env.artifact_name }}
162+
path: build/${{ env.artifact_name }}
208163

209164
create-release:
210165
needs: [check-versions, build]
@@ -225,67 +180,45 @@ jobs:
225180
run: |
226181
mkdir -p release_files
227182
find artifacts -type f \( -name "*.dll" -o -name "*.so" -o -name "*.dylib" \) -exec cp {} release_files/ \;
228-
ls -la release_files/
229183
230184
- name: Generate release notes
231-
id: release_notes
232185
run: |
233-
set -e
234-
235-
RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S UTC')
236-
237-
# Write the initial section of the release notes
186+
RELEASE_DATE=$(date +'%Y-%m-%d')
187+
238188
cat > release_notes.md <<EOF
239-
## 🤖 Automated Build
189+
## Build Information
240190
241-
This release was automatically generated by GitHub Actions.
191+
**Date:** ${RELEASE_DATE}
192+
**Commit:** \`${GITHUB_SHA:0:7}\`
242193
243-
**Build Date:** ${RELEASE_DATE}
244-
**Trigger:** ${{ github.event_name }}
245-
246-
### 📦 Included Builds
247-
248-
This release contains builds for the following Binary Ninja versions:
194+
### Supported Binary Ninja Versions
249195
250196
EOF
251-
197+
252198
echo '${{ needs.check-versions.outputs.versions_matrix }}' > versions.json
253-
jq -c -r '.[] | "- **Version \(.full_version)**: Build `\(.short_name)`"' versions.json >> release_notes.md
254-
255-
# Append the remaining sections
199+
jq -r '.[] | "- \(.full_version) (build \(.short_name))"' versions.json >> release_notes.md
200+
256201
cat >> release_notes.md <<EOF
257202
258-
### 📥 Installation
259-
260-
1. Download the appropriate file for your platform and Binary Ninja version
261-
2. Place it in your Binary Ninja plugins directory
262-
3. Restart Binary Ninja
203+
### Installation
263204
264-
### 🔧 File Naming Convention
205+
**Option 1 (Recommended):** Use the [loader plugin](https://github.com/ScriptWare-Software/native-predicate-solver_loader) which automatically downloads and updates the correct binary for your Binary Ninja version.
265206
266-
All platforms use the same naming format:
207+
**Option 2:** Manual installation - download the appropriate binary for your platform and Binary Ninja version, then place it in your Binary Ninja plugins directory.
267208
268-
- **Stable versions**: \`NativePredicateSolver-[full-version].[ext]\`
269-
- Example: \`NativePredicateSolver-5.0.7290.dll\`, \`NativePredicateSolver-5.1.8104.so\`
270-
- **Dev version**: \`NativePredicateSolver-dev.[ext]\`
271-
- Example: \`NativePredicateSolver-dev.dll\`, \`NativePredicateSolver-dev.dylib\`
209+
**Naming format:**
210+
- Stable: \`NativePredicateSolver-<version>.<ext>\`
211+
- Dev: \`NativePredicateSolver-dev.<ext>\`
272212
273-
---
274-
275-
**Commit:** ${{ github.sha }}
213+
Where \`<ext>\` is \`dll\` (Windows), \`so\` (Linux), or \`dylib\` (macOS).
276214
EOF
277215
278-
echo "✅ Generated release notes:"
279-
cat release_notes.md
280-
281216
- name: Create Release
282217
uses: softprops/action-gh-release@v1
283218
with:
284-
tag_name: build-${{ github.run_number }}-${{ github.sha }}
285-
name: Automated Build ${{ github.run_number }}
219+
tag_name: build-${{ github.run_number }}
220+
name: Build ${{ github.run_number }}
286221
body_path: release_notes.md
287222
files: release_files/*
288-
draft: false
289-
prerelease: false
290223
env:
291-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)