Workflow config file is invalid. Please check your config file: yaml: line 6: did not find expected alphabetic or numeric character
wood chen 93a01d21cf chore(workflow): ignore md files in release workflow
update README for FFmpeg built-in and Python version requirement
2024-11-16 10:04:43 +08:00

161 lines
5.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build and Release
on:
push:
branches: [main]
paths-ignore: [**.md]
workflow_dispatch:
permissions:
contents: write # 添加这个权限声明
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Generate version number
id: version
run: |
SHA_SHORT=$(git rev-parse --short HEAD)
echo "version=1.0.0-${SHA_SHORT}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.version }}
name: Release v${{ steps.version.outputs.version }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
build-windows:
needs: create-release
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Download FFmpeg
run: |
mkdir ffmpeg
curl -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip -o ffmpeg.zip
7z x ffmpeg.zip -offmpeg
move ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe ffmpeg\
move ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe ffmpeg\
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller
shell: cmd
run: |
pyinstaller --name video2gif --onefile --windowed --add-data "ffmpeg/ffmpeg.exe;ffmpeg" --add-data "ffmpeg/ffprobe.exe;ffmpeg" --add-data "README.md;." --clean --noconfirm --log-level=INFO gui.py
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: ./dist/video2gif.exe
build-macos:
needs: create-release
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Download FFmpeg
run: |
mkdir ffmpeg
curl -L https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4/darwin-x64 -o ffmpeg/ffmpeg
curl -L https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4/darwin-x64 -o ffmpeg/ffprobe
chmod +x ffmpeg/ffmpeg ffmpeg/ffprobe
# 或者使用 Homebrew备选方案
- name: Install FFmpeg using Homebrew
if: failure()
run: |
brew install ffmpeg
mkdir -p ffmpeg
cp $(which ffmpeg) ffmpeg/
cp $(which ffprobe) ffmpeg/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
# 创建启动器脚本
- name: Create launcher script
run: |
echo 'import os, sys; os.environ["PATH"] = os.path.join(os.path.dirname(sys.executable), "ffmpeg") + os.pathsep + os.environ["PATH"]' > launcher.py
cat gui.py >> launcher.py
- name: Build with PyInstaller
run: |
pyinstaller --name video2gif --onefile --windowed --add-data "ffmpeg/ffmpeg:ffmpeg" --add-data "ffmpeg/ffprobe:ffmpeg" --add-data "README.md:." launcher.py
- name: Create DMG
run: |
cd dist
mkdir -p video2gif.app/Contents/MacOS
mkdir -p video2gif.app/Contents/Resources/ffmpeg
mv video2gif video2gif.app/Contents/MacOS/
cp ../ffmpeg/* video2gif.app/Contents/Resources/ffmpeg/
# 创建 Info.plist
cat > video2gif.app/Contents/Info.plist << EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>video2gif</string>
<key>CFBundleIdentifier</key>
<string>com.example.video2gif</string>
<key>CFBundleName</key>
<string>Video2Gif</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.10</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOL
# 创建 DMG
hdiutil create -volname "Video2Gif" -srcfolder video2gif.app -ov -format UDZO video2gif.dmg
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: ./dist/video2gif.dmg