diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 4a3a404..ef5a8b4 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -2,7 +2,7 @@ name: Build and Release on: push: tags: - - 'v*' + #- 'v*' jobs: build-and-release: @@ -23,6 +23,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-depth: 0 - name: Set up Python 3.11 uses: actions/setup-python@v5 @@ -61,6 +62,15 @@ jobs: } # pyinstaller --onefile $script --uac-admin + $icoName = $script -replace '\.py$', '.ico' + + if (Test-Path -Path $icoName) { + pyinstaller --onefile $script --uac-admin --icon $icoName + } else { + pyinstaller --onefile $script --uac-admin + } + # pyinstaller --onefile $script --uac-admin + $exeName = $script -replace '\.py$', '' Move-Item "dist\$exeName.exe" "dist\$exeName-Windows-x64.exe" } @@ -81,6 +91,7 @@ jobs: with: name: ${{ matrix.platform }}-executables path: cnNetTool-${{ matrix.platform }}-x64.zip + path: cnNetTool-${{ matrix.platform }}-x64.zip create-release: needs: build-and-release @@ -92,6 +103,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-depth: 0 - name: Download all artifacts uses: actions/download-artifact@v3 @@ -121,8 +133,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check existing release + id: check_release + run: | + if gh release view ${{ github.ref_name }} &> /dev/null; then + echo "release_exists=true" >> $GITHUB_OUTPUT + else + echo "release_exists=false" >> $GITHUB_OUTPUT + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Delete existing release if: steps.check_release.outputs.release_exists == 'true' + run: | + gh release delete ${{ github.ref_name }} --yes + if: steps.check_release.outputs.release_exists == 'true' run: | gh release delete ${{ github.ref_name }} --yes env: @@ -141,5 +167,7 @@ jobs: --draft=false \ **/cnNetTool-Linux-x64.zip \ **/cnNetTool-Windows-x64.zip \ + **/cnNetTool-Linux-x64.zip \ + **/cnNetTool-Windows-x64.zip \ **/cnNetTool-macOS-x64.zip shell: bash \ No newline at end of file diff --git a/setDNS.py b/setDNS.py index 59a9f70..31a426a 100644 --- a/setDNS.py +++ b/setDNS.py @@ -255,6 +255,10 @@ def set_dns_servers(ipv4_dns_list: list[str], ipv6_dns_list: list[str]): if "Connected" in line or "已连接" in line: interface = line.split()[-1] # 更严格地检查并忽略WSL相关的虚拟网卡 + if "WSL" in interface or "Hyper-V" in interface: + logger.info(f"跳过虚拟网卡: {interface}") + continue + # 更严格地检查并忽略WSL相关的虚拟网卡 if "WSL" in interface or "Hyper-V" in interface: logger.info(f"跳过虚拟网卡: {interface}") continue @@ -544,11 +548,13 @@ def main(): set_dns_servers(recommended_dns["ipv4"], recommended_dns["ipv6"]) logger.info("DNS服务器已更新") input("\n任务执行完毕,按任意键退出!") + input("\n任务执行完毕,按任意键退出!") else: logger.info("操作已取消") else: logger.warning("未找到合适的DNS服务器") input("\n任务执行失败,按任意键退出!") + input("\n任务执行失败,按任意键退出!") def is_admin() -> bool: