更新 BestDnsUpdater.py:增加域名 #16
Workflow file for this run
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
name: Build and Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build-and-release: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
platform: Linux | |
- os: windows-latest | |
platform: Windows | |
- os: macos-latest | |
platform: macOS | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 确保检出完整的Git历史 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- name: Build executables (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
for script in BestDnsUpdater.py BestHostsUpdater-IPv4.py BestHostsUpdater.py; do | |
pyinstaller --onefile "$script" | |
mv "dist/${script%.py}" "dist/${script%.py}-Linux-x64" | |
done | |
zip -j "cnNetTool-Linux-x64.zip" dist/*-Linux-x64 | |
- name: Build executables (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$scripts = @("BestDnsUpdater.py", "BestHostsUpdater-IPv4.py", "BestHostsUpdater.py") | |
if (Test-Path -Path "dist") { | |
Remove-Item -Recurse -Force "dist" | |
} | |
foreach ($script in $scripts) { | |
pyinstaller --onefile $script --uac-admin | |
$exeName = $script -replace '\.py$', '' | |
Move-Item "dist\$exeName.exe" "dist\$exeName-Windows-x64.exe" | |
} | |
Compress-Archive -Path dist\*-Windows-x64.exe -DestinationPath "cnNetTool-Windows-x64.zip" | |
shell: pwsh | |
- name: Build executables (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
for script in BestDnsUpdater.py BestHostsUpdater-IPv4.py BestHostsUpdater.py; do | |
pyinstaller --onefile "$script" | |
mv "dist/${script%.py}" "dist/${script%.py}-macOS-x64" | |
done | |
zip -j "cnNetTool-macOS-x64.zip" dist/*-macOS-x64 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.platform }}-executables | |
path: | | |
cnNetTool-Linux-x64.zip | |
cnNetTool-Windows-x64.zip | |
cnNetTool-macOS-x64.zip | |
create-release: | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 确保检出完整的Git历史 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
- name: Get tag description | |
id: tag_description | |
run: | | |
TAG_DESCRIPTION=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) | |
echo "tag_description=${TAG_DESCRIPTION}" >> $GITHUB_ENV | |
- name: Get latest commit message | |
id: commit_message | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "commit_message=${COMMIT_MESSAGE}" >> $GITHUB_ENV | |
- name: Delete existing release | |
uses: dev-drprasad/[email protected] | |
with: | |
tag_name: ${{ github.ref_name }} | |
delete_release: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: "${{ github.ref_name }} ${{ env.tag_description }}" | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
**/cnNetTool-Linux-x64.zip | |
**/cnNetTool-Windows-x64.zip | |
**/cnNetTool-macOS-x64.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |