Skip to content

feat(text_translator): 更新翻译器列表并优化翻译功能 #3

feat(text_translator): 更新翻译器列表并优化翻译功能

feat(text_translator): 更新翻译器列表并优化翻译功能 #3

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
asset-suffix: windows
- os: ubuntu-latest
asset-suffix: linux
- os: macos-latest
asset-suffix: macos
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller
- name: Install UPX (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install upx -y
echo "UPX_PATH=C:\ProgramData\chocolatey\bin" >> $env:GITHUB_ENV
# - name: Install UPX (Linux) (not used)
# if: runner.os == 'Linux'
# run: |
# sudo apt-get update
# sudo apt-get install -y upx
# - name: Install UPX (macOS) (not used)
# if: runner.os == 'macOS'
# run: |
# brew install upx
- name: Build executable with PyInstaller
run: |
pyinstaller --name TingJu --onedir --icon "${{ github.workspace }}/static/img/icon.ico" --distpath ./dist --workpath ./build --specpath ./spec app.py
- name: Copy extra directories
shell: bash
run: |
cp -r static templates dist/TingJu
- name: Make binary executable (Unix)
if: runner.os != 'Windows'
run: chmod +x dist/TingJu
- name: Create zip archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path dist/TingJu/* -DestinationPath TingJu-${{ github.ref_name }}-${{ matrix.asset-suffix }}.zip
- name: Create zip archive (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cd dist/TingJu
zip -r -9 "../../TingJu-${{ github.ref_name }}-${{ matrix.asset-suffix }}.zip" .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: TingJu-${{ github.ref_name }}-${{ matrix.asset-suffix }}
path: TingJu-${{ github.ref_name }}-${{ matrix.asset-suffix }}.zip
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Generate release notes
run: |
TEMPLATE=$(< .github/release_template.md)
NOTES="${TEMPLATE//\$\{\{ VERSION \}\}/${{ github.ref_name }}}"
echo "$NOTES" > RELEASE.md
- name: Create release and upload assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body_path: RELEASE.md
draft: false
prerelease: false
files: |
artifacts/*/*.zip