Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify stub handling to allow for console and GUI stubs #54

Merged
merged 5 commits into from
Jun 5, 2024
Merged
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
40 changes: 17 additions & 23 deletions .github/workflows/update-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ jobs:
# Generate the stub app
cd stub
briefcase build macOS Xcode
# Since it's a generic stub binary, we can't provide any meaningful
# signing credentials in the Xcode project. Remove the signature from
# the stub binary.
codesign --remove-signature ./build/stub/macos/xcode/build/Release/Stub.app/Contents/MacOS/Stub
echo "Move the binary into the final location"
mv ./build/stub/macos/xcode/build/Release/Stub.app/Contents/MacOS/Stub Stub-${{ env.PYTHON_TAG }}
# Since the project is producing generic stub binary, we can't provide
# any meaningful signing credentials in the Xcode project. Remove the
# signature from the stub binaries.
codesign --remove-signature "./build/console-stub/macos/xcode/build/Release/Console Stub.app/Contents/MacOS/Console Stub"
codesign --remove-signature "./build/gui-stub/macos/xcode/build/Release/GUI Stub.app/Contents/MacOS/GUI Stub"
echo "Move the binaries into the final location"
mv "./build/console-stub/macos/xcode/build/Release/Console Stub.app/Contents/MacOS/Console Stub" Console-Stub-${{ env.PYTHON_TAG }}
mv "./build/gui-stub/macos/xcode/build/Release/GUI Stub.app/Contents/MacOS/GUI Stub" GUI-Stub-${{ env.PYTHON_TAG }}

- name: Upload Stub Artefact
uses: actions/[email protected]
with:
name: stub-${{ matrix.python-version }}
path: stub/Stub-${{ env.PYTHON_TAG }}
path: stub/*-Stub-${{ env.PYTHON_TAG }}

commit-stubs:
name: Commit stub binaries
Expand All @@ -75,23 +77,15 @@ jobs:
export BRIEFCASE_VERSION="${TAG%-*}"
export BUILD_NUMBER="${TAG#*-}"

echo "TAG=${TAG}"
echo "PYTHON_TAG=${PYTHON_TAG}"
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}"
echo "BUILD_NUMBER=${BUILD_NUMBER}"

echo "TAG=${TAG}" >> $GITHUB_ENV
echo "PYTHON_TAG=${PYTHON_TAG}" >> $GITHUB_ENV
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}" >> $GITHUB_ENV
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
echo "TAG=${TAG}" | tee -a $GITHUB_ENV
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}" | tee -a $GITHUB_ENV
echo "BUILD_NUMBER=${BUILD_NUMBER}" | tee -a $GITHUB_ENV

if [ "${BRIEFCASE_VERSION}" == "dev" ]; then
# We're on the development template; push to main
echo "TEMPLATE_BRANCH=main"
echo "TEMPLATE_BRANCH=main" >> $GITHUB_ENV
echo "TEMPLATE_BRANCH=main" | tee -a $GITHUB_ENV
else
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}"
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}" >> $GITHUB_ENV
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}" | tee -a $GITHUB_ENV
fi

- name: Checkout Template
Expand All @@ -109,12 +103,12 @@ jobs:
git config user.email "[email protected]"
git config user.name "Brutus (robot)"
# Move the binary into it's final location
mv stub/Stub-* "{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS"
mv stub/*-Stub-* "{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS"
# Ensure the binary is executable
cd "{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS"
chmod 755 Stub-*
chmod 755 *-Stub-*
# Commit changes
git add ./Stub-*
git add ./*-Stub-*
git commit -m "AUTO: Update app binaries; build ${{ env.TAG }}"
git push origin HEAD:${{ env.TEMPLATE_BRANCH }}
env:
Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"info": "",
"entitlements": "",
"document_types": "",
"console_app": false,
"version": "1.0.0",
"build": "1",
"bundle": "com.example",
Expand Down
16 changes: 10 additions & 6 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
from pathlib import Path


BIN_PATH = Path("{{ cookiecutter.formal_name }}.app/Contents/MacOS")

# Move the stub for the Python version into the final location
os.rename(BIN_PATH / 'Stub-{{ cookiecutter.python_version|py_tag }}', BIN_PATH / '{{ cookiecutter.formal_name }}')
# Rename the stub binary we want to "Stub""
STUB_PATH = (
BIN_PATH
/ "{% if cookiecutter.console_app %}Console{% else %}GUI{% endif %}-Stub-{{ cookiecutter.python_version|py_tag }}"
)
STUB_PATH.rename(BIN_PATH / "Stub")

# Delete all remaining stubs
for stub in BIN_PATH.glob("Stub-*"):
os.unlink(stub)
# Delete all stubs that aren't for the Python version and app type
# that we are targeting
for stub in BIN_PATH.glob("*-Stub-*"):
stub.unlink()

# The codesign utility in recent macOS fails with obscure errors when presented with
# CRLF line endings, but in some configurations (e.g. global `core.autocrlf=true`)
Expand Down
15 changes: 11 additions & 4 deletions stub/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
project_name = "Stub"
bundle = "org.beeware"
version = "1.0.0"
license.file = "../LICENSE"

[tool.briefcase.app.stub]
formal_name = "Stub"
description = "A stub binary that can be integrated into the macOS app template"
sources = ['src/stub']
[tool.briefcase.app.gui-stub]
formal_name = "GUI Stub"
description = "A stub binary for GUI apps that can be integrated into the macOS app template"
sources = ['src/gui_stub']

[tool.briefcase.app.console-stub]
formal_name = "Console Stub"
description = "A stub binary for console apps that can be integrated into the macOS app template"
sources = ['src/console_stub']
console_app = true
File renamed without changes.
Empty file added stub/src/gui_stub/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions {{ cookiecutter.format }}/installer/Distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-script minSpecVersion="1.000000">
<title>{{ cookiecutter.formal_name }}</title>
<welcome file="welcome.html" mime-type="text/html" />
<license file="LICENSE" mime-type="text/plain" />
<options customize="never" allow-external-scripts="no"/>
<domains enable_localSystem="true" />
<choices-outline>
<line choice="{{ cookiecutter.app_name }}"/>
</choices-outline>
<choice id="{{ cookiecutter.app_name }}" title="{{ cookiecutter.app_name }}">
<pkg-ref id="{{ cookiecutter.app_name }}.pkg"/>
</choice>
<pkg-ref id="{{ cookiecutter.app_name }}.pkg" auth="Root">{{ cookiecutter.app_name }}.pkg</pkg-ref>
</installer-script>
15 changes: 15 additions & 0 deletions {{ cookiecutter.format }}/installer/resources/welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style>
* {
font-family: sans-serif;
}
</style>
</head>
<body>
<h1>{{ cookiecutter.formal_name }} {{ cookiecutter.version }}</h1>
<p>This installer will guide you through the steps necessary to install {{ cookiecutter.formal_name }}.</p>
</body>
</html>
7 changes: 7 additions & 0 deletions {{ cookiecutter.format }}/installer/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
echo "Post installation process started"

echo "Install binary symlink"
ln -si "/Library/{{ cookiecutter.formal_name }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/{{ cookiecutter.formal_name }}" /usr/local/bin/{{ cookiecutter.app_name }}

echo "Post installation process finished"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading