Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 157f51c765 | |||
| d54a69cba8 | |||
| 3b6f15ecbb | |||
| cd131697d5 | |||
| 2e3ac2cfe7 | |||
| bea22d5e9e | |||
| 7759e0b376 | |||
| 92a9d61007 | |||
| 16b3f50dac | |||
| 48c6bec254 | |||
| 9e7369a2af |
76
.github/workflows/release_skill.yaml
vendored
76
.github/workflows/release_skill.yaml
vendored
@@ -8,12 +8,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# 1. 下载源码
|
# 1. 下载源码
|
||||||
- uses: actions/checkout@v3
|
- uses: http://120.25.191.12:3000/admin/actions-checkout@v4
|
||||||
|
|
||||||
# 2. 环境及工具准备
|
# 2. 环境及工具准备
|
||||||
- name: Setup Tools
|
- name: Setup Tools
|
||||||
# 修复:添加 --break-system-packages 参数
|
# 优化:使用国内清华源加速安装速度
|
||||||
run: pip install pyarmor requests python-frontmatter --break-system-packages
|
run: pip install pyarmor requests python-frontmatter --break-system-packages -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# 3. 【核心步骤】PyArmor 源代码混淆加密
|
# 3. 【核心步骤】PyArmor 源代码混淆加密
|
||||||
- name: Encrypt Source Code
|
- name: Encrypt Source Code
|
||||||
@@ -30,42 +30,82 @@ jobs:
|
|||||||
import frontmatter, os, json, shutil
|
import frontmatter, os, json, shutil
|
||||||
post = frontmatter.load('SKILL.md')
|
post = frontmatter.load('SKILL.md')
|
||||||
metadata = post.metadata
|
metadata = post.metadata
|
||||||
slug = metadata['name']
|
|
||||||
version = metadata['version']
|
# slug 优先从 openclaw.slug 读取,兼容历史用 name
|
||||||
# 修复:使用新的 $GITHUB_OUTPUT 方式设置变量,兼容性更好
|
openclaw_meta = metadata.get('metadata', {}).get('openclaw', {})
|
||||||
|
slug = (openclaw_meta.get('slug') or metadata.get('slug') or metadata.get('name') or '').strip()
|
||||||
|
if not slug:
|
||||||
|
raise Exception('SKILL.md 缺少 slug/name,无法构建发布包')
|
||||||
|
|
||||||
|
# 以 Git Tag 为准(自动模式)
|
||||||
|
ref_name = (os.environ.get('GITHUB_REF_NAME') or '').strip()
|
||||||
|
if not ref_name:
|
||||||
|
ref_name = (os.environ.get('GITHUB_REF') or '').strip().split('/')[-1]
|
||||||
|
if not ref_name.startswith('v'):
|
||||||
|
raise Exception(f'非法标签: {ref_name},要求以 v 开头,例如 v1.0.10')
|
||||||
|
|
||||||
|
version = ref_name.lstrip('v')
|
||||||
|
|
||||||
|
# 自动模式:SKILL.md 与 tag 不一致时仅告警,不阻塞发布
|
||||||
|
skill_version = str(metadata.get('version') or '').strip()
|
||||||
|
if skill_version and skill_version != version:
|
||||||
|
print(f'WARNING: SKILL.md version({skill_version}) != tag version({version}), using tag version')
|
||||||
|
|
||||||
|
# 统一覆盖,确保后续输出与上传完全一致
|
||||||
|
metadata['version'] = version
|
||||||
|
|
||||||
|
# 安全写入输出
|
||||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
||||||
f.write(f'slug={slug}\n')
|
f.write(f'slug={slug}\n')
|
||||||
f.write(f'version={version}\n')
|
f.write(f'version={version}\n')
|
||||||
f.write(f'metadata={json.dumps(metadata)}\n')
|
f.write(f'metadata={json.dumps(metadata, ensure_ascii=False)}\n')
|
||||||
|
|
||||||
# 制作最终的发布 ZIP 包
|
# 制作最终的发布 ZIP 包
|
||||||
shutil.make_archive(slug, 'zip', 'dist/package')
|
shutil.make_archive(slug, 'zip', 'dist/package')
|
||||||
"
|
"
|
||||||
|
|
||||||
# 5. 同步数据库记录
|
# 5. 同步数据库记录
|
||||||
- name: Sync Database (V2.0)
|
- name: Sync Database (V2.0)
|
||||||
|
env:
|
||||||
|
METADATA_JSON: ${{ steps.build_task.outputs.metadata }}
|
||||||
run: |
|
run: |
|
||||||
python -c "
|
python -c "
|
||||||
import requests, json, os
|
import requests, json, os
|
||||||
# 修复:从环境变量读取 metadata
|
metadata = json.loads(os.environ['METADATA_JSON'])
|
||||||
metadata = json.loads('''${{ steps.build_task.outputs.metadata }}''')
|
|
||||||
url = 'https://jc2009.com/api/skill/update'
|
url = 'https://jc2009.com/api/skill/update'
|
||||||
res = requests.post(url, json=metadata)
|
res = requests.post(url, json=metadata)
|
||||||
print(f'DB Sync Result: {res.text}')
|
print(f'DB Sync Result: {res.text}')
|
||||||
if res.status_code != 200: exit(1)
|
if res.status_code != 200:
|
||||||
|
exit(1)
|
||||||
|
try:
|
||||||
|
payload = res.json()
|
||||||
|
except Exception:
|
||||||
|
exit(1)
|
||||||
|
if payload.get('code') != 200:
|
||||||
|
exit(1)
|
||||||
"
|
"
|
||||||
|
|
||||||
# 6. 上传物理包
|
# 6. 上传物理包
|
||||||
- name: Upload Encrypted ZIP
|
- name: Upload Encrypted ZIP
|
||||||
|
env:
|
||||||
|
SLUG: ${{ steps.build_task.outputs.slug }}
|
||||||
|
VERSION: ${{ steps.build_task.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
SLUG=${{ steps.build_task.outputs.slug }}
|
|
||||||
VERSION=${{ steps.build_task.outputs.version }}
|
|
||||||
python -c "
|
python -c "
|
||||||
import requests
|
import requests, os
|
||||||
url = 'https://jc2009.com/api/upload'
|
url = 'https://jc2009.com/api/upload'
|
||||||
payload = {'plugin_name': '$SLUG', 'version': '$VERSION'}
|
slug = os.environ['SLUG']
|
||||||
with open(f'$SLUG.zip', 'rb') as f:
|
version = os.environ['VERSION']
|
||||||
|
payload = {'plugin_name': slug, 'version': version, 'artifact_type': 'skill'}
|
||||||
|
with open(f'{slug}.zip', 'rb') as f:
|
||||||
res = requests.post(url, data=payload, files={'file': f})
|
res = requests.post(url, data=payload, files={'file': f})
|
||||||
print(f'Upload Result: {res.text}')
|
print(f'Upload Result: {res.text}')
|
||||||
if res.status_code != 200: exit(1)
|
if res.status_code != 200:
|
||||||
"
|
exit(1)
|
||||||
|
try:
|
||||||
|
payload = res.json()
|
||||||
|
except Exception:
|
||||||
|
exit(1)
|
||||||
|
if payload.get('code') != 200:
|
||||||
|
exit(1)
|
||||||
|
"
|
||||||
39
SKILL.md
39
SKILL.md
@@ -1,16 +1,21 @@
|
|||||||
---
|
---
|
||||||
name: account-manager
|
name: 账号管理
|
||||||
description: 多平台多账号管理。管理各平台账号与Chrome Profile的对应关系,供publisher类Skill调用获取账号信息。
|
description: 多平台多账号管理。管理各平台账号与Chrome Profile的对应关系,供publisher类Skill调用获取账号信息。
|
||||||
version: 1.0.1
|
version: 1.0.1
|
||||||
author: 深圳匠厂科技有限公司
|
author: 深圳匠厂科技有限公司
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
|
slug: account-manager
|
||||||
emoji: "👤"
|
emoji: "👤"
|
||||||
|
category: "通用"
|
||||||
|
skill_type: 1
|
||||||
|
monthly_price: 0
|
||||||
|
yearly_price: 0
|
||||||
allowed-tools:
|
allowed-tools:
|
||||||
- bash
|
- bash
|
||||||
---
|
---
|
||||||
|
|
||||||
# 账号管理器
|
# 账号管理
|
||||||
|
|
||||||
## 使用时机
|
## 使用时机
|
||||||
|
|
||||||
@@ -23,32 +28,4 @@ allowed-tools:
|
|||||||
|
|
||||||
### 列出某平台所有账号
|
### 列出某平台所有账号
|
||||||
```bash
|
```bash
|
||||||
python3 {baseDir}/scripts/account.py list <platform>
|
python3 {baseDir}/scripts/account.py list <platform>
|
||||||
```
|
|
||||||
|
|
||||||
### 获取某个账号详情
|
|
||||||
```bash
|
|
||||||
python3 {baseDir}/scripts/account.py get <account_id>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 初始化账号登录(首次使用,打开浏览器手动登录)
|
|
||||||
```bash
|
|
||||||
python3 {baseDir}/scripts/account.py login <account_id>
|
|
||||||
```
|
|
||||||
|
|
||||||
## 输出格式
|
|
||||||
|
|
||||||
- list:逐行返回账号ID和名称
|
|
||||||
- get:返回账号完整信息
|
|
||||||
- login:打开浏览器后提示用户手动完成登录
|
|
||||||
|
|
||||||
## 错误处理
|
|
||||||
|
|
||||||
- 账号不存在:提示"未找到该账号,请检查账号ID是否正确"
|
|
||||||
- 平台无账号:提示"该平台暂无账号,请先在accounts.json中添加"
|
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
- 账号档案存储在 `accounts.json`,新增账号需手动编辑该文件
|
|
||||||
- Chrome Profile目录首次登录后自动创建,登录态永久保存
|
|
||||||
- 每个账号只需初始化登录一次
|
|
||||||
216
release.ps1
Normal file
216
release.ps1
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
One-command release script for skill repos.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
- Optional auto-commit
|
||||||
|
- Push current branch
|
||||||
|
- Auto-increment semantic tag (vX.Y.Z)
|
||||||
|
- Create & push tag
|
||||||
|
- Fail fast on unsafe states
|
||||||
|
|
||||||
|
.EXAMPLES
|
||||||
|
# Safe mode (recommended): requires clean working tree
|
||||||
|
.\release.ps1
|
||||||
|
|
||||||
|
# Auto commit tracked/untracked changes then release
|
||||||
|
.\release.ps1 -AutoCommit -CommitMessage "chore: update skill config"
|
||||||
|
|
||||||
|
# Dry run (show what would happen)
|
||||||
|
.\release.ps1 -DryRun
|
||||||
|
|
||||||
|
# Custom tag prefix
|
||||||
|
.\release.ps1 -Prefix "v" -Message "正式发布"
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Requires: git, PowerShell 5+
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[string]$Prefix = "v",
|
||||||
|
[string]$Message = "正式发布",
|
||||||
|
[switch]$AutoCommit,
|
||||||
|
[switch]$RequireClean,
|
||||||
|
[string]$CommitMessage,
|
||||||
|
[switch]$DryRun
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
function Invoke-Git {
|
||||||
|
param([Parameter(Mandatory = $true)][string]$Args)
|
||||||
|
Write-Host ">> git $Args" -ForegroundColor DarkGray
|
||||||
|
& cmd /c "git $Args"
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "git command failed: git $Args"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Get-GitOutput {
|
||||||
|
param([Parameter(Mandatory = $true)][string]$Args)
|
||||||
|
$output = & cmd /c "git $Args" 2>$null
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "git command failed: git $Args"
|
||||||
|
}
|
||||||
|
return @($output)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-Repo {
|
||||||
|
& git rev-parse --is-inside-work-tree *> $null
|
||||||
|
return ($LASTEXITCODE -eq 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-CurrentBranch {
|
||||||
|
$b = (Get-GitOutput "branch --show-current" | Select-Object -First 1).Trim()
|
||||||
|
return $b
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Get-StatusPorcelain {
|
||||||
|
$lines = @(Get-GitOutput "status --porcelain")
|
||||||
|
return $lines
|
||||||
|
}
|
||||||
|
|
||||||
|
function Parse-SemVerTag {
|
||||||
|
param(
|
||||||
|
[string]$Tag,
|
||||||
|
[string]$TagPrefix
|
||||||
|
)
|
||||||
|
$escaped = [regex]::Escape($TagPrefix)
|
||||||
|
$m = [regex]::Match($Tag, "^${escaped}(\d+)\.(\d+)\.(\d+)$")
|
||||||
|
if (-not $m.Success) { return $null }
|
||||||
|
|
||||||
|
return [pscustomobject]@{
|
||||||
|
Raw = $Tag
|
||||||
|
Major = [int]$m.Groups[1].Value
|
||||||
|
Minor = [int]$m.Groups[2].Value
|
||||||
|
Patch = [int]$m.Groups[3].Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-NextTag {
|
||||||
|
param([string]$TagPrefix)
|
||||||
|
|
||||||
|
$tags = Get-GitOutput "tag --list"
|
||||||
|
$parsed = @()
|
||||||
|
|
||||||
|
foreach ($t in $tags) {
|
||||||
|
$t = $t.Trim()
|
||||||
|
if (-not $t) { continue }
|
||||||
|
$obj = Parse-SemVerTag -Tag $t -TagPrefix $TagPrefix
|
||||||
|
if ($null -ne $obj) { $parsed += $obj }
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($parsed.Count -eq 0) {
|
||||||
|
return "${TagPrefix}1.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
$latest = $parsed | Sort-Object Major, Minor, Patch | Select-Object -Last 1
|
||||||
|
return "$TagPrefix$($latest.Major).$($latest.Minor).$([int]$latest.Patch + 1)"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Ensure-CleanOrAutoCommit {
|
||||||
|
param(
|
||||||
|
[switch]$DoAutoCommit,
|
||||||
|
[switch]$NeedClean,
|
||||||
|
[switch]$IsDryRun,
|
||||||
|
[string]$Msg
|
||||||
|
)
|
||||||
|
|
||||||
|
$status = @(Get-StatusPorcelain)
|
||||||
|
if ($status.Length -eq 0) { return }
|
||||||
|
|
||||||
|
if ($NeedClean) {
|
||||||
|
Write-Host "Working tree is not clean and -RequireClean is enabled." -ForegroundColor Yellow
|
||||||
|
& git status --short
|
||||||
|
throw "Abort: dirty working tree."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 默认一键发布:有改动就自动提交;也可用 -AutoCommit 显式开启
|
||||||
|
$commitMsg = $Msg
|
||||||
|
if ([string]::IsNullOrWhiteSpace($commitMsg)) {
|
||||||
|
$commitMsg = "chore: auto release commit ($(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'))"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $DoAutoCommit) {
|
||||||
|
Write-Host "Detected uncommitted changes, auto-committing before release..." -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($IsDryRun) {
|
||||||
|
Write-Host "[DryRun] Would run: git add -A" -ForegroundColor Yellow
|
||||||
|
Write-Host "[DryRun] Would run: git commit -m `"$commitMsg`"" -ForegroundColor Yellow
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Git "add -A"
|
||||||
|
Invoke-Git "commit -m `"$commitMsg`""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Write-Host "=== Release Script Start ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
if (-not (Test-Repo)) {
|
||||||
|
throw "Current directory is not a git repository."
|
||||||
|
}
|
||||||
|
|
||||||
|
$branch = Get-CurrentBranch
|
||||||
|
if ([string]::IsNullOrWhiteSpace($branch)) {
|
||||||
|
throw "Unable to determine current branch."
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($branch -notin @("main", "master")) {
|
||||||
|
throw "Current branch is '$branch'. Release is only allowed from main/master."
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Git "fetch --tags --prune origin"
|
||||||
|
|
||||||
|
Ensure-CleanOrAutoCommit -DoAutoCommit:$AutoCommit -NeedClean:$RequireClean -IsDryRun:$DryRun -Msg $CommitMessage
|
||||||
|
|
||||||
|
$upstream = (& git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>$null)
|
||||||
|
$hasUpstream = ($LASTEXITCODE -eq 0)
|
||||||
|
|
||||||
|
if ($DryRun) {
|
||||||
|
if ($hasUpstream) {
|
||||||
|
Write-Host "[DryRun] Would run: git push" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host "[DryRun] Would run: git push -u origin $branch" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($hasUpstream) {
|
||||||
|
Invoke-Git "push"
|
||||||
|
} else {
|
||||||
|
Invoke-Git "push -u origin $branch"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextTag = Get-NextTag -TagPrefix $Prefix
|
||||||
|
Write-Host "Next tag: $nextTag" -ForegroundColor Green
|
||||||
|
|
||||||
|
$existing = @(Get-GitOutput "tag --list `"$nextTag`"")
|
||||||
|
if ($existing.Length -gt 0) {
|
||||||
|
throw "Tag already exists: $nextTag"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($DryRun) {
|
||||||
|
Write-Host "[DryRun] Would run: git tag -a $nextTag -m `"$Message`"" -ForegroundColor Yellow
|
||||||
|
Write-Host "[DryRun] Would run: git push origin $nextTag" -ForegroundColor Yellow
|
||||||
|
Write-Host "=== DryRun Complete ===" -ForegroundColor Cyan
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Git "tag -a $nextTag -m `"$Message`""
|
||||||
|
Invoke-Git "push origin $nextTag"
|
||||||
|
|
||||||
|
Write-Host "Release success: $nextTag" -ForegroundColor Green
|
||||||
|
Write-Host "=== Release Script Done ===" -ForegroundColor Cyan
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "Release failed: $($_.Exception.Message)" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user