diff --git a/.github/workflows/update-binary.yml b/.github/workflows/update-binary.yml index 9a5fa3b..1acb6fc 100644 --- a/.github/workflows/update-binary.yml +++ b/.github/workflows/update-binary.yml @@ -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/upload-artifact@v4.3.3 with: name: stub-${{ matrix.python-version }} - path: stub/Stub-${{ env.PYTHON_TAG }} + path: stub/*-Stub-${{ env.PYTHON_TAG }} commit-stubs: name: Commit stub binaries @@ -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 @@ -109,12 +103,12 @@ jobs: git config user.email "brutus@beeware.org" 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: diff --git a/cookiecutter.json b/cookiecutter.json index 3defe9e..e9bb3b0 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,6 +6,7 @@ "info": "", "entitlements": "", "document_types": "", + "console_app": false, "version": "1.0.0", "build": "1", "bundle": "com.example", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 367bfc2..ebdd896 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -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`) diff --git a/stub/pyproject.toml b/stub/pyproject.toml index 4a3ee9b..978a925 100644 --- a/stub/pyproject.toml +++ b/stub/pyproject.toml @@ -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 diff --git a/stub/src/stub/__init__.py b/stub/src/console_stub/__init__.py similarity index 100% rename from stub/src/stub/__init__.py rename to stub/src/console_stub/__init__.py diff --git a/stub/src/gui_stub/__init__.py b/stub/src/gui_stub/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{ cookiecutter.format }}/installer/Distribution.xml b/{{ cookiecutter.format }}/installer/Distribution.xml new file mode 100644 index 0000000..6e21ea1 --- /dev/null +++ b/{{ cookiecutter.format }}/installer/Distribution.xml @@ -0,0 +1,15 @@ + + + {{ cookiecutter.formal_name }} + + + + + + + + + + + {{ cookiecutter.app_name }}.pkg + diff --git a/{{ cookiecutter.format }}/installer/resources/welcome.html b/{{ cookiecutter.format }}/installer/resources/welcome.html new file mode 100644 index 0000000..97100d0 --- /dev/null +++ b/{{ cookiecutter.format }}/installer/resources/welcome.html @@ -0,0 +1,15 @@ + + + + + + + +

{{ cookiecutter.formal_name }} {{ cookiecutter.version }}

+

This installer will guide you through the steps necessary to install {{ cookiecutter.formal_name }}.

+ + diff --git a/{{ cookiecutter.format }}/installer/scripts/postinstall b/{{ cookiecutter.format }}/installer/scripts/postinstall new file mode 100755 index 0000000..12d5afc --- /dev/null +++ b/{{ cookiecutter.format }}/installer/scripts/postinstall @@ -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" diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.10 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.10 new file mode 100755 index 0000000..2aa64c9 Binary files /dev/null and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.10 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.11 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.11 new file mode 100755 index 0000000..ecac288 Binary files /dev/null and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.11 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.12 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.12 new file mode 100755 index 0000000..734a286 Binary files /dev/null and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.12 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.8 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.8 new file mode 100755 index 0000000..7614dbd Binary files /dev/null and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.8 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.9 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.9 new file mode 100755 index 0000000..4f39ea1 Binary files /dev/null and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Console-Stub-3.9 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.10 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.10 similarity index 66% rename from {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.10 rename to {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.10 index fd6c395..26b0ea5 100755 Binary files a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.10 and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.10 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.11 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.11 similarity index 68% rename from {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.11 rename to {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.11 index 44a987c..4ff2f34 100755 Binary files a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.11 and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.11 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.12 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.12 similarity index 73% rename from {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.12 rename to {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.12 index b8d4d3f..3f73c5b 100755 Binary files a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.12 and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.12 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.8 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.8 similarity index 63% rename from {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.8 rename to {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.8 index 14d4c1f..c2fd8ba 100755 Binary files a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.8 and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.8 differ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.9 b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.9 similarity index 65% rename from {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.9 rename to {{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.9 index 2727559..b85f748 100755 Binary files a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/Stub-3.9 and b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS/GUI-Stub-3.9 differ