Skip to content

Commit 98146f2

Browse files
committed
fix: make CI pipeline and sidecar builds work on all platforms
- Move sqlmap-bundle.py and sqlmap-bundle.spec into scripts/ so they are part of the repo (CI can access them without external files) - Remove hardcoded target_arch='arm64' from spec, auto-detect platform - Use SQLMAP_ROOT env var to decouple spec from sqlmap directory location - Rewrite build-sidecar.sh to set SQLMAP_ROOT and use scripts/ spec - Rewrite GitHub Actions workflow: - Single job per platform (sidecar + app build in sequence) - Clone sqlmap inside the workspace - Collect DMG/deb/AppImage/MSI/EXE artifacts - Create GitHub Release with all platform installers - Update updater endpoint to javierpr0/sqlmap-ui - Add build/ to .gitignore (PyInstaller temp directory)
1 parent 50ac093 commit 98146f2

7 files changed

Lines changed: 309 additions & 76 deletions

File tree

.github/workflows/build.yml

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,54 @@ on:
55
tags:
66
- 'v*'
77

8+
permissions:
9+
contents: write
10+
811
jobs:
9-
build-sidecar:
12+
build:
1013
strategy:
14+
fail-fast: false
1115
matrix:
1216
include:
1317
- os: macos-latest
1418
target: aarch64-apple-darwin
19+
label: macOS-arm64
1520
- os: macos-13
1621
target: x86_64-apple-darwin
22+
label: macOS-x86_64
1723
- os: ubuntu-22.04
1824
target: x86_64-unknown-linux-gnu
25+
label: Linux-x86_64
1926
- os: windows-latest
2027
target: x86_64-pc-windows-msvc
28+
label: Windows-x86_64
2129
runs-on: ${{ matrix.os }}
2230
steps:
2331
- uses: actions/checkout@v4
2432

33+
# -- Python + PyInstaller for sidecar --
2534
- uses: actions/setup-python@v5
2635
with:
2736
python-version: '3.10'
2837

29-
- name: Clone sqlmap
30-
run: git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git sqlmap
31-
working-directory: ..
32-
33-
- name: Copy build files to sqlmap
34-
run: |
35-
cp ../sqlmap-bundle.py ../sqlmap/ 2>/dev/null || true
36-
cp ../sqlmap-bundle.spec ../sqlmap/ 2>/dev/null || true
37-
shell: bash
38-
3938
- name: Install PyInstaller
4039
run: pip install pyinstaller
4140

41+
- name: Clone sqlmap
42+
run: git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git sqlmap
43+
working-directory: ${{ github.workspace }}
44+
4245
- name: Build sidecar
4346
run: bash scripts/build-sidecar.sh
47+
env:
48+
SQLMAP_ROOT: ${{ github.workspace }}/sqlmap
49+
shell: bash
4450

45-
- uses: actions/upload-artifact@v4
46-
with:
47-
name: sidecar-${{ matrix.target }}
48-
path: src-tauri/binaries/sqlmap-sidecar-*
49-
50-
build-app:
51-
needs: build-sidecar
52-
strategy:
53-
matrix:
54-
include:
55-
- os: macos-latest
56-
target: aarch64-apple-darwin
57-
- os: macos-13
58-
target: x86_64-apple-darwin
59-
- os: ubuntu-22.04
60-
target: x86_64-unknown-linux-gnu
61-
- os: windows-latest
62-
target: x86_64-pc-windows-msvc
63-
runs-on: ${{ matrix.os }}
64-
steps:
65-
- uses: actions/checkout@v4
51+
- name: Verify sidecar
52+
run: ls -la src-tauri/binaries/
53+
shell: bash
6654

55+
# -- Node + Rust for Tauri --
6756
- uses: pnpm/action-setup@v4
6857
with:
6958
version: 10
@@ -79,30 +68,55 @@ jobs:
7968
if: runner.os == 'Linux'
8069
run: |
8170
sudo apt-get update
82-
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev
83-
84-
- uses: actions/download-artifact@v4
85-
with:
86-
name: sidecar-${{ matrix.target }}
87-
path: src-tauri/binaries/
71+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
8872
8973
- name: Make sidecar executable
9074
if: runner.os != 'Windows'
9175
run: chmod +x src-tauri/binaries/sqlmap-sidecar-*
9276

9377
- run: pnpm install
9478

95-
- run: pnpm tauri build
96-
env:
97-
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
79+
- name: Build Tauri app
80+
run: pnpm tauri build
81+
82+
# -- Collect artifacts --
83+
- name: Collect release artifacts
84+
id: artifacts
85+
run: |
86+
mkdir -p release-artifacts
87+
# macOS
88+
cp src-tauri/target/release/bundle/dmg/*.dmg release-artifacts/ 2>/dev/null || true
89+
# Linux
90+
cp src-tauri/target/release/bundle/deb/*.deb release-artifacts/ 2>/dev/null || true
91+
cp src-tauri/target/release/bundle/appimage/*.AppImage release-artifacts/ 2>/dev/null || true
92+
# Windows
93+
cp src-tauri/target/release/bundle/msi/*.msi release-artifacts/ 2>/dev/null || true
94+
cp src-tauri/target/release/bundle/nsis/*.exe release-artifacts/ 2>/dev/null || true
95+
ls -lh release-artifacts/
96+
shell: bash
9897

9998
- uses: actions/upload-artifact@v4
10099
with:
101-
name: app-${{ matrix.target }}
102-
path: |
103-
src-tauri/target/release/bundle/**/*.dmg
104-
src-tauri/target/release/bundle/**/*.app
105-
src-tauri/target/release/bundle/**/*.deb
106-
src-tauri/target/release/bundle/**/*.AppImage
107-
src-tauri/target/release/bundle/**/*.msi
108-
src-tauri/target/release/bundle/**/*.exe
100+
name: release-${{ matrix.label }}
101+
path: release-artifacts/*
102+
103+
release:
104+
needs: build
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/download-artifact@v4
108+
with:
109+
path: artifacts
110+
merge-multiple: true
111+
112+
- name: List all artifacts
113+
run: find artifacts -type f | sort
114+
115+
- name: Create GitHub Release
116+
uses: softprops/action-gh-release@v2
117+
with:
118+
files: artifacts/**/*
119+
generate_release_notes: true
120+
draft: false
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules/
33

44
# Build output
55
dist/
6+
build/
67

78
# Rust / Tauri
89
src-tauri/target/

scripts/build-sidecar.sh

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,85 @@
11
#!/bin/bash
22
# Build sqlmap sidecar for the current platform.
3-
# Run this on each target OS (macOS, Linux, Windows) to produce the correct binary.
3+
#
4+
# Prerequisites:
5+
# - Python 3 with PyInstaller installed (pip install pyinstaller)
6+
# - sqlmap cloned somewhere on disk
47
#
58
# Usage:
6-
# ./scripts/build-sidecar.sh
9+
# SQLMAP_ROOT=/path/to/sqlmap ./scripts/build-sidecar.sh
710
#
8-
# Output goes to src-tauri/binaries/sqlmap-sidecar-{target-triple}
11+
# If SQLMAP_ROOT is not set, it looks for sqlmap in ../sqlmap relative to the project.
12+
# Output: src-tauri/binaries/sqlmap-sidecar-{target-triple}
913

1014
set -e
1115

1216
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1317
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
14-
SQLMAP_DIR="$(dirname "$PROJECT_DIR")/sqlmap"
1518
BINARIES_DIR="$PROJECT_DIR/src-tauri/binaries"
1619

20+
# Resolve sqlmap root
21+
if [ -z "$SQLMAP_ROOT" ]; then
22+
SQLMAP_ROOT="$(dirname "$PROJECT_DIR")/sqlmap"
23+
fi
24+
25+
export SQLMAP_ROOT
26+
27+
# Validate
28+
if [ ! -f "$SQLMAP_ROOT/sqlmap.py" ]; then
29+
echo "Error: sqlmap.py not found at $SQLMAP_ROOT"
30+
echo "Clone sqlmap first: git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git $SQLMAP_ROOT"
31+
exit 1
32+
fi
33+
1734
# Detect target triple
18-
case "$(uname -s)-$(uname -m)" in
19-
Darwin-arm64) TARGET="aarch64-apple-darwin" ;;
20-
Darwin-x86_64) TARGET="x86_64-apple-darwin" ;;
21-
Linux-x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
22-
Linux-aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
35+
case "$(uname -s)" in
36+
Darwin)
37+
case "$(uname -m)" in
38+
arm64) TARGET="aarch64-apple-darwin" ;;
39+
x86_64) TARGET="x86_64-apple-darwin" ;;
40+
*) echo "Unsupported macOS arch: $(uname -m)"; exit 1 ;;
41+
esac
42+
;;
43+
Linux)
44+
case "$(uname -m)" in
45+
x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
46+
aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
47+
*) echo "Unsupported Linux arch: $(uname -m)"; exit 1 ;;
48+
esac
49+
;;
2350
MINGW*|MSYS*|CYGWIN*)
2451
case "$(uname -m)" in
2552
x86_64) TARGET="x86_64-pc-windows-msvc" ;;
2653
*) TARGET="aarch64-pc-windows-msvc" ;;
2754
esac
2855
;;
29-
*) echo "Unsupported platform: $(uname -s)-$(uname -m)"; exit 1 ;;
56+
*) echo "Unsupported OS: $(uname -s)"; exit 1 ;;
3057
esac
3158

32-
echo "Building sqlmap sidecar for: $TARGET"
33-
echo "sqlmap directory: $SQLMAP_DIR"
34-
echo "Output: $BINARIES_DIR/sqlmap-sidecar-$TARGET"
59+
echo "=== Building sqlmap sidecar ==="
60+
echo "Platform: $TARGET"
61+
echo "sqlmap: $SQLMAP_ROOT"
62+
echo "Spec: $SCRIPT_DIR/sqlmap-bundle.spec"
63+
echo "Output: $BINARIES_DIR/sqlmap-sidecar-$TARGET"
64+
echo ""
3565

36-
if [ ! -f "$SQLMAP_DIR/sqlmap-bundle.spec" ]; then
37-
echo "Error: $SQLMAP_DIR/sqlmap-bundle.spec not found"
38-
echo "Make sure sqlmap is cloned next to sqlmap-ui/"
39-
exit 1
40-
fi
66+
mkdir -p "$BINARIES_DIR"
4167

42-
cd "$SQLMAP_DIR"
43-
44-
python3 -m PyInstaller sqlmap-bundle.spec \
68+
python3 -m PyInstaller "$SCRIPT_DIR/sqlmap-bundle.spec" \
4569
--distpath "$BINARIES_DIR" \
70+
--workpath "$PROJECT_DIR/build/pyinstaller" \
4671
--clean -y
4772

48-
# Rename to include target triple
73+
# Rename binary to include target triple
4974
if [ -f "$BINARIES_DIR/sqlmap-sidecar" ]; then
5075
mv "$BINARIES_DIR/sqlmap-sidecar" "$BINARIES_DIR/sqlmap-sidecar-$TARGET"
51-
echo "Success: $BINARIES_DIR/sqlmap-sidecar-$TARGET"
52-
ls -lh "$BINARIES_DIR/sqlmap-sidecar-$TARGET"
5376
elif [ -f "$BINARIES_DIR/sqlmap-sidecar.exe" ]; then
5477
mv "$BINARIES_DIR/sqlmap-sidecar.exe" "$BINARIES_DIR/sqlmap-sidecar-$TARGET.exe"
55-
echo "Success: $BINARIES_DIR/sqlmap-sidecar-$TARGET.exe"
56-
ls -lh "$BINARIES_DIR/sqlmap-sidecar-$TARGET.exe"
5778
else
5879
echo "Error: sidecar binary not found after build"
5980
exit 1
6081
fi
82+
83+
echo ""
84+
echo "=== Success ==="
85+
ls -lh "$BINARIES_DIR/sqlmap-sidecar-$TARGET"* 2>/dev/null

scripts/sqlmap-bundle.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Entry point for PyInstaller bundle.
3+
Patches broken MySQLdb, overrides modulePath for frozen builds, then runs sqlmap.
4+
"""
5+
import sys
6+
import os
7+
import types
8+
9+
# Block broken MySQLdb import
10+
fake_mysqldb = types.ModuleType("MySQLdb")
11+
fake_mysqldb.version_info = (0, 0, 0)
12+
fake_mysqldb._mysql = types.ModuleType("MySQLdb._mysql")
13+
fake_mysqldb._mysql.version_info = (0, 0, 0)
14+
fake_mysqldb._mysql.__file__ = ""
15+
sys.modules["MySQLdb"] = fake_mysqldb
16+
sys.modules["MySQLdb._mysql"] = fake_mysqldb._mysql
17+
18+
# When running as a PyInstaller bundle, _MEIPASS points to the extracted dir
19+
if getattr(sys, 'frozen', False):
20+
bundle_dir = sys._MEIPASS
21+
else:
22+
bundle_dir = os.path.dirname(os.path.abspath(__file__))
23+
24+
os.chdir(bundle_dir)
25+
sys.path.insert(0, bundle_dir)
26+
27+
# Patch sqlmap's modulePath to return _MEIPASS instead of exe directory
28+
import sqlmap as sqlmap_module
29+
sqlmap_module.modulePath = lambda: bundle_dir
30+
31+
# Also patch weAreFrozen so setPaths reads from _MEIPASS
32+
from lib.core import common as common_module
33+
_original_modulePath = common_module.getUnicode if hasattr(common_module, 'getUnicode') else str
34+
35+
# Override modulePath at the common level too if it exists
36+
if hasattr(common_module, 'modulePath'):
37+
common_module.modulePath = lambda: bundle_dir
38+
39+
sqlmap_module.main()

0 commit comments

Comments
 (0)