Skip to content

优选DNS服务器,自动更新hosts文件 #9

优选DNS服务器,自动更新hosts文件

优选DNS服务器,自动更新hosts文件 #9

Workflow file for this run

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
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
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
- name: Build executables (Windows)
if: matrix.os == 'windows-latest'
run: |
$scripts = @("BestDnsUpdater.py", "BestHostsUpdater-IPv4.py", "BestHostsUpdater.py")
foreach ($script in $scripts) {
pyinstaller --onefile $script
$exeName = $script -replace '\.py$', ''
Move-Item "dist\$exeName.exe" "dist\$exeName-Windows-x64.exe"
}
shell: pwsh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }}-executables
path: dist/*
create-release:
needs: build-and-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Delete existing release
uses: dev-drprasad/delete-tag-and-release@v0.2.1
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 }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
*-executables/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}