Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: ffsubsync build

on:
release:
types: [published]

jobs:
build-binaries:
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:

- os: ubuntu-latest
os-name: "linux"
python-version: "3.11"
arch: "x86_64"
build-deps: "pyinstaller"

- os: ubuntu-latest
os-name: "linux"
python-version: "3.11"
arch: "arm64"
build-deps: "pyinstaller"

- os: macos-latest
os-name: "macos"
python-version: "3.11"
arch: "x86_64"
build-deps: "pyinstaller"

- os: macos-latest
os-name: "macos"
python-version: "3.11"
arch: "arm64"
build-deps: "pyinstaller"

- os: windows-latest
os-name: "windows"
python-version: "3.11"
arch: "x86_64"
build-deps: "pyinstaller setuptools wheel webrtcvad"

steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Install UPX (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y upx-ucl

- name: Install UPX (macOS)
if: runner.os == 'macOS'
run: brew install upx

- name: Install UPX (Windows)
if: runner.os == 'Windows'
run: choco install upx

- name: Prepare build requirements
run: echo "${{ matrix.build-deps }}" | tr ' ' '\n' > requirements-build.txt

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements.txt
requirements-build.txt

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-build.txt

- name: Build executable with PyInstaller
run: |
echo 'FFSUBSYNC_VERSION = "${{ github.event.release.tag_name }}"' > ffsubsync/__version.py
pyinstaller --onefile --name ffsubsync ffsubsync/ffsubsync.py

- name: Smoke test
run: ./dist/ffsubsync --version || ./dist/ffsubsync.exe --version

- name: Package binary
shell: bash
run: |
cd dist
if [[ "${{ runner.os }}" == "Windows" ]]; then
powershell Compress-Archive -Path ffsubsync.exe -DestinationPath "${{ matrix.os-name }}-${{ matrix.arch }}.zip"
else
tar -czf "${{ matrix.os-name }}-${{ matrix.arch }}.tar.gz" ffsubsync
fi

- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ./dist/${{ matrix.os-name }}-${{ matrix.arch }}.*
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ffsubsync
name: ffsubsync test

on: [push, pull_request]

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ dist
__version__
.venv/
.coverage

# Generated by PyInstaller
ffsubsync.spec
2 changes: 1 addition & 1 deletion ffsubsync/ffsubsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def add_cli_only_args(parser: argparse.ArgumentParser) -> None:
"--version",
action="version",
version="{package} {version}".format(
package=__package__, version=get_version()
package=__package__ or "ffsubsync", version=get_version()
),
)
parser.add_argument(
Expand Down
6 changes: 6 additions & 0 deletions ffsubsync/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

def get_version():
if "unknown" in __version__.lower():
try:
from ffsubsync.__version import FFSUBSYNC_VERSION
return FFSUBSYNC_VERSION
except ImportError:
pass

with open(
os.path.join(os.environ[SUBSYNC_RESOURCES_ENV_MAGIC], "__version__")
) as f:
Expand Down