build-linux #6
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-linux | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| include_release: | |
| description: '是否生成 GitHub Release(需要先创建对应标签)' | |
| required: false | |
| default: 'false' | |
| tag_name: | |
| description: '手动触发时要发布的标签名(例如 v1.2.3),需已存在' | |
| required: false | |
| default: '' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-dev python3-tk build-essential libasound2-dev libudev-dev libevdev-dev patchelf | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Build executable | |
| run: | | |
| pyinstaller pyinstaller.spec --noconfirm --clean --distpath dist --workpath build | |
| - name: Package artifact | |
| run: | | |
| tar -czf lexisharp-linux.tar.gz -C dist lexisharp | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lexisharp-linux | |
| path: | | |
| lexisharp-linux.tar.gz | |
| if-no-files-found: error | |
| - name: 发布 GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.include_release == 'true' && (github.event.inputs.tag_name || '') != '') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.tag_name || github.ref_name }} | |
| release_name: LexiSharp-linux ${{ github.event.inputs.tag_name || github.ref_name }} | |
| generate_release_notes: true | |
| files: lexisharp-linux.tar.gz | |
| fail_on_unmatched_files: true | |
| prerelease: ${{ contains(github.event.inputs.tag_name || github.ref_name, '-rc') || contains(github.event.inputs.tag_name || github.ref_name, '-beta') || contains(github.event.inputs.tag_name || github.ref_name, '-alpha') }} |