Build Release Multi-platform #34
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 with PyInstaller | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - 'v*' | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整的 git 历史,确保能获取 commit 信息 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| pip install pyinstaller | |
| - name: Determine version | |
| id: version | |
| run: | | |
| # 获取版本号:优先使用 tag,其次使用 release tag,最后默认为 dev | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| elif [[ "${{ github.event_name }}" == "release" ]]; then | |
| VERSION=${{ github.event.release.tag_name }} | |
| else | |
| VERSION="dev-${GITHUB_SHA:0:7}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "构建版本: $VERSION" | |
| - name: Build with PyInstaller | |
| run: | | |
| chmod +x build.sh | |
| ./build.sh ${{ steps.version.outputs.version }} | |
| - name: Upload artifact | |
| if: github.event_name != 'release' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tricode-${{ steps.version.outputs.version }} | |
| path: dist/ | |
| - name: Upload to release | |
| if: github.event_name == 'release' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ github.event.release.tag_name }} dist/* --clobber |