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

Remove stub binaries from app template #58

Merged
merged 4 commits into from
Jun 6, 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
76 changes: 17 additions & 59 deletions .github/workflows/update-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,67 +49,25 @@ jobs:
# Generate the stub app
cd stub
briefcase build macOS Xcode
# 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 }}
echo "Build console stub artefact"
mv "./build/console-stub/macos/xcode/build/Release/Console Stub.app/Contents/MacOS/Console Stub" Stub
codesign --remove-signature Stub
zip Console-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip Stub

commit-stubs:
name: Commit stub binaries
needs: build-stubs
runs-on: macos-latest
steps:
- name: Set Build Variables
echo "Build GUI stub artefact"
mv "./build/gui-stub/macos/xcode/build/Release/GUI Stub.app/Contents/MacOS/GUI Stub" Stub
codesign --remove-signature Stub
zip Console-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip Stub

- name: Upload Release Asset to S3
env:
TAG_NAME: ${{ github.ref }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
export TAG=$(basename $TAG_NAME)
export BRIEFCASE_VERSION="${TAG%-*}"
export BUILD_NUMBER="${TAG#*-}"
python -m pip install -U pip
python -m pip install -U setuptools
python -m pip install awscli

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" | tee -a $GITHUB_ENV
else
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}" | tee -a $GITHUB_ENV
fi

- name: Checkout Template
uses: actions/checkout@v4.1.6

- name: Download Stub Artefacts
uses: actions/download-artifact@v4.1.7
with:
pattern: stub-*
path: stub
merge-multiple: true

- name: Commit stubs
run: |
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"
# Ensure the binary is executable
cd "{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.app/Contents/MacOS"
chmod 755 *-Stub-*
# Commit changes
git add ./*-Stub-*
git commit -m "AUTO: Update app binaries; build ${{ env.TAG }}"
git push origin HEAD:${{ env.TEMPLATE_BRANCH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
aws s3 cp stub/Console-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip s3://briefcase-support/python/${{ steps.build-vars.outputs.PY_VERSION }}/macOS/Console-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip
aws s3 cp stub/GUI-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip s3://briefcase-support/python/${{ steps.build-vars.outputs.PY_VERSION }}/macOS/GUI-Stub-${{ env.PYTHON_TAG }}-${{ steps.build-vars.outputs.BUILD_NUMBER }}.zip
17 changes: 1 addition & 16 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
from pathlib import Path


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

# 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 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`)
# git may have checked out this repo in a way that put CRLF line endings in Entitlements.plist.
Expand All @@ -24,6 +9,6 @@
xml_content = ENTITLEMENTS_PATH.read_text()
ENTITLEMENTS_PATH.open('w', newline='\n').write(xml_content)

INFO_PATH = BIN_PATH.parent / 'Info.plist'
INFO_PATH = Path("{{ cookiecutter.formal_name }}.app/Contents/Info.plist")
info_content = INFO_PATH.read_text()
INFO_PATH.open('w', newline='\n').write(info_content)
1 change: 1 addition & 0 deletions {{ cookiecutter.format }}/briefcase.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ support_path = "{{ cookiecutter.formal_name }}.app/Contents/Resources/support"
"3.11": "support_revision = 3",
"3.12": "support_revision = 2",
}.get(cookiecutter.python_version|py_tag, "") }}
stub_binary_revision = 8
cleanup_paths = [
"{{ cookiecutter.formal_name }}.app/Contents/Resources/support/Python.xcframework",
"{{ cookiecutter.formal_name }}.app/Contents/Resources/support/platform-site",
Expand Down
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