Skip to content

Commit d7a3f1c

Browse files
committed
feat(build): add macos intel build
1 parent fede87c commit d7a3f1c

File tree

3 files changed

+65
-9
lines changed

3 files changed

+65
-9
lines changed

.github/workflows/release.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,24 @@ jobs:
6666
- name: Install Build Dependencies
6767
run: |
6868
python -m pip install pyinstaller --user
69-
- name: Build Windows
70-
id: windows_build
71-
if: ${{ matrix.os == 'windows-latest' }}
69+
- name: Build
70+
id: build
7271
run: |
73-
python scripts/createmsi.py
74-
echo "##[set-output name=msi;]$(ls *.msi)"
75-
- name: Upload MSI
76-
if: ${{ matrix.os == 'windows-latest' }}
72+
if [ "$RUNNER_OS" == "Windows" ]; then
73+
python scripts/createmsi.py
74+
echo "build=$(ls *.msi)" >> $GITHUB_OUTPUT
75+
elif [ "$RUNNER_OS" == "macOS" ]; then
76+
export PATH=$PATH:/Users/runner/.local/bin
77+
python scripts/create_macos_package.py
78+
echo "build=$(ls *.pkg)" >> $GITHUB_OUTPUT
79+
else
80+
echo "$RUNNER_OS not supported"
81+
exit 1
82+
fi
83+
shell: bash
84+
- name: Upload
7785
uses: softprops/action-gh-release@v2
7886
with:
79-
files: ${{ steps.windows_build.outputs.msi }}
87+
files: ${{ steps.build.outputs.build }}
8088

8189

activity-browser.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ if platform.system() == "Darwin":
8080
target,
8181
name="Activity Browser.app",
8282
icon="activity_browser/static/icons/activity-browser.icns",
83-
bundle_identifier=None,
83+
bundle_identifier="com.github.lca_activity_browser.activity_browser",
8484
version=os.environ.get("VERSION", "0.0.0"),
8585
info_plist={
8686
"NSPrincipalClass": "NSApplication",

scripts/create_macos_package.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import platform
2+
import shutil
3+
import subprocess
4+
import sys
5+
6+
7+
def build_app():
8+
pyinstaller = shutil.which("pyinstaller")
9+
if not pyinstaller:
10+
print("ERROR: This script requires pyinstaller.")
11+
sys.exit(1)
12+
13+
pyinst_cmd = [
14+
pyinstaller,
15+
"activity-browser.spec",
16+
"--clean",
17+
"-y"
18+
]
19+
subprocess.check_call(pyinst_cmd)
20+
21+
22+
def build_macos_package(application_path='dist/Activity Browser.app', package_path='./Activity Browser-{}.pkg',
23+
sign_identity: str=None):
24+
macos_architecture = 'intel' if platform.processor() == 'i386' else 'arm'
25+
build_cmd = [
26+
'pkgbuild',
27+
'--component',
28+
application_path,
29+
"--install-location",
30+
'/Applications',
31+
package_path.format(macos_architecture)
32+
]
33+
if sign_identity:
34+
build_cmd = build_cmd[0] + ['--sign', sign_identity] + build_cmd[1:]
35+
subprocess.check_call(build_cmd)
36+
37+
38+
if __name__ == "__main__":
39+
import argparse
40+
41+
if not shutil.which("pyinstaller"):
42+
subprocess.check_call(["pip", "install", "--upgrade", "pyinstaller"])
43+
44+
parser = argparse.ArgumentParser()
45+
parser.add_argument("--sign-identity", help="signing identity")
46+
options = parser.parse_args()
47+
build_app()
48+
build_macos_package(sign_identity=options.sign_identity)

0 commit comments

Comments
 (0)