👈 Reset the file pointer when returning font from get_webfont
(#121)
#138
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.?[0-9]* | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: linux | |
arch: x86_64 | |
runs: ubuntu-latest | |
ext: "" | |
- os: windows | |
arch: x86_64 | |
runs: windows-latest | |
ext: ".exe" | |
- os: macos | |
arch: x86_64 | |
runs: macos-12 | |
ext: "" | |
- os: macos | |
arch: arm64 | |
runs: macos-14 | |
ext: "" | |
runs-on: ${{ matrix.runs }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.11" | |
architecture: x64 # Otherwise the runner will try to download Python arm64, which is not available. x64 has support for both archs (universal2). | |
- name: Install latest stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Build | |
run: | | |
python -m pip install --upgrade pip | |
pip install "pyinstaller>=5.12" | |
pip install certifi | |
pip install maturin | |
pip install .[fast] | |
bash -c "rm -rf /tmp/orjson" | |
bash scripts/install_patched_orjson.sh | |
pyinstaller src/fig2sketch.py -y --onefile --target-arch ${{ matrix.arch }} | |
- name: Rename binary | |
run: mv dist/fig2sketch${{ matrix.ext }} dist/fig2sketch-${{ github.ref_name }}${{ matrix.ext }} | |
- name: zip release | |
uses: thedoctor0/zip-release@main | |
with: | |
type: "zip" | |
filename: "fig2sketch-${{ matrix.os }}-${{ matrix.arch }}.zip" | |
directory: "dist" | |
path: "*" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: dist/fig2sketch-${{ matrix.os }}-${{ matrix.arch }}.zip | |
build-macos-universal: | |
needs: [build] | |
runs-on: macos-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: builds | |
- name: Create universal binary with lipo | |
# Why are we patching the binary? | |
# Both binaries are generated by pyinstaller. This works by archiving the python interpreter and .py files | |
# and then adding a binary that unarchives the content and runs them (similar to a self-extracting zip). | |
# The problem is that it locates the start of the archive inside the binary by looking for a specific magic value. | |
# Both binaries (x86_64 and arm64) use the same magic value, so after bundling in a universal binary, the bootloader | |
# will always find the first archive, even if it's the wrong architecture. Thus, only one architecture works. | |
# The binary patch applied below changes the magic value for only one of the binaries, so we have a different | |
# magic value to search for each architecture, which solves the problem. | |
# We need to re-sign the binary afterwards since the signature becomes invalid when tweaking the bytes | |
run: | | |
mkdir x86_64 | |
mkdir arm64 | |
mkdir -p dist | |
unzip fig2sketch-macos-x86_64.zip -d x86_64/ | |
unzip fig2sketch-macos-arm64.zip -d arm64/ | |
hexdump -ve '1/1 "%.2X"' x86_64/fig2sketch-${{ github.ref_name }} | sed "s/4D45490\([0C]\)0B0A0B0E/4D45490\10B0A0B0F/g" | xxd -r -p > x86_64/fig2sketch.patched | |
codesign --remove x86_64/fig2sketch.patched | |
codesign -s - x86_64/fig2sketch.patched | |
lipo -create x86_64/fig2sketch.patched arm64/fig2sketch-${{ github.ref_name }} -output dist/fig2sketch-${{ github.ref_name }} | |
- name: zip release | |
uses: thedoctor0/zip-release@main | |
with: | |
type: "zip" | |
filename: "fig2sketch-macos-universal.zip" | |
directory: "dist" | |
path: "*" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: dist/fig2sketch-macos-universal.zip | |
create-release: | |
needs: [build, build-macos-universal] | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: builds | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "fig2sketch-*.zip" | |
generateReleaseNotes: true | |
publish-to-pypi: | |
name: Build and publish to PyPi | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.11" | |
- name: Install build tools | |
run: pip install build | |
- name: Build source distribution | |
run: python -m build --sdist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |