Some checks failed
技能自动化发布 (测试版-无鉴权) / build-and-deploy (push) Failing after 1m31s
71 lines
2.4 KiB
YAML
71 lines
2.4 KiB
YAML
name: 技能自动化发布 (测试版-无鉴权)
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# 1. 下载源码
|
|
- uses: actions/checkout@v3
|
|
|
|
# 2. 环境及工具准备
|
|
- name: Setup Tools
|
|
run: pip install pyarmor requests python-frontmatter
|
|
|
|
# 3. 【核心步骤】PyArmor 源代码混淆加密
|
|
- name: Encrypt Source Code
|
|
run: |
|
|
mkdir -p dist/package
|
|
# 使用 PyArmor 加密 scripts 目录下的所有 Python 源码
|
|
pyarmor gen -O dist/package scripts/*.py
|
|
# 拷贝说明文档到发包目录
|
|
cp SKILL.md dist/package/
|
|
|
|
# 4. 提取元数据并物理打包
|
|
- name: Parse Metadata and Pack
|
|
id: build_task
|
|
run: |
|
|
python -c "
|
|
import frontmatter, os, json, shutil
|
|
post = frontmatter.load('SKILL.md')
|
|
metadata = post.metadata
|
|
slug = metadata['name']
|
|
version = metadata['version']
|
|
# 设置变量供后续 API 调用使用
|
|
print(f'::set-output name=slug::{slug}')
|
|
print(f'::set-output name=version::{version}')
|
|
print(f'::set-output name=metadata::{json.dumps(metadata)}')
|
|
# 制作最终的发布 ZIP 包
|
|
shutil.make_archive(slug, 'zip', 'dist/package')
|
|
"
|
|
|
|
# 5. 同步数据库记录 (对应接口: /api/skill/update)
|
|
- name: Sync Database (V2.0)
|
|
run: |
|
|
python -c "
|
|
import requests, json
|
|
metadata = json.loads('${{ steps.build_task.outputs.metadata }}')
|
|
# 严谨修正:接口路径为 /api/skill/update
|
|
url = 'https://jc2009.com/api/skill/update'
|
|
res = requests.post(url, json=metadata)
|
|
print(f'DB Sync Result: {res.text}')
|
|
if res.status_code != 200: exit(1)
|
|
"
|
|
|
|
# 6. 上传物理包 (对应接口: /api/upload)
|
|
- name: Upload Encrypted ZIP
|
|
run: |
|
|
SLUG=${{ steps.build_task.outputs.slug }}
|
|
VERSION=${{ steps.build_task.outputs.version }}
|
|
python -c "
|
|
import requests
|
|
url = 'https://jc2009.com/api/upload'
|
|
payload = {'plugin_name': '$SLUG', 'version': '$VERSION'}
|
|
with open(f'$SLUG.zip', 'rb') as f:
|
|
res = requests.post(url, data=payload, files={'file': f})
|
|
print(f'Upload Result: {res.text}')
|
|
if res.status_code != 200: exit(1)
|
|
"
|