From a2e17f4a9f1b77e89ee91201b7cbca4cdb855f57 Mon Sep 17 00:00:00 2001 From: Xumin Yu <1090414006@qq.com> Date: Fri, 20 Sep 2024 20:14:54 +0800 Subject: [PATCH] Dev update libraries (#19) Co-authored-by: wl-zhao --- .github/workflows/package-and-upload.yaml | 167 ++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 .github/workflows/package-and-upload.yaml diff --git a/.github/workflows/package-and-upload.yaml b/.github/workflows/package-and-upload.yaml new file mode 100644 index 00000000..062e322f --- /dev/null +++ b/.github/workflows/package-and-upload.yaml @@ -0,0 +1,167 @@ + +name: "Release To HF" + +on: + workflow_dispatch: + inputs: + git_tag: + description: 'Git Branch Tag' + required: true + type: string + default: "main" + cu: + description: 'CUDA Version' + required: true + type: string + default: "124" + python_minor: + description: 'Python Minor Version' + required: true + type: string + default: "10" + python_patch: + description: 'Python Patch Version' + required: true + type: string + default: "10" + version: + description: 'Release Version Tag' + required: true + type: string + default: "beta" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + ref: ${{ inputs.git_tag }} + + - uses: pnpm/action-setup@v2 + with: + version: 9 + run_install: false + + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "pnpm" + cache-dependency-path: "web/pnpm-lock.yaml" + + - working-directory: "./web" + run: pnpm install + + - working-directory: "./web" + run: pnpm turbo run build --filter=web + + - uses: actions/upload-artifact@v3 + with: + name: web-build + path: web/apps/web/dist + + package_shellagent_windows: + permissions: + contents: "write" + packages: "write" + pull-requests: "read" + needs: build + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.git_tag }} + fetch-depth: 0 + persist-credentials: false + submodules: recursive + - uses: actions/setup-python@v5 + with: + python-version: 3.${{ inputs.python_minor }}.${{ inputs.python_patch }} + + - name: Download web-build artifact + uses: actions/download-artifact@v3 + with: + name: web-build + path: ./servers/web-build + + - shell: bash + run: | + cd .. + cp -r ShellAgent ShellAgent_copy + + curl -L https://huggingface.co/XuminYu/git_embed/resolve/main/git.7z?download=true -o git.7z + "C:\Program Files\7-Zip\7z.exe" x git.7z -ogit + + curl https://www.python.org/ftp/python/3.${{ inputs.python_minor }}.${{ inputs.python_patch }}/python-3.${{ inputs.python_minor }}.${{ inputs.python_patch }}-embed-amd64.zip -o python_embeded.zip + unzip python_embeded.zip -d python_embeded + + cd python_embeded + + echo 'import site' >> ./python3${{ inputs.python_minor }}._pth + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + ./python.exe get-pip.py + cp -r ../ShellAgent/.ci/python_dependencies_wins/include ./include + cp -r ../ShellAgent/.ci/python_dependencies_wins/Library ./Library + cp -r ../ShellAgent/.ci/python_dependencies_wins/libs ./libs + ./python.exe -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu${{ inputs.cu }} + ./python.exe -s -m pip install --use-pep517 pygit2 Cython scikit_build_core enscons pytoml cmake==3.21 + ./python.exe -s -m pip install --use-pep517 -r ../ShellAgent/requirements.txt + ./python.exe -s -m pip install onnx==1.16.1 flask PyExecJS docx2txt fuzzywuzzy git cloudpickle + sed -i '1i../ShellAgent' ./python3${{ inputs.python_minor }}._pth + + cd .. + + mkdir ShellAgent_windows_portable + mv python_embeded ShellAgent_windows_portable + mv git ShellAgent_windows_portable + mv ShellAgent_copy ShellAgent_windows_portable/ShellAgent + + cd ShellAgent_windows_portable + cp -r ShellAgent/.ci/windows_base_files/* ./ + + cd ShellAgent + + mkdir -p models/insightface/models + ls models/insightface/ + curl -L https://huggingface.co/MonsterMMORPG/tools/resolve/main/antelopev2.zip -o models/insightface/models/antelopev2.zip + ls models/insightface/models/ + unzip models/insightface/models/antelopev2.zip -d models/insightface/models/ + + mkdir -p models/vae_approx + ls models + git clone --depth 1 https://github.com/comfyanonymous/taesd + cp taesd/*.pth models/vae_approx + + ../python_embeded/python.exe -m pip install -e . + ../python_embeded/python.exe -m pip show proconfig + # ../python_embeded/python.exe servers/main.py + + cd .. + cd .. + + "C:\Program Files\7-Zip\7z.exe" a -t7z -m0=lzma2 -mx=8 -mfb=64 -md=32m -ms=on -mf=BCJ2 ShellAgent_windows_portable.7z ShellAgent_windows_portable/* + mv ShellAgent_windows_portable.7z ShellAgent/ShellAgent_windows_portable.7z + + ls + + - name: Install Hugging Face Hub SDK + run: pip install huggingface_hub + + - name: Upload binaries to Hugging Face + run: | + from huggingface_hub import HfApi + api = HfApi() + + # Set repository and file paths + repo_id = "myshell-ai/ShellAgent" + file_path = "ShellAgent_windows_portable.7z" + + # Upload the file to Hugging Face repository + api.upload_file( + path_or_fileobj=file_path, + path_in_repo="ShellAgent_${{ inputs.version }}.7z", + repo_id=repo_id, + repo_type="model", # or 'dataset' depending on your use case + token="${{ secrets.HF_TOKEN }}" + ) + shell: python