Browse Source

add cd.yml

liuyuqi-dellpc 7 months ago
parent
commit
63071ea809
9 changed files with 126 additions and 2 deletions
  1. 47 0
      .github/workflows/cd.yml
  2. 13 0
      .pre-commit-config.yaml
  3. 5 0
      README.md
  4. 1 1
      gui/main.py
  5. 1 1
      main.py
  6. 3 0
      poetry.toml
  7. 21 0
      pyproject.toml
  8. 6 0
      web/app.py
  9. 29 0
      web/apps/extensions/__init__.py

+ 47 - 0
.github/workflows/cd.yml

@@ -0,0 +1,47 @@
+name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+
+on:
+  # release:
+  #   types: [published]
+  workflow_dispatch: ~
+  push:
+    branches: [master]
+    tags: [v*]
+
+jobs:
+  build-n-publish:
+    name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+    runs-on: ubuntu-latest
+    # permissions:
+    #   id-token: write
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.12'
+
+      - name: Install Dependencies
+        run: |
+          python -m pip install --upgrade pip wheel setuptools poetry
+          poetry config virtualenvs.in-project true
+          poetry install
+
+      - name: Build a binary wheel and a source tarball
+        run: |
+          poetry build
+
+      # - name: Publish distribution 📦 to Test PyPI
+      #   uses: pypa/gh-action-pypi-publish@release/v1
+      #   with:
+      #     repository_url: https://test.pypi.org/legacy/
+      #     packages_dir: dist/
+      #     password: ${{ secrets.PYPI_TOKEN }}
+
+      - name: Publish distribution 📦 to PyPI
+        if: startsWith(github.ref, 'refs/tags')
+        uses: pypa/gh-action-pypi-publish@release/v1
+        with:
+          packages_dir: dist/
+          password: ${{ secrets.PYPI_TOKEN }}

+ 13 - 0
.pre-commit-config.yaml

@@ -0,0 +1,13 @@
+repos:
+  - repo: https://github.com/charliermarsh/ruff-pre-commit
+    # Ruff version.
+    rev: 'v0.0.280'
+    hooks:
+      - id: ruff
+        args: [ --fix, --exit-non-zero-on-fix ]
+
+  - repo: https://github.com/psf/black
+    rev: 23.1.0
+    hooks:
+      - id: black
+

+ 5 - 0
README.md

@@ -13,7 +13,12 @@
 2、windows 双击 `scripts/start-set_github_secret.bat`,返回201状态码设置成功
 
 
+
 ## License
 
+Licensed under the [Apache 2.0](LICENSE) © [liuyuqi.gov@msn.cn](https://github.com/jianboy)
+
+
+
 ## Reference
 

+ 1 - 1
gui/main.py

@@ -11,4 +11,4 @@ import os,sys,logging
 
 
 if __name__=='__main__':
-    pass
+    pass

+ 1 - 1
main.py

@@ -25,4 +25,4 @@ if __name__=='__main__':
                 value=i["value"]
                 github_api.set_update_github_secret(key, value)
     else:
-        print(f"account.json not found, current path: {current_run_path}")
+        print(f"account.json not found, current path: {current_run_path}")

+ 3 - 0
poetry.toml

@@ -0,0 +1,3 @@
+[virtualenvs]
+in-project = true
+path = "."

+ 21 - 0
pyproject.toml

@@ -0,0 +1,21 @@
+[tool.poetry]
+name = "set-github-secret"
+version = "0.1.0"
+description = "set github secret"
+authors = ["liuyuqi-dellpc <liuyuqi.gov@msn.cn>"]
+readme = "README.md"
+license = "Apache-2.0"
+exclude = [
+    "tests",
+    "docs",
+]
+[tool.poetry.dependencies]
+python = "^3.11"
+requests = "^2.22.0"
+
+[build-system]
+requires = ["poetry-core"]
+build-backend = "poetry.core.masonry.api"
+
+[tool.poetry.scripts]
+sgs = "set_github_secret.set_github_secret.GithubApi:set_update_github_secret"

+ 6 - 0
web/app.py

@@ -7,6 +7,12 @@
 @Desc    :   enter point
 """
 
+
+from apps import create_app
+
+app = create_app()
+
+
 if __name__=='__main__':
     from dotenv import load_dotenv
     import os

+ 29 - 0
web/apps/extensions/__init__.py

@@ -0,0 +1,29 @@
+from flask import Flask
+from .init_sqlalhemy import db, ma, init_databases
+from .init_upload import init_upload
+from .init_login import init_login_manager
+from .init_mail import init_mail
+from .init_csrf import init_csrf
+from .init_template_directives import init_template_directives
+# from flasgger import Swagger
+# from flask_siwadoc import SiwaDoc
+
+def init_extensions(app: Flask):
+    """初始化flask插件"""
+
+    init_login_manager(app)
+    init_databases(app)
+    init_template_directives(app)
+    init_mail(app)
+    init_upload(app)
+    # init_csrf(app)
+
+    # flask-cache
+    # init_cache(app)
+    init_docs(app=app)
+
+def init_docs(app: Flask):
+    """  """
+    # swagger = Swagger(app)
+    # siwa = SiwaDoc(app)
+    pass