mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 16:45:35 +08:00
Merge pull request #318 from zhamao-robot/update-gh-actions
更新 GH Action
This commit is contained in:
71
.github/workflows/build-release-artifacts.yml
vendored
Normal file
71
.github/workflows/build-release-artifacts.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
name: Build Release Artifacts
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-release-artifacts:
|
||||||
|
name: Build Release Artifacts
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.base_ref }}
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: sunxyw/workflows/setup-environment@main
|
||||||
|
with:
|
||||||
|
php-version: 8.0
|
||||||
|
php-extensions: swoole, posix, json
|
||||||
|
operating-system: ubuntu-latest
|
||||||
|
use-cache: true
|
||||||
|
|
||||||
|
- name: Remove Dev Dependencies
|
||||||
|
run: composer install --no-dev
|
||||||
|
|
||||||
|
- name: Build Phar
|
||||||
|
run: ./zhamao build
|
||||||
|
|
||||||
|
- name: Get Latest Release Upload URL
|
||||||
|
id: get-latest-release
|
||||||
|
run: curl https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.upload_url' | sed 's/{?name,label}//g' > upload_url.txt
|
||||||
|
|
||||||
|
- name: Upload Phar
|
||||||
|
run: |
|
||||||
|
curl -X POST \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
$(cat upload_url.txt)/zm.phar \
|
||||||
|
--data-binary "@build/zm.phar"
|
||||||
|
|
||||||
|
update-changelog:
|
||||||
|
name: Update Changelog
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.base_ref }}
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: sunxyw/workflows/setup-environment@main
|
||||||
|
with:
|
||||||
|
php-version: 8.1
|
||||||
|
php-extensions: swoole, posix, json
|
||||||
|
operating-system: ubuntu-latest
|
||||||
|
use-cache: true
|
||||||
|
|
||||||
|
- name: Update Changelog
|
||||||
|
run: ./zhamao generate:text update-log-md
|
||||||
|
|
||||||
|
- name: Commit Changelog
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: update changelog
|
||||||
|
branch: ${{ github.base_ref }}
|
||||||
10
.github/workflows/increment-build-number.yml
vendored
10
.github/workflows/increment-build-number.yml
vendored
@@ -47,6 +47,16 @@ jobs:
|
|||||||
commit_message: update api docs
|
commit_message: update api docs
|
||||||
branch: ${{ github.base_ref }}
|
branch: ${{ github.base_ref }}
|
||||||
|
|
||||||
|
- name: Update Class Aliases Docs
|
||||||
|
run: ./zhamao generate:text class-alias-md
|
||||||
|
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.changed_files, 'src/Globals/global_class_alias.php') }}
|
||||||
|
|
||||||
|
- name: Commit Class Aliases Docs
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: update class aliases docs
|
||||||
|
branch: ${{ github.base_ref }}
|
||||||
|
|
||||||
- name: Increment build number
|
- name: Increment build number
|
||||||
id: increment-build-number
|
id: increment-build-number
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"captainhook/captainhook": "^5.10",
|
"captainhook/captainhook": "^5.10",
|
||||||
|
"captainhook/plugin-composer": "^5.3",
|
||||||
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
|
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
|
||||||
"jangregor/phpstan-prophecy": "^1.0",
|
"jangregor/phpstan-prophecy": "^1.0",
|
||||||
"jetbrains/phpstorm-attributes": "^1.0",
|
"jetbrains/phpstorm-attributes": "^1.0",
|
||||||
@@ -82,7 +83,8 @@
|
|||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
"phpstan/extension-installer": true
|
"phpstan/extension-installer": true,
|
||||||
|
"captainhook/plugin-composer": true
|
||||||
},
|
},
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
@@ -96,7 +98,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-autoload-dump": "vendor/bin/captainhook install -f -s",
|
|
||||||
"analyse": "phpstan analyse --memory-limit 300M",
|
"analyse": "phpstan analyse --memory-limit 300M",
|
||||||
"cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 php-cs-fixer fix",
|
"cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 php-cs-fixer fix",
|
||||||
"test": "bin/phpunit-zm --no-coverage"
|
"test": "bin/phpunit-zm --no-coverage"
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class BuildCommand extends Command
|
|||||||
}
|
}
|
||||||
$target = $build_dir . '/' . $target;
|
$target = $build_dir . '/' . $target;
|
||||||
// 确认 Phar 文件可以写入
|
// 确认 Phar 文件可以写入
|
||||||
|
FileSystem::createDir($build_dir);
|
||||||
FileSystem::ensureFileWritable($target);
|
FileSystem::ensureFileWritable($target);
|
||||||
|
|
||||||
$this->comment("目标文件:{$target}");
|
$this->comment("目标文件:{$target}");
|
||||||
@@ -51,6 +52,8 @@ class BuildCommand extends Command
|
|||||||
unlink($target);
|
unlink($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 增加开发依赖的判定并提醒
|
||||||
|
|
||||||
$this->info('正在构建 Phar 包');
|
$this->info('正在构建 Phar 包');
|
||||||
|
|
||||||
$this->build(
|
$this->build(
|
||||||
|
|||||||
@@ -45,11 +45,29 @@ class TextGenerateCommand extends Command
|
|||||||
$full_maxlen = max($full_maxlen, strlen('`' . $full_class . '`'));
|
$full_maxlen = max($full_maxlen, strlen('`' . $full_class . '`'));
|
||||||
$short_maxlen = max($short_maxlen, strlen('`' . $short_class . '`'));
|
$short_maxlen = max($short_maxlen, strlen('`' . $short_class . '`'));
|
||||||
}
|
}
|
||||||
$this->write('| ' . str_pad('全类名', $full_maxlen) . ' | ' . str_pad('别名', $short_maxlen) . ' |');
|
$obj = <<<'LINE'
|
||||||
$this->write('| ' . str_pad('', $full_maxlen, '-') . ' | ' . str_pad('', $short_maxlen, '-') . ' |');
|
# 类全局别名
|
||||||
foreach ($line as $v) {
|
|
||||||
$this->write('| ' . str_pad('`' . $v[0] . '`', $full_maxlen) . ' | ' . str_pad('`' . $v[1] . '`', $short_maxlen) . ' |');
|
在框架 1.x 和 2.x 老版本中,我们发现许多开发者在使用框架时,往往不会使用 PhpStorm 这类大型 IDE,而即使使用 VSCode 这类编辑器的时候也不一定会安装补全插件,
|
||||||
}
|
这样在编写机器人模块或插件时会因寻找每个对象的完整命名空间而烦恼。
|
||||||
|
|
||||||
|
在 3.0 版本起,框架对常用的注解事件和对象均使用了类别名功能,方便非 IDE 开发者编写插件。
|
||||||
|
|
||||||
|
## 别名使用
|
||||||
|
|
||||||
|
框架对别名的定义比较简单,由于内部暂时没有不同命名空间下重复类名的情况,所以我们目前只对需要别名类名的命名空间移除,例如:
|
||||||
|
|
||||||
|
`\ZM\Annotation\OneBot\BotCommand` 注解事件类,在经过全局别名后,你也可以使用 `\BotCommand` 作为注解事件,效果相同。
|
||||||
|
|
||||||
|
## 别名列表
|
||||||
|
LINE;
|
||||||
|
file_put_contents(
|
||||||
|
SOURCE_ROOT_DIR . '/docs/components/common/class-alias.md',
|
||||||
|
$obj . "\n" . '| ' . str_pad('全类名', $full_maxlen) . ' | ' . str_pad('别名', $short_maxlen) . ' |' .
|
||||||
|
"\n" . '| ' . str_pad('', $full_maxlen, '-') . ' | ' . str_pad('', $short_maxlen, '-') . ' |' .
|
||||||
|
"\n" . implode("\n", array_map(fn ($v) => '| ' . str_pad('`' . $v[0] . '`', $full_maxlen) . ' | ' . str_pad('`' . $v[1] . '`', $short_maxlen) . ' |', $line)) . "\n"
|
||||||
|
);
|
||||||
|
$this->write('成功');
|
||||||
return static::SUCCESS;
|
return static::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user