Skip to content

Commit

Permalink
Modify stub handling to allow for console and GUI stubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 11, 2024
1 parent f0071f1 commit a0b6fa0
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 25 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/update-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ jobs:
# Generate the stub app
cd stub
briefcase build windows visualstudio
echo "Move the binary into the final location"
mv ./build/stub/windows/visualstudio/x64/Release/Stub.exe ./Stub-${{ env.PYTHON_TAG }}.exe
echo "Move the binaries into the final location"
mv ./build/console-stub/windows/visualstudio/x64/Release/console-stub.exe ./Console-Stub-${{ env.PYTHON_TAG }}.exe
mv "./build/gui-stub/windows/visualstudio/x64/Release/GUI stub.exe" ./GUI-Stub-${{ env.PYTHON_TAG }}.exe
- name: Upload Stub Artefact
uses: actions/[email protected]
with:
name: stub-${{ matrix.python-version }}
path: stub/Stub-${{ env.PYTHON_TAG }}.exe
path: stub/*-Stub-${{ env.PYTHON_TAG }}.exe

commit-stubs:
name: Commit Stub Binaries
Expand All @@ -75,23 +76,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 @@ -108,8 +101,8 @@ jobs:
run: |
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 }}/src"
# Move the binaries into their final location
mv stub/*-Stub-* "{{ cookiecutter.format }}/src"
git add "{{ cookiecutter.format }}/src"
git commit -m "AUTO: Update app binaries; build ${{ env.TAG }}"
git push origin HEAD:${{ env.TEMPLATE_BRANCH }}
Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author_email": "[email protected]",
"url": "http://example.com",
"description": "Short description of app",
"console_app": false,
"guid": "1409c8f5-c276-4cf3-a2fd-defcbdfef9a2",
"install_scope": "",
"use_full_install_path": true,
Expand Down
9 changes: 6 additions & 3 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

BIN_PATH = Path("src")

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

# Delete all remaining stubs
for stub in BIN_PATH.glob("Stub-*.exe"):
for stub in BIN_PATH.glob("*-Stub-*.exe"):
os.unlink(stub)
16 changes: 12 additions & 4 deletions stub/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ project_name = "Stub"
bundle = "org.beeware"
version = "1.0.0"

[tool.briefcase.app.stub]
formal_name = "Stub"
description = "A stub binary that can be integrated into the Windows app template"
sources = ['src/stub']
template_branch = "console-app"

[tool.briefcase.app.gui-stub]
formal_name = "GUI Stub"
description = "A stub binary for GUI apps that can be integrated into the Windows 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 Windows app template"
sources = ['src/console_stub']
console_app = true
File renamed without changes.
Empty file added stub/src/gui_stub/__init__.py
Empty file.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.10.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.11.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.12.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.8.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.9.exe
Binary file not shown.

0 comments on commit a0b6fa0

Please sign in to comment.