mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
new workflow config
This commit is contained in:
parent
359d53bc74
commit
3365b5e59b
2 changed files with 129 additions and 130 deletions
189
.github/workflows/update_db.yml
vendored
189
.github/workflows/update_db.yml
vendored
|
|
@ -1,107 +1,106 @@
|
|||
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: CI
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the "main" branch
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
# Triggers the workflow on push or pull request events but only for the "main" branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.13'
|
||||
# Set git to use CRLF line endings
|
||||
- name: Configure git CRLF
|
||||
run: |
|
||||
git config --global core.autocrlf true
|
||||
|
||||
# Clone Detect-It-Easy repository
|
||||
- name: Clone Detect-It-Easy
|
||||
run: |
|
||||
git clone https://github.com/horsicq/Detect-It-Easy DIE
|
||||
|
||||
# Create zip archives
|
||||
- name: Create zip archives
|
||||
run: |
|
||||
cd DIE
|
||||
zip -r ../db.zip db
|
||||
zip -r ../db_extra.zip db_extra
|
||||
cd ..
|
||||
ls -la *.zip # Verify the zip files were created
|
||||
# Calculate MD5 checksums
|
||||
- name: Calculate MD5 checksums
|
||||
id: md5
|
||||
run: |
|
||||
DB_MD5=$(md5sum db.zip | awk '{print $1}')
|
||||
DB_EXTRA_MD5=$(md5sum db_extra.zip | awk '{print $1}')
|
||||
echo "DB_MD5=$DB_MD5" >> $GITHUB_OUTPUT
|
||||
echo "DB_EXTRA_MD5=$DB_EXTRA_MD5" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate DB Stats
|
||||
run: |
|
||||
cd DIE
|
||||
cd scripts
|
||||
python --version
|
||||
python db.py '../db' > '../../db_stat.txt'
|
||||
python db.py '../db_extra' > '../../db_extra_stat.txt'
|
||||
|
||||
# Get the current date for the update message
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.13"
|
||||
# Set git to use CRLF line endings
|
||||
- name: Configure git CRLF
|
||||
run: |
|
||||
git config --global core.autocrlf true
|
||||
|
||||
# Read database stats
|
||||
- name: Read database stats
|
||||
id: dbstats
|
||||
run: |
|
||||
DB_STATS=$(cat db_stat.txt)
|
||||
DB_EXTRA_STATS=$(cat db_extra_stat.txt)
|
||||
echo "DB_STATS<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$DB_STATS" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
echo "DB_EXTRA_STATS<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$DB_EXTRA_STATS" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
# Update the "Current database" pre-release
|
||||
- name: Update Database Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
db.zip
|
||||
db_extra.zip
|
||||
name: "Current database"
|
||||
tag_name: current-database
|
||||
body: |
|
||||
- db.zip: `${{ steps.md5.outputs.DB_MD5 }}`
|
||||
- db_extra.zip: `${{ steps.md5.outputs.DB_EXTRA_MD5 }}`
|
||||
|
||||
Last updated: ${{ steps.date.outputs.DATE }}
|
||||
|
||||
This pre-release contains the latest database files from Detect-It-Easy:
|
||||
- db.zip: Contains main database files
|
||||
|
||||
${{ steps.dbstats.outputs.DB_STATS }}
|
||||
|
||||
- db_extra.zip: Contains extra database files
|
||||
|
||||
${{ steps.dbstats.outputs.DB_EXTRA_STATS }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
# Clone Detect-It-Easy repository
|
||||
- name: Clone Detect-It-Easy
|
||||
run: |
|
||||
git clone https://github.com/horsicq/Detect-It-Easy DIE
|
||||
|
||||
# Create zip archives
|
||||
- name: Create zip archives
|
||||
run: |
|
||||
cd DIE
|
||||
zip -r ../db.zip db
|
||||
zip -r ../db_extra.zip db_extra
|
||||
cd ..
|
||||
ls -la *.zip # Verify the zip files were created
|
||||
# Calculate MD5 checksums
|
||||
- name: Calculate MD5 checksums
|
||||
id: md5
|
||||
run: |
|
||||
DB_MD5=$(md5sum db.zip | awk '{print $1}')
|
||||
DB_EXTRA_MD5=$(md5sum db_extra.zip | awk '{print $1}')
|
||||
echo "DB_MD5=$DB_MD5" >> $GITHUB_OUTPUT
|
||||
echo "DB_EXTRA_MD5=$DB_EXTRA_MD5" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate DB Stats
|
||||
run: |
|
||||
cd DIE
|
||||
cd autotools/dbupdater
|
||||
python --version
|
||||
python task.py '../db' > '../../db_stat.txt'
|
||||
python task.py '../db_extra' > '../../db_extra_stat.txt'
|
||||
|
||||
# Get the current date for the update message
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
|
||||
|
||||
# Read database stats
|
||||
- name: Read database stats
|
||||
id: dbstats
|
||||
run: |
|
||||
DB_STATS=$(cat db_stat.txt)
|
||||
DB_EXTRA_STATS=$(cat db_extra_stat.txt)
|
||||
echo "DB_STATS<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$DB_STATS" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
echo "DB_EXTRA_STATS<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$DB_EXTRA_STATS" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
# Update the "Current database" pre-release
|
||||
- name: Update Database Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
db.zip
|
||||
db_extra.zip
|
||||
name: "Current database"
|
||||
tag_name: current-database
|
||||
body: |
|
||||
- db.zip: `${{ steps.md5.outputs.DB_MD5 }}`
|
||||
- db_extra.zip: `${{ steps.md5.outputs.DB_EXTRA_MD5 }}`
|
||||
|
||||
Last updated: ${{ steps.date.outputs.DATE }}
|
||||
|
||||
This pre-release contains the latest database files from Detect-It-Easy:
|
||||
- db.zip: Contains main database files
|
||||
|
||||
${{ steps.dbstats.outputs.DB_STATS }}
|
||||
|
||||
- db_extra.zip: Contains extra database files
|
||||
|
||||
${{ steps.dbstats.outputs.DB_EXTRA_STATS }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
def count_signatures(base_path='../db'):
|
||||
# Verify base path exists
|
||||
if not os.path.exists(base_path):
|
||||
print(f"Error: Base path '{base_path}' does not exist.")
|
||||
return
|
||||
|
||||
# Dictionary to hold subfolder and signature count
|
||||
signature_count = {}
|
||||
|
||||
# Walk through each directory and count .sg files
|
||||
for root, dirs, files in os.walk(base_path):
|
||||
# Get relative subfolder path
|
||||
relative_path = os.path.relpath(root, base_path)
|
||||
|
||||
# Skip the root path itself
|
||||
if relative_path == "." or ".vscode" in relative_path:
|
||||
continue
|
||||
|
||||
# Count .sg files in the current directory
|
||||
count = sum(1 for file in files if file.endswith('.sg'))
|
||||
signature_count[relative_path] = count
|
||||
|
||||
# Generate Markdown table
|
||||
for subfolder, count in signature_count.items():
|
||||
print(f"{subfolder} : {count}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get base path from command-line argument or use default
|
||||
base_path = sys.argv[1] if len(sys.argv) > 1 else '../db'
|
||||
count_signatures(base_path)
|
||||
import os
|
||||
import sys
|
||||
|
||||
def count_signatures(base_path='../db'):
|
||||
# Verify base path exists
|
||||
if not os.path.exists(base_path):
|
||||
print(f"Error: Base path '{base_path}' does not exist.")
|
||||
return
|
||||
|
||||
# Dictionary to hold subfolder and signature count
|
||||
signature_count = {}
|
||||
|
||||
# Walk through each directory and count .sg files
|
||||
for root, dirs, files in os.walk(base_path):
|
||||
# Get relative subfolder path
|
||||
relative_path = os.path.relpath(root, base_path)
|
||||
|
||||
# Skip the root path itself
|
||||
if relative_path == "." or ".vscode" in relative_path:
|
||||
continue
|
||||
|
||||
# Count .sg files in the current directory
|
||||
count = sum(1 for file in files if file.endswith('.sg'))
|
||||
signature_count[relative_path] = count
|
||||
|
||||
# Generate Markdown table
|
||||
for subfolder, count in signature_count.items():
|
||||
print(f"{subfolder} : {count}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get base path from command-line argument or use default
|
||||
base_path = sys.argv[1] if len(sys.argv) > 1 else '../db'
|
||||
count_signatures(base_path)
|
||||
Loading…
Add table
Add a link
Reference in a new issue