Renew Projects

This commit is contained in:
e2hang
2025-12-31 13:22:56 +08:00
parent 4b60ced553
commit d143bbc65c
1753 changed files with 841 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
name: Close Specific PR
on:
pull_request_target:
types: [opened, ]
# Note: If you use both the branches filter and the paths filter, the workflow will only run when both filters are satisfied.
branches:
- master
paths:
- 'usage/workflow_download.py'
jobs:
close_specific_pr:
env:
comment: |
To prevent beginners from mistakenly submitting PRs,
if your PR only modifies the usage/workflow_download.py file,
it will be automatically closed.
If you really want to submit a PR, please reopen it yourself.
Make sure you know what you are doing!
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Close PR
run: |
PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH)
echo "PR_TITLE: $PR_TITLE"
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body '${{ env.comment }}'
gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,70 @@
name: 下载JM本子 (commit)
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/download.yml' # 工作流定义
- 'usage/workflow_download.py' # 下载脚本
- 'assets/option/option_workflow_download.yml' # 配置文件
jobs:
crawler:
runs-on: ubuntu-latest
env:
# 登录相关secrets
JM_USERNAME: ${{ secrets.JM_USERNAME }}
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
# 邮件相关secrets
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TITLE: ${{ secrets.EMAIL_TITLE }}
EMAIL_CONTENT: ${{ secrets.EMAIL_CONTENT }}
# 固定值
JM_DOWNLOAD_DIR: /home/runner/work/jmcomic/download/
ZIP_NAME: '本子.tar.gz'
UPLOAD_NAME: 'Click me to download'
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependency
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: 安装jmcomicpip
if: ${{ github.ref != 'refs/heads/dev' }}
run: |
pip install jmcomic -i https://pypi.org/project --upgrade
- name: 安装jmcomiclocal
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
pip install -e ./
- name: 运行下载脚本
run: |
cd ./usage/
python workflow_download.py
- name: 压缩文件
run: |
cd $JM_DOWNLOAD_DIR
tar -zcvf "../$ZIP_NAME" ./
mv "../$ZIP_NAME" .
- name: 上传结果
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_NAME }}
path: ${{ env.JM_DOWNLOAD_DIR }}/${{ env.ZIP_NAME }}
if-no-files-found: warn
retention-days: 90

View File

@@ -0,0 +1,125 @@
name: 下载JM本子 (dispatch)
on:
workflow_dispatch:
inputs:
JM_ALBUM_IDS:
type: string
description: 本子id多个id用-隔开,如 '123-456-789'
required: false
JM_PHOTO_IDS:
type: string
description: 章节id单独下载章节多个id同上
required: false
CLIENT_IMPL:
type: string
description: 客户端类型client.impl下载失败时你可以尝试填入此项重试。'api' 表示移动端,'html' 表示网页端。
default: ''
required: false
IMAGE_SUFFIX:
type: string
description: 图片后缀download.cache.suffix默认为空表示不做图片格式转换。可填入例如 'png' 'jpg'
default: ''
required: false
DIR_RULE:
type: string
description: 下载文件夹规则dir_rule.rule。默认使用配置文件的 'Bd_Aauthor_Atitle_Pindex'。
default: ''
required: false
ZIP_NAME:
type: string
default: 本子.tar.gz
description: 压缩文件名称
required: false
UPLOAD_NAME:
type: string
default: Click me to download
description: 上传文件名称
required: false
# JM_USERNAME:
# type: string
# default: ''
# description: '禁漫帐号不建议使用用户名和密码会泄露在日志中。最好用secrets'
# required: false
#
# JM_PASSWORD:
# type: string
# default: ''
# description: '禁漫密码不建议使用用户名和密码会泄露在日志中。最好用secrets'
# required: false
jobs:
crawler:
runs-on: ubuntu-latest
env:
# 工作流输入
JM_ALBUM_IDS: ${{ github.event.inputs.JM_ALBUM_IDS }}
JM_PHOTO_IDS: ${{ github.event.inputs.JM_PHOTO_IDS }}
DIR_RULE: ${{ github.event.inputs.DIR_RULE }}
CLIENT_IMPL: ${{ github.event.inputs.CLIENT_IMPL }}
ZIP_NAME: ${{ github.event.inputs.ZIP_NAME }}
UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }}
IMAGE_SUFFIX: ${{ github.event.inputs.IMAGE_SUFFIX }}
# 登录相关secrets
JM_USERNAME: ${{ secrets.JM_USERNAME }}
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
# 邮件相关secrets
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TITLE: ${{ secrets.EMAIL_TITLE }}
EMAIL_CONTENT: ${{ secrets.EMAIL_CONTENT }}
# 固定值
JM_DOWNLOAD_DIR: /home/runner/work/jmcomic/download/
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependency
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: 安装jmcomicpip
if: ${{ github.ref != 'refs/heads/dev' }}
run: |
pip install jmcomic -i https://pypi.org/project --upgrade
- name: 安装jmcomiclocal
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
pip install -e ./
- name: 运行下载脚本
run: |
cd ./usage/
python workflow_download.py
- name: 压缩文件
run: |
cd $JM_DOWNLOAD_DIR
tar -zcvf "../$ZIP_NAME" ./
mv "../$ZIP_NAME" .
- name: 上传结果
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_NAME }}
path: ${{ env.JM_DOWNLOAD_DIR }}/${{ env.ZIP_NAME }}
if-no-files-found: error
retention-days: 90

View File

@@ -0,0 +1,79 @@
name: 导出收藏夹数据
on:
# schedule:
# - cron: "0 0 * * *"
workflow_dispatch:
inputs:
IN_JM_USERNAME:
type: string
default: ''
description: '禁漫帐号不建议使用会泄露在日志中。最好用secrets'
required: false
IN_JM_PASSWORD:
type: string
default: ''
description: '禁漫密码不建议使用会泄露在日志中。最好用secrets'
required: false
IN_ZIP_PASSWORD:
type: string
default: ''
description: '压缩文件密码不建议使用会泄露在日志中。最好用secrets'
required: false
jobs:
crawler:
runs-on: ubuntu-latest
env:
# 工作流输入
IN_JM_USERNAME: ${{ github.event.inputs.IN_JM_USERNAME }}
IN_JM_PASSWORD: ${{ github.event.inputs.IN_JM_PASSWORD }}
IN_ZIP_PASSWORD: ${{ github.event.inputs.IN_ZIP_PASSWORD }}
# 登录相关secrets
JM_USERNAME: ${{ secrets.JM_USERNAME }}
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
ZIP_PASSWORD: ${{ secrets.ZIP_PASSWORD }}
# 邮件相关secrets
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TITLE: ${{ secrets.EMAIL_TITLE }}
EMAIL_CONTENT: ${{ secrets.EMAIL_CONTENT }}
# 固定值
ZIP_FP: /home/runner/work/jmcomic/download/export.7z
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependency
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
sudo apt update
sudo apt install p7zip-full
- name: 安装jmcomiclocal
run: |
pip install -e ./
- name: 执行代码
run: |
cd ./usage/
python workflow_export_favorites.py
- name: 上传结果
uses: actions/upload-artifact@v4
with:
name: '导出的收藏夹'
path: ${{ env.ZIP_FP }}
if-no-files-found: error
retention-days: 90

View File

@@ -0,0 +1,29 @@
# publish when new release
name: Publish If Release
on:
workflow_dispatch:
release:
types: [ published ]
jobs:
release:
name: Publish `jmcomic` to PYPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build
run: |
python -m pip install build
python -m build
- name: Publish PYPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_JMCOMIC }}

View File

@@ -0,0 +1,44 @@
# auto release and publish
name: Auto Release & Publish
on:
workflow_dispatch:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'v')
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Parse Tag & Body
id: tb
run: |
commit_message=$(git log --format=%B -n 1 ${{ github.sha }})
python .github/release.py "$commit_message"
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tb.outputs.tag }}
body_path: release_body.txt
- name: Build
run: |
python -m pip install build
python -m build
- name: Release PYPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_JMCOMIC }}

View File

@@ -0,0 +1,48 @@
name: Run Test (API)
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches: [ "dev" ]
paths:
- 'src/**/*.py'
- 'tests/**/*.py'
- '.github/workflows/test_api.yml'
- 'assets/option/option_test_api.yml'
jobs:
test: # This code is based on https://github.com/gaogaotiantian/viztracer/blob/master/.github/workflows/python-package.yml
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.13']
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
env:
# 配置文件路径
JM_OPTION_PATH_TEST: ./assets/option/option_test_api.yml
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Install local
run: |
pip install -e ./
- name: Run Test
run: |
cd ./tests/
python -m unittest

View File

@@ -0,0 +1,48 @@
name: Run Test (HTML)
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches: [ "dev" ]
paths:
- 'src/**/*.py'
- 'tests/**/*.py'
- '.github/workflows/test_html.yml'
- 'assets/option/option_test_html.yml'
jobs:
test: # This code is based on https://github.com/gaogaotiantian/viztracer/blob/master/.github/workflows/python-package.yml
strategy:
matrix:
python-version: ['3.7', '3.8', '3.11', '3.12']
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
env:
# 配置文件路径
JM_OPTION_PATH_TEST: ./assets/option/option_test_html.yml
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Install local
run: |
pip install -e ./
- name: Run Test
run: |
cd ./tests/
python -m unittest