generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5d1b9db
Showing
17 changed files
with
1,553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.py] | ||
indent_size = 4 | ||
|
||
[*.md] | ||
max_line_length = off | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'CI' | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.analysis.typeCheckingMode": "strict" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.4.0] - 2021-09-15 | ||
|
||
### Added | ||
|
||
- 支持检查包是否发布到 PyPI | ||
- 支持检查项目仓库/主页是否可以访问 | ||
|
||
## [0.3.0] - 2021-07-26 | ||
|
||
### Fixed | ||
|
||
- 修改分支名为 publish | ||
|
||
## [0.2.0] - 2020-11-20 | ||
|
||
### Changed | ||
|
||
- 事件判定更严格 | ||
- 支持重开议题事件 | ||
- 检查拉取请求的标签是否为插件 | ||
|
||
### Fixed | ||
|
||
- 拉取请求合并时报错 | ||
- 打开议题触发时,在插件信息中将仓库拥有者误设为插件作者 | ||
|
||
## [0.1.0] - 2020-11-19 | ||
|
||
### Added | ||
|
||
- 最初的版本 | ||
|
||
[Unreleased]: https://github.com/nonebot/nonebot2-publish-bot/compare/v0.4.0...HEAD | ||
|
||
[0.4.0]: https://github.com/nonebot/nonebot2-publish-bot/compare/v0.3.0...v0.4.0 | ||
[0.3.0]: https://github.com/nonebot/nonebot2-publish-bot/compare/v0.2.0...v0.3.0 | ||
[0.2.0]: https://github.com/nonebot/nonebot2-publish-bot/compare/v0.1.0...v0.2.0 | ||
[0.1.0]: https://github.com/nonebot/nonebot2-publish-bot/releases/tag/v0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.9 | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install "PyGithub>=1.55,<2.0" "pydantic>=v1.8.2,<2.0" | ||
|
||
COPY ./main.py /app/ | ||
COPY ./src /app/src | ||
|
||
CMD ["python", "/app/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 hemengyang | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# NoneBot2 Publish Bot | ||
|
||
[NoneBot2](https://github.com/nonebot/nonebot2) 插件/协议/机器人 发布机器人 | ||
|
||
## 主要功能 | ||
|
||
根据 插件/协议/机器人 发布(带 Plugin/Adapter/Bot 标题)议题,自动修改对应文件,并创建拉取请求。 | ||
|
||
## 自动处理 | ||
|
||
- 商店发布议题创建后,自动根据议题内容创建拉取请求 | ||
- 相关议题修改时,自动修改已创建的拉取请求,如果没有创建则重新创建 | ||
- 拉取请求关闭时,自动关闭对应议题,并删除对应分支 | ||
- 已经创建的拉取请求在其他拉取请求合并后,自动解决冲突 | ||
- 自动检查是否符合发布要求 | ||
|
||
### 发布要求 | ||
|
||
- 项目主页能够访问 | ||
- 项目发布至 PyPI | ||
|
||
## 使用方法 | ||
|
||
简单的示例 | ||
|
||
```yaml | ||
name: 'NoneBot2 Publish Bot' | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
issues: | ||
types: [opened, reopened, edited] | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
publish_bot: | ||
runs-on: ubuntu-latest | ||
name: nonebot2 publish bot | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: NoneBot2 Publish Bot | ||
uses: nonebot/nonebot2-publish-bot@main | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
config: > | ||
{ | ||
"base": "master", | ||
"plugin_path": "docs/.vuepress/public/plugins.json", | ||
"bot_path": "docs/.vuepress/public/bots.json", | ||
"adapter_path": "docs/.vuepress/public/adapters.json" | ||
} | ||
``` | ||
## 测试 | ||
在 [action-test](https://github.com/he0119/action-test) 仓库中测试。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'NoneBot2 Publish Bot' | ||
description: 'Manage publish related issues in nonebot2 project' | ||
author: 'hemengyang <[email protected]>' | ||
inputs: | ||
token: | ||
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}' | ||
required: true | ||
config: | ||
description: 'JSON with settings as described in the README' | ||
required: true | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
branding: | ||
icon: 'box' | ||
color: 'orange' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import logging | ||
|
||
from github import Github | ||
|
||
from src.models import Settings | ||
from src.process import ( | ||
process_issues_event, | ||
process_pull_request_event, | ||
process_push_event, | ||
) | ||
|
||
|
||
def main(): | ||
FORMAT = "%(asctime)s - %(levelname)s - %(message)s" | ||
logging.basicConfig(level=logging.INFO, format=FORMAT) | ||
|
||
settings = Settings() | ||
logging.info(f"当前配置: {settings.json()}") | ||
|
||
if not settings.input_token.get_secret_value(): | ||
logging.info("无法获得 Token,跳过此次操作") | ||
return | ||
|
||
g = Github(settings.input_token.get_secret_value()) | ||
repo = g.get_repo(settings.github_repository) | ||
|
||
if not settings.github_event_path.is_file(): | ||
logging.error(f"没有在 {settings.github_event_path} 找到 GitHub 事件文件") | ||
return | ||
|
||
if settings.github_event_name == "push": | ||
process_push_event(settings, repo) | ||
elif settings.github_event_name == "pull_request": | ||
process_pull_request_event(settings, repo) | ||
elif settings.github_event_name == "issues": | ||
process_issues_event(settings, repo) | ||
else: | ||
logging.info(f"不支持的事件: {settings.github_event_name},已跳过") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.