Skip to content

Commit

Permalink
cicd: switch to universal macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
dynobo committed Nov 15, 2024
1 parent e8f33a1 commit 3842484
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, windows-2022, ubuntu-22.04]
os: [macos-14, windows-2022, ubuntu-22.04]
steps:
# Setup environment
- uses: actions/checkout@v4
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
echo "QT_QPA_PLATFORM=xcb" >> $GITHUB_ENV
- name: Prepare macOS
if: matrix.os == 'macos-13' || matrix.os == 'macos-14'
if: matrix.os == 'macos-14'
run: |
brew install tesseract tesseract-lang dylibbundler
brew info tesseract
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, windows-2022, ubuntu-22.04]
os: [macos-14, windows-2022, ubuntu-22.04]
steps:
- uses: actions/checkout@v4

Expand All @@ -134,7 +134,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, windows-2022, ubuntu-22.04]
os: [macos-14, windows-2022, ubuntu-22.04]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, windows-2022, ubuntu-22.04]
os: [macos-14, windows-2022, ubuntu-22.04]
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Changelog

## v0.6.0 (upcoming)

- macOS: Switch to universal build instead of separate x86 and M1 builds.

## v0.5.9 (2024-11-10)

- All: Add Chinese translation. Thanks, [@mofazhe](https://github.com/mofazhe)! ([#661](https://github.com/dynobo/normcap/pull/661))
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ Note: You have to allow the unsigned application on first start: "System Prefere
"Security & Privacy" → "General" → "Open anyway". You also have to allow NormCap to take
screenshots. ([#135](https://github.com/dynobo/normcap/issues/135))

- [NormCap-0.5.9-x86_64-macOS.dmg](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-x86_64-macOS.dmg)
(Installer for x86/64)
- [NormCap-0.5.9-arm64-macOS.dmg](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-arm64-macOS.dmg)
(Installer for M1)
- [NormCap-0.5.9-universal-macOS.dmg](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-universal-macOS.dmg)
(Installer for x86/64 and M1)

## Install Python package

Expand Down
7 changes: 2 additions & 5 deletions bundle/platforms/macos_briefcase.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Run adjustments while packaging with briefcase during CI/CD."""

import platform
import shutil
from pathlib import Path

Expand All @@ -14,9 +13,7 @@ class MacBriefcase(BuilderBase):

binary_suffix = ""
binary_extension = "dmg"
binary_platform = (
"arm64-macOS" if platform.machine().startswith("arm64") else "x86_64-macOS"
)
binary_platform = "universal-macOS"

@staticmethod
def _get_path_to_tesseract() -> Path:
Expand All @@ -30,7 +27,7 @@ def _patch_info_plist_for_proper_fullscreen(self) -> None:
See details:
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/20001431-113616
"""
# TODO: Replace by briefcase config
# TODO: Remove if config is applied correctly
file_path = Path("macOS/app/NormCap/NormCap.app/Contents") / "Info.plist"
patch = """
<key>LSUIPresentationMode</key>
Expand Down
2 changes: 1 addition & 1 deletion bundle/platforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_version(self) -> str:

with Path(self.PYPROJECT_PATH).open(encoding="utf8") as toml_file:
pyproject_toml = toml.load(toml_file)
return pyproject_toml["tool"]["briefcase"]["version"]
return pyproject_toml["project"]["version"]

@staticmethod
def run(cmd: Union[str, list], cwd: Optional[Path] = None) -> Optional[str]:
Expand Down
6 changes: 2 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ Packages with the
<small>Portable, x86_64, ~120 MB</small>
- [Download for **Linux**](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-x86_64.AppImage)
<small>x86_64, ~90 MB</small>
- [Download for **macOS**](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-x86_64-macOS.dmg)
<small>x86_64, ~80 MB</small>
- [Download for **macOS (M1)**](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-arm64-macOS.dmg)
<small>arm64, ~65 MB</small>
- [Download for **macOS**](https://github.com/dynobo/normcap/releases/download/v0.5.9/NormCap-0.5.9-universal-macOS.dmg)
<small>Universal, ~80 MB</small>
</div>

... or install via
Expand Down
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ version = "0.5.9"
description = "OCR-powered screen-capture tool to capture information instead of images."
keywords = ["screenshot", "ocr", "capture", "clipboard"]
readme = "README.md"
requires-python = ">=3.9,<=3.12"
license = "GPL-3.0-or-later"
requires-python = ">=3.9"
license.file = "LICENSE"
authors = [{ name = "dynobo", email = "[email protected]" }]
classifiers = [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -113,7 +113,7 @@ check = [
format = [
{ cmd = "ruff check --fix-only" },
{ cmd = "ruff format" },
{ ref = "locales-compile"},
{ ref = "locales-compile" },
{ cmd = "mdformat --align-semantic-breaks-in-lists --end-of-line keep" },
]
chart = [
Expand Down Expand Up @@ -309,14 +309,11 @@ cleanup_paths = [
[tool.briefcase.app.normcap.macOS.Xcode]
requires = ["std-nslog==1.0.0"]
universal_build = true
# TODO: Configure Entitlements.plist ? For screenshot and notify permissions?
# TODO: Info.plist?
# TODO: Remove build for x64 (not needed anymore). Also from docs.

info."LSUIPresentationMode" = 3

[tool.briefcase.app.normcap.linux.appimage]
template = "https://github.com/beeware/briefcase-linux-appimage-template"
template_branch = "v0.3.16"
template_branch = "v0.3.20"
manylinux = "manylinux_2_28"
manylinux_image_tag = "latest"
system_requires = [
Expand Down Expand Up @@ -358,13 +355,11 @@ RUN cd wl-clipboard \
&& ninja \
&& meson install
ENV LD_LIBRARY_PATH "$LD_LIBRARY_PATH:/app/NormCap.AppDir/usr/app_packages/shiboken6"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/NormCap.AppDir/usr/app_packages/shiboken6"
USER brutus
"""

# TODO: Use briefcase --Xdocker-build for docker build args (if applicable)

[tool.briefcase.app.normcap.windows]
use_full_install_path = false

Expand Down
4 changes: 2 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def test_version():
with Path("pyproject.toml").open(encoding="utf8") as toml_file:
pyproject_toml = toml.load(toml_file)

briefcase_version = pyproject_toml["tool"]["briefcase"]["version"]
pyproject_version = pyproject_toml["project"]["version"]
normcap_version = normcap.__version__
assert normcap_version.startswith(briefcase_version)
assert normcap_version.startswith(pyproject_version)


def test_get_args(monkeypatch):
Expand Down
Loading

0 comments on commit 3842484

Please sign in to comment.