name: Build and Release permissions: contents: write on: push: tags: - 'v*' jobs: build: name: Build on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies run: | pip install -r requirements.txt pip install pyinstaller - name: Build executable shell: bash run: | echo "Runner OS: ${{ runner.os }}" # 设置系统名和扩展名 if [[ "${{ runner.os }}" == "Windows" ]]; then SYSNAME=windows EXT=.exe elif [[ "${{ runner.os }}" == "Linux" ]]; then SYSNAME=linux EXT= else SYSNAME=macos EXT= fi # 用 PyInstaller 打包 pyinstaller --onefile rsync-tui.py # 获取 tag 名 TAG_NAME=${GITHUB_REF##*/} # 重命名可执行文件 mv dist/rsync-tui${EXT} dist/rsync-tui-${SYSNAME}-${TAG_NAME}${EXT} ls -l dist - name: Upload build artifact uses: actions/upload-artifact@v4 with: name: rsync-tui-${{ runner.os }} path: dist/rsync-tui-* release: runs-on: ubuntu-latest needs: build steps: - name: Download all artifacts uses: actions/download-artifact@v4 with: path: dist - name: Prepare files for release shell: bash run: | mkdir -p dist-root for d in dist/*; do cp "$d"/* dist-root/ done ls -l dist-root - name: Create Release uses: softprops/action-gh-release@v2 with: files: dist-root/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}