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

Create standalone executables for popular tools #438

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
152 changes: 108 additions & 44 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,116 @@ on:
name: Create and Publish Release

jobs:
apps:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
python-version: [3.9]
platform: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install packages
run: |
pip install .[qa]
pip install pyinstaller
- name: Build executables
run: |
pyinstaller gftools.spec
- name: gen zip file name
id: zip-name
shell: bash
# Set the archive name to repo name + "-assets" e.g "MavenPro-assets"
run: echo "ZIP_NAME=$(echo $RUNNER_OS)-binaries" >> $GITHUB_ENV
# If a new release is cut, use the release tag to auto-bump the source files

# foo bar
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.ZIP_NAME }}
path: |
dist/*
outputs:
zip_name: ${{ env.ZIP_NAME }}


build:
name: Create and Publish Release
runs-on: ubuntu-latest
needs:
- apps

steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine

- name: Get release notes
id: release_notes
run: |
# By default, GH Actions checkout will only fetch a single commit.
# For us to extract the release notes, we need to fetch the tags
# and tag annotations as well.
# https://github.com/actions/checkout/issues/290
git fetch --tags --force
TAG_NAME=${GITHUB_REF/refs\/tags\//}
echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "${{ runner.temp }}/CHANGELOG.md"
draft: false
prerelease: false

# - name: Build and publish to PyPI
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# python setup.py sdist bdist_wheel
# twine upload dist/gftools*
# outputs:
# zip_name: ${{ env.ZIP_NAME }}
#

attach:
needs: [apps, build]
runs-on: ubuntu-latest
env:
ZIP_NAME: ${{ needs.apps.outputs.zip_name }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine

- name: Get release notes
id: release_notes
run: |
# By default, GH Actions checkout will only fetch a single commit.
# For us to extract the release notes, we need to fetch the tags
# and tag annotations as well.
# https://github.com/actions/checkout/issues/290
git fetch --tags --force
TAG_NAME=${GITHUB_REF/refs\/tags\//}
echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "${{ runner.temp }}/CHANGELOG.md"
draft: false
prerelease: false

- name: Build and publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/gftools*
- uses: actions/checkout@v2
- name: Download all artefact files
uses: actions/download-artifact@v2
- name: Zip files
run: |
for d in *-binaries; do zip -r $d $d; done
- name: Upload binaries to release
uses: alexellis/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '[" *-binaries.zip "]'
100 changes: 100 additions & 0 deletions gftools.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
import freetype as ft

datas = []
binaries = [(ft.raw.filename, ".")]
hiddenimports = []
tmp_ret = collect_all("gftools")
datas += tmp_ret[0]
binaries += tmp_ret[1]
hiddenimports += tmp_ret[2]

# from gftools builder
tmp_ret = collect_all("glyphsLib")
datas += tmp_ret[0]
binaries += tmp_ret[1]
hiddenimports += tmp_ret[2]



block_cipher = None


a_qa = Analysis(
["bin/gftools-qa.py"],
pathex=["."],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
a_builder = Analysis(
["bin/gftools-builder.py"],
pathex=["."],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)

MERGE(
(a_qa, "gftools-qa", "gftools-qa"),
(a_builder, "gftools-builder", "gftools-builder"),
)

pyz_qa = PYZ(a_qa.pure, a_qa.zipped_data, cipher=block_cipher)
pyz_builder = PYZ(a_builder.pure, a_builder.zipped_data, cipher=block_cipher)

exe_qa = EXE(
pyz_qa,
a_qa.scripts,
a_qa.binaries,
a_qa.dependencies,
a_qa.zipfiles,
a_qa.datas,
[],
name="gftools-qa",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
exe_builder = EXE(
pyz_builder,
a_builder.scripts,
a_builder.binaries,
a_builder.dependencies,
a_builder.zipfiles,
a_builder.datas,
[],
name="gftools-builder",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)