mirror of
https://github.com/h9zdev/GeoSentinel
synced 2026-04-25 17:25:10 +02:00
Refactor workflow for manual build and release
This commit is contained in:
210
.github/workflows/manual.yml
vendored
210
.github/workflows/manual.yml
vendored
@@ -1,209 +1,75 @@
|
||||
name: Reusable Build and Release
|
||||
name: Manual Build and Release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: "Tag to create (e.g. v1.0.0)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
release_name:
|
||||
description: "Release display name (optional)"
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
type: string
|
||||
|
||||
overwrite_release:
|
||||
description: "If true, delete existing release with the same tag before creating (CAREFUL)"
|
||||
required: false
|
||||
type: string
|
||||
default: "true"
|
||||
type: string
|
||||
|
||||
draft:
|
||||
description: "Create release as draft? (true/false)"
|
||||
required: false
|
||||
type: string
|
||||
default: "false"
|
||||
type: string
|
||||
|
||||
prerelease:
|
||||
description: "Create release as prerelease? (true/false)"
|
||||
required: false
|
||||
type: string
|
||||
default: "false"
|
||||
|
||||
# Repo entrypoint (present in repo root)
|
||||
main_py_file:
|
||||
required: false
|
||||
type: string
|
||||
default: "OSINT-framework.py"
|
||||
|
||||
app_name:
|
||||
description: "Output app name (filename will be sanitized)"
|
||||
required: false
|
||||
default: "Geosentinel"
|
||||
type: string
|
||||
|
||||
main_py_file:
|
||||
description: "Entrypoint python file"
|
||||
required: false
|
||||
default: "app.py"
|
||||
type: string
|
||||
|
||||
requirements_file:
|
||||
description: "Requirements file"
|
||||
required: false
|
||||
type: string
|
||||
default: "requirements.txt"
|
||||
|
||||
# Pretty name allowed; we sanitize to a safe filename for the actual binary
|
||||
app_name:
|
||||
required: false
|
||||
type: string
|
||||
default: "Osint Mindmap"
|
||||
|
||||
python_version:
|
||||
description: "Python version"
|
||||
required: false
|
||||
type: string
|
||||
default: "3.10"
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ inputs.python_version }}
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python -m pip install --upgrade pip
|
||||
if [ -f "${{ inputs.requirements_file }}" ]; then
|
||||
pip install -r "${{ inputs.requirements_file }}"
|
||||
else
|
||||
echo "No requirements file found at: ${{ inputs.requirements_file }} (continuing)"
|
||||
fi
|
||||
pip install pyinstaller
|
||||
|
||||
- name: Build Windows EXE (no console)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$Pretty = "${{ inputs.app_name }}"
|
||||
$Safe = ($Pretty -replace '[^A-Za-z0-9._-]', '_')
|
||||
|
||||
pyinstaller --onefile --noconsole --name "$Safe" "${{ inputs.main_py_file }}"
|
||||
|
||||
$exePath = "dist\$Safe.exe"
|
||||
if (!(Test-Path $exePath)) {
|
||||
Write-Host "dist/ contains:"
|
||||
Get-ChildItem -Path dist -Force | Format-Table -AutoSize
|
||||
throw "Expected $exePath not found"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path out | Out-Null
|
||||
Copy-Item $exePath "out\$Safe.exe" -Force
|
||||
|
||||
- name: Build Linux binary
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PRETTY="${{ inputs.app_name }}"
|
||||
SAFE="$(echo "$PRETTY" | sed -E 's/[^A-Za-z0-9._-]/_/g')"
|
||||
|
||||
pyinstaller --onefile --name "$SAFE" "${{ inputs.main_py_file }}"
|
||||
|
||||
if [ ! -f "dist/$SAFE" ]; then
|
||||
echo "Expected dist/$SAFE not found"
|
||||
echo "dist/ contains:"
|
||||
ls -la dist || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p out
|
||||
cp "dist/$SAFE" "out/$SAFE"
|
||||
chmod +x "out/$SAFE"
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: app-${{ runner.os }}
|
||||
path: out/
|
||||
|
||||
release:
|
||||
name: Create Release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
path: downloaded
|
||||
|
||||
- name: Prepare release assets
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p release_assets
|
||||
cp downloaded/* release_assets/ || true
|
||||
|
||||
echo "Release assets:"
|
||||
ls -la release_assets
|
||||
|
||||
- name: Generate SHA256SUMS.txt
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd release_assets
|
||||
if [ "$(ls -A .)" = "" ]; then
|
||||
echo "No assets found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sha256sum * | LC_ALL=C sort > SHA256SUMS.txt
|
||||
echo "SHA256SUMS.txt:"
|
||||
cat SHA256SUMS.txt
|
||||
|
||||
- name: Delete existing release (optional)
|
||||
if: ${{ inputs.overwrite_release == 'true' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${{ inputs.tag_name }}"
|
||||
|
||||
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
||||
gh release delete "$TAG" --repo "$GITHUB_REPOSITORY" --yes --cleanup-tag
|
||||
fi
|
||||
|
||||
- name: Create release and upload assets
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
TAG="${{ inputs.tag_name }}"
|
||||
TITLE_INPUT="${{ inputs.release_name }}"
|
||||
DRAFT="${{ inputs.draft }}"
|
||||
PRERELEASE="${{ inputs.prerelease }}"
|
||||
|
||||
if [ -n "$TITLE_INPUT" ]; then
|
||||
TITLE="$TITLE_INPUT"
|
||||
else
|
||||
TITLE="Release $TAG"
|
||||
fi
|
||||
|
||||
FLAGS=()
|
||||
[ "$DRAFT" = "true" ] && FLAGS+=(--draft)
|
||||
[ "$PRERELEASE" = "true" ] && FLAGS+=(--prerelease)
|
||||
|
||||
gh release create "$TAG" release_assets/* \
|
||||
--repo "$GITHUB_REPOSITORY" \
|
||||
--title "$TITLE" \
|
||||
--notes "" \
|
||||
"${FLAGS[@]}"
|
||||
build_and_release:
|
||||
uses: ./.github/workflows/reusable-build-release.yml
|
||||
with:
|
||||
tag_name: ${{ inputs.tag_name }}
|
||||
release_name: ${{ inputs.release_name }}
|
||||
overwrite_release: ${{ inputs.overwrite_release }}
|
||||
draft: ${{ inputs.draft }}
|
||||
prerelease: ${{ inputs.prerelease }}
|
||||
app_name: ${{ inputs.app_name }}
|
||||
main_py_file: ${{ inputs.main_py_file }}
|
||||
requirements_file: ${{ inputs.requirements_file }}
|
||||
python_version: ${{ inputs.python_version }}
|
||||
secrets: inherit
|
||||
|
||||
Reference in New Issue
Block a user