Skip to content

Commit 52b56b5

Browse files
committed
Modify build workflow to automate api changes
1 parent 1c7f5b2 commit 52b56b5

File tree

1 file changed

+69
-104
lines changed

1 file changed

+69
-104
lines changed

.github/workflows/build.yaml

Lines changed: 69 additions & 104 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)"
70-
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}]')
71-
else
72-
echo "Skipping version: $tag (build $BUILD_NUM < $MIN_BUILD)"
55+
if [[ ! -z "$BUILD_NUM" ]] && [[ $BUILD_NUM -ge $MIN_BUILD_NUMBER ]]; then
56+
echo "Including version: $tag (build $BUILD_NUM)"
57+
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}]')
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-13,
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:
@@ -120,7 +89,7 @@ jobs:
12089

12190
- uses: ilammy/msvc-dev-cmd@v1
12291
if: matrix.config.name == 'windows'
123-
92+
12493
- name: Setup Python
12594
uses: actions/setup-python@v6
12695
with:
@@ -134,55 +103,67 @@ jobs:
134103
git submodule update --init --recursive
135104
136105
- name: Configure CMake
137-
run: |
138-
if [[ "${{ matrix.config.name }}" == "windows" ]]; then
139-
cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON -DPYTHON_COMMAND="python"
140-
else
141-
cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON
142-
fi
106+
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBN_ALLOW_STUBS=ON
143107

144108
- name: Build
145-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
109+
run: cmake --build build --config ${{env.BUILD_TYPE}}
146110

147-
- name: Rename artifacts
111+
- name: Rename artifacts (Windows)
112+
if: matrix.config.name == 'windows'
113+
shell: pwsh
114+
run: |
115+
cd build
116+
$original = Get-ChildItem -Recurse -Filter "*NativePredicateSolver*.dll" | Select-Object -First 1
117+
118+
if ($null -eq $original) {
119+
Write-Error "Built library not found"
120+
exit 1
121+
}
122+
123+
if ("${{ matrix.version.full_version }}" -eq "dev") {
124+
$newName = "NativePredicateSolver-dev.dll"
125+
} else {
126+
$newName = "NativePredicateSolver-${{ matrix.version.full_version }}.dll"
127+
}
128+
129+
Copy-Item -Path $original.FullName -Destination $newName
130+
echo "artifact_name=$newName" >> $env:GITHUB_ENV
131+
132+
- name: Rename artifacts (Unix)
133+
if: matrix.config.name != 'windows'
148134
shell: bash
149135
run: |
150-
cd ${{github.workspace}}/build
136+
cd build
151137
152-
# Find the built library
153-
if [[ "${{ matrix.config.ext }}" == "dll" ]]; then
154-
ORIGINAL=$(find . -name "*NativePredicateSolver.dll" -o -name "*NativePredicateSolver*.dll" | head -n 1)
155-
elif [[ "${{ matrix.config.ext }}" == "so" ]]; then
156-
ORIGINAL=$(find . -name "libNativePredicateSolver.so" -o -name "libNativePredicateSolver*.so" | head -n 1)
138+
if [[ "${{ matrix.config.ext }}" == "so" ]]; then
139+
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.so*" | head -n 1)
157140
else
158-
ORIGINAL=$(find . -name "libNativePredicateSolver.dylib" -o -name "libNativePredicateSolver*.dylib" | head -n 1)
141+
ORIGINAL=$(find . -type f -name "libNativePredicateSolver.dylib*" | head -n 1)
159142
fi
160143
161144
if [[ -z "$ORIGINAL" ]]; then
162-
echo "Error: Could not find built library"
145+
echo "Built library not found"
163146
exit 1
164147
fi
165148
166-
# Determine new name based on version (consistent across all platforms)
167149
if [[ "${{ matrix.version.full_version }}" == "dev" ]]; then
168150
NEW_NAME="NativePredicateSolver-dev.${{ matrix.config.ext }}"
169151
else
170152
NEW_NAME="NativePredicateSolver-${{ matrix.version.full_version }}.${{ matrix.config.ext }}"
171153
fi
172154
173-
echo "Renaming $ORIGINAL to $NEW_NAME"
174155
cp "$ORIGINAL" "$NEW_NAME"
175156
echo "artifact_name=$NEW_NAME" >> $GITHUB_ENV
176157
177158
- name: Upload artifact
178159
uses: actions/upload-artifact@v4
179160
with:
180161
name: ${{ matrix.config.name }}-${{ matrix.version.filename }}
181-
path: ${{ github.workspace }}/build/${{ env.artifact_name }}
162+
path: build/${{ env.artifact_name }}
182163

183164
create-release:
184165
needs: [check-versions, build]
185-
if: needs.check-versions.outputs.should_build == 'true' || github.event.inputs.create_release == 'true'
166+
if: needs.check-versions.outputs.should_build == 'true' || github.event.inputs.create_release == 'true' || github.event_name == 'push'
186167
runs-on: ubuntu-latest
187168
permissions:
188169
contents: write
@@ -199,61 +180,45 @@ jobs:
199180
run: |
200181
mkdir -p release_files
201182
find artifacts -type f \( -name "*.dll" -o -name "*.so" -o -name "*.dylib" \) -exec cp {} release_files/ \;
202-
ls -la release_files/
203183
204184
- name: Generate release notes
205-
id: release_notes
206185
run: |
207-
RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S UTC')
208-
cat > release_notes.md << 'EOF'
209-
## 🤖 Automated Build
210-
211-
This release was automatically generated by GitHub Actions.
212-
213-
**Build Date:** $RELEASE_DATE
214-
**Trigger:** ${{ github.event_name }}
215-
216-
### 📦 Included Builds
217-
218-
This release contains builds for the following Binary Ninja versions:
186+
RELEASE_DATE=$(date +'%Y-%m-%d')
219187
188+
cat > release_notes.md <<EOF
189+
## Build Information
190+
191+
**Date:** ${RELEASE_DATE}
192+
**Commit:** \`${GITHUB_SHA:0:7}\`
193+
194+
### Supported Binary Ninja Versions
195+
220196
EOF
221197
222-
# Add version info
223-
echo "${{ needs.check-versions.outputs.versions_matrix }}" | jq -r '.[] | "- **Version \(.full_version)**: Build `\(.short_name)`"' >> release_notes.md
224-
225-
cat >> release_notes.md << 'EOF'
226-
227-
### 📥 Installation
228-
229-
1. Download the appropriate file for your platform and Binary Ninja version
230-
2. Place it in your Binary Ninja plugins directory
231-
3. Restart Binary Ninja
232-
233-
### 🔧 File Naming Convention
234-
235-
All platforms use the same naming format:
236-
237-
- **Stable versions**: `NativePredicateSolver-[full-version].[ext]`
238-
- Example: `NativePredicateSolver-5.0.7290.dll`, `NativePredicateSolver-5.1.8104.so`
239-
- **Dev version**: `NativePredicateSolver-dev.[ext]`
240-
- Example: `NativePredicateSolver-dev.dll`, `NativePredicateSolver-dev.dylib`
198+
echo '${{ needs.check-versions.outputs.versions_matrix }}' > versions.json
199+
jq -r '.[] | "- \(.full_version) (build \(.short_name))"' versions.json >> release_notes.md
241200
242-
---
243-
244-
**Commit:** ${{ github.sha }}
201+
cat >> release_notes.md <<EOF
202+
203+
### Installation
204+
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.
206+
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.
208+
209+
**Naming format:**
210+
- Stable: \`NativePredicateSolver-<version>.<ext>\`
211+
- Dev: \`NativePredicateSolver-dev.<ext>\`
212+
213+
Where \`<ext>\` is \`dll\` (Windows), \`so\` (Linux), or \`dylib\` (macOS).
245214
EOF
246-
247-
cat release_notes.md
248-
215+
249216
- name: Create Release
250217
uses: softprops/action-gh-release@v1
251218
with:
252-
tag_name: build-${{ github.run_number }}-${{ github.sha }}
253-
name: Automated Build ${{ github.run_number }}
219+
tag_name: build-${{ github.run_number }}
220+
name: Build ${{ github.run_number }}
254221
body_path: release_notes.md
255222
files: release_files/*
256-
draft: false
257-
prerelease: false
258223
env:
259-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)