修复Linux相关代码 #22
Workflow file for this run
This file contains hidden or 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*" | |
release: | |
types: [created] | |
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 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -U pyinstaller | |
- name: Build executables (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
pyinstaller GitProxySwitch.spec | |
mv "dist/GitProxySwitch" "dist/GitProxySwitch-Linux-x64" | |
zip -j "GitProxySwitch-Linux-x64.zip" dist/*-Linux-x64 | |
- name: Build executables (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
if (Test-Path -Path "dist") { | |
Remove-Item -Recurse -Force "dist" | |
} | |
pyinstaller GitProxySwitch.spec | |
Move-Item "dist\GitProxySwitch.exe" "dist\GitProxySwitch-Windows-x64.exe" | |
Compress-Archive -Path dist\*-Windows-x64.exe -DestinationPath "GitProxySwitch-Windows-x64.zip" | |
shell: pwsh | |
- name: Build executables (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
pyinstaller GitProxySwitch.spec | |
mv "dist/GitProxySwitch" "dist/GitProxySwitch-macOS-x64" | |
zip -j "GitProxySwitch-macOS-x64.zip" dist/*-macOS-x64 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform }}-executables | |
path: GitProxySwitch-${{ matrix.platform }}-x64.zip | |
create-release: | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Get tag description | |
id: tag_description | |
run: | | |
TAG_DESCRIPTION=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) | |
echo "tag_description=${TAG_DESCRIPTION}" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Get latest commit message | |
id: commit_message | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "commit_message=${COMMIT_MESSAGE}" >> $GITHUB_OUTPUT | |
shell: bash | |
- 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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ github.ref_name }} \ | |
--title "${{ github.ref_name }} ${{ steps.tag_description.outputs.tag_description }}" \ | |
--notes "Release for ${{ github.ref_name }} | |
Changes in this release: | |
${{ steps.commit_message.outputs.commit_message }}" \ | |
--draft=false \ | |
**/GitProxySwitch-Linux-x64.zip \ | |
**/GitProxySwitch-Windows-x64.zip \ | |
**/GitProxySwitch-macOS-x64.zip | |
shell: bash |