Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .build/icon-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .build/nuitka.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nuitka --standalone --onefile --output-dir=./dist --output-filename=ddns --remove-output --include-module=dns.dnspod --include-module=dns.alidns --include-module=dns.dnspod_com --include-module=dns.dnscom --include-module=dns.cloudflare --include-module=dns.he --include-module=dns.huaweidns --include-module=dns.callback --macos-app-name="DDNS" --product-name=DDNS --file-description="DDNS Client 自动更新域名解析到本机IP" --company-name="New Future" --copyright="https://ddns.newfuture.cc" --windows-icon-from-ico="favicon.ico" --linux-icon=".build/icon.png" --macos-app-icon=".build/icon.png" --assume-yes-for-downloads run.py
50 changes: 49 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,55 @@ jobs:
# Upload build result
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-py${{ matrix.python-version }}
name: PyInstaller-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/
retention-days: 7

nuitka:
strategy:
# fail-fast: false
matrix:
os: [windows-latest, windows-11-arm, ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install nuitka

# Prepare build version and cert
- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash

- name: setup on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt install -y patchelf ccache
cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem

- name: setup on macOS
if: runner.os == 'macOS'
run: |
python3 -m pip install imageio


- run: python ./run.py -h

- name: Package binary
run: ./.build/nuitka.cmd

- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h

# Upload build result
- uses: actions/upload-artifact@v4
with:
name: ddns-${{ runner.os }}-${{ runner.arch }}
path: dist/
retention-days: 7

Expand Down
31 changes: 22 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,44 @@ jobs:

build-binary:
strategy:
# fail-fast: false
matrix:
os: [macos, ubuntu, windows]
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 8
os: [windows-latest, windows-11-arm, ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: pip install pyinstaller
run: pip install nuitka

- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: Copy cert on ubuntu

- name: setup on Linux
if: runner.os == 'Linux'
run: cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem
run: |
apt-get update && apt install -y patchelf ccache
cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem

- name: setup on macOS
if: runner.os == 'macOS'
run: |
python3 -m pip install imageio

- name: Package binary
run: ./.build/nuitka.cmd

- run: python -O -m PyInstaller --noconfirm --clean .build/ddns.spec
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h

- run: mv ./dist/ddns ./dist/ddns-osx
if: runner.os == 'macOS'
- name: Move and rename binary with lowercase OS and arch
run: mv ./dist/ddns "./dist/ddns-$(echo ${{ runner.os }}-${{ runner.arch }} | tr '[:upper:]' '[:lower:]')"
shell: bash

- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}
Expand Down
Binary file added favicon.ico
Binary file not shown.
12 changes: 9 additions & 3 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
@author: New Future
@modified: rufengsuixing
"""
# nuitka-project-if: {OS} == "Linux":
# nuitka-project: --static-libpython=yes
# nuitka-project-if: os.getenv("BUILD_VERSION") is not None:
# nuitka-project: --product-version=${BUILD_VERSION}
# nuitka-project-else:
# nuitka-project: --product-version=0.0.0

from __future__ import print_function
from time import ctime, asctime
from os import path, environ, name as os_name
Expand Down Expand Up @@ -46,7 +53,7 @@ def get_ip(ip_type, index="default"):
debug(f"get_ip({ip_type}, {index})")
if index is False: # disabled
return False
elif type(index) is list: # 如果获取到的规则是列表,则依次判断列表中每一个规则,直到找到一个可以正确获取到的IP
elif isinstance(index, list): # 如果获取到的规则是列表,则依次判断列表中每一个规则,直到找到一个可以正确获取到的IP
for i in index:
value = get_ip(ip_type, i)
if value:
Expand All @@ -66,8 +73,7 @@ def get_ip(ip_type, index="default"):
value = getattr(ip, index + "_v" + ip_type)()
except Exception as e:
error(e)
finally:
return value
return value


def change_dns_record(dns, proxy_list, **kw):
Expand Down
Loading