Skip to content

Release a new version #177

Release a new version

Release a new version #177

Workflow file for this run

name: Release a new version
on:
workflow_dispatch:
inputs:
new_version:
description: Release version
required: true
type: string
env:
FULL_PYTHON_VERSION: 3.12.7
jobs:
create_release:
name: Bump version and create Github release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Bump version
run: |
echo ${{ inputs.new_version }} > zebrazoom/version.txt
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: Bump version to ${{ inputs.new_version }}
tag: release/${{ inputs.new_version }}
- name: Generate release notes
run: |
python generate_release_notes.py ${{ secrets.GITHUB_TOKEN }} > release_notes.txt
- name: Create a new release draft
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release/${{ inputs.new_version }}
release_name: release/${{ inputs.new_version }}
draft: true
prerelease: false
body_path: release_notes.txt
deploy_windows:
name: Deploy on Windows
needs: create_release
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master
- name: Install Python
uses: actions/setup-python@v5
id: python
with:
python-version: ${{ env.FULL_PYTHON_VERSION }}
- name: Install dependencies
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools wheel
${{ steps.python.outputs.python-path }} -m pip install pyinstaller
${{ steps.python.outputs.python-path }} -m pip install -e .
- name: Freeze the code
run: |
mkdir build
cd build
pyinstaller --console --icon=../icon.ico --onedir --contents-directory ZebraZoom --collect-data zebrazoom --hidden-import="sklearn.utils._vector_sentinel" --hidden-import="sklearn.utils._heap" --hidden-import="sklearn.utils._sorting" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --hidden-import="sklearn.tree._partitioner" --hidden-import="ultralytics" -n ZebraZoom ../zebrazoom/__main__.py
pyinstaller --onefile --uac-admin --icon=../icon.ico --windowed -n updater ../updater.py
rm -erroraction silentlycontinue dist/ZebraZoom/ZebraZoom/zebrazoom/dataAnalysis/data/.gitignore
rm -erroraction silentlycontinue dist/ZebraZoom/ZebraZoom/zebrazoom/dataAnalysis/resultsClustering/.gitignore
rm -erroraction silentlycontinue dist/ZebraZoom/ZebraZoom/zebrazoom/dataAnalysis/resultsKinematic/.gitignore
mkdir dist/ZebraZoom/ZebraZoom/zebrazoom/code/tracking
cp -r ../zebrazoom/code/tracking/customTrackingImplementations dist/ZebraZoom/ZebraZoom/zebrazoom/code/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/ZebraZoom/zebrazoom/code/GUI/tracking
cp -r ../zebrazoom/code/GUI/tracking/customTrackingImplementations dist/ZebraZoom/ZebraZoom/zebrazoom/code/GUI/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/ZebraZoom/updater
mv dist/updater.exe dist/ZebraZoom/ZebraZoom/updater
cp ../icon.ico dist/ZebraZoom/ZebraZoom
- name: Run the created executable
run: |
build/dist/ZebraZoom/ZebraZoom exit
rm build/dist/ZebraZoom/ZebraZoom/zebrazoom/ZZoutput/_groupsInternal.pkl
- name: Generate the list of installed files
run: |
cd build/dist/ZebraZoom/ZebraZoom
${{ steps.python.outputs.python-path }} -c "exec('''\nimport os\n\ndef walk(path):\n files = []\n for entry in os.scandir(path):\n if entry.is_dir(follow_symlinks=False):\n yield from walk(entry.path)\n yield entry.path\n else:\n files.append(entry.path)\n yield from files\n\nwith open('installedFiles.txt', 'w') as f:\n f.write('\\n'.join(map(os.path.relpath, walk('.'))))\n''')"
- name: Create archive
run: |
cd build/dist/ZebraZoom
7z a -tzip ../ZebraZoom.zip *
- name: Upload archive
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ZebraZoom-${{ runner.os }}.zip
asset_path: build/dist/ZebraZoom.zip
asset_content_type: application/zip
deploy_linux:
name: Deploy on Linux
needs: create_release
runs-on: ubuntu-latest
container:
image: rockylinux/rockylinux:8.10-ubi
options: --user root
steps:
- name: Checkout repository
uses: taiki-e/checkout-action@v1
with:
ref: master
- name: Install dependencies and build Python
run: |
curl https://www.python.org/ftp/python/${{ env.FULL_PYTHON_VERSION }}/Python-${{ env.FULL_PYTHON_VERSION }}.tar.xz -o "Python-${{ env.FULL_PYTHON_VERSION }}.tar.xz"
yum groupinstall -y 'Development Tools'
yum install -y xz mesa-libGL bzip2-devel openssl-devel libffi-devel zlib-devel
tar xf Python-*.tar.xz
cd Python-*/
./configure --with-ensurepip=install --enable-shared --enable-optimizations --prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib
make -j2
make altinstall
cd ..
rm -rf Python-*
rm -f /opt/python/bin/python*-config
/opt/python/bin/python* -m pip install --upgrade pip setuptools wheel
/opt/python/bin/python* -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu # use CPU-only torch to keep the archive size reasonable
/opt/python/bin/python* -m pip install pyinstaller
/opt/python/bin/python* -m pip install -e .
- name: Freeze the code
run: |
mkdir build
cd build
/opt/python/bin/python* -m PyInstaller --console --icon=../icon.ico --onedir --contents-directory . --collect-data zebrazoom --hidden-import="sklearn.utils._vector_sentinel" --hidden-import="sklearn.utils._heap" --hidden-import="sklearn.utils._sorting" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --hidden-import="sklearn.tree._partitioner" --hidden-import="ultralytics" -n ZebraZoom ../zebrazoom/__main__.py
/opt/python/bin/python* -m PyInstaller --onefile --icon=../icon.ico --windowed -n updater ../updater.py
rm -f dist/ZebraZoom/zebrazoom/dataAnalysis/data/.gitignore
rm -f dist/ZebraZoom/zebrazoom/dataAnalysis/resultsClustering/.gitignore
rm -f dist/ZebraZoom/zebrazoom/dataAnalysis/resultsKinematic/.gitignore
mkdir dist/ZebraZoom/zebrazoom/code/tracking
cp -r ../zebrazoom/code/tracking/customTrackingImplementations dist/ZebraZoom/zebrazoom/code/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/zebrazoom/code/GUI/tracking
cp -r ../zebrazoom/code/GUI/tracking/customTrackingImplementations dist/ZebraZoom/zebrazoom/code/GUI/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/updater
mv dist/updater dist/ZebraZoom/updater
cp ../icon.ico dist/ZebraZoom
/opt/python/bin/python* -c "import static_ffmpeg; static_ffmpeg.add_paths()" # this will ensure ffmpeg is downloaded and shipped with the zip
- name: Generate the list of installed files
run: |
cd build/dist/ZebraZoom
/opt/python/bin/python* - <<-EOF
import os
def walk(path):
files = []
for entry in os.scandir(path):
if entry.is_dir(follow_symlinks=False):
yield from walk(entry.path)
yield entry.path
else:
files.append(entry.path)
yield from files
with open('installedFiles.txt', 'w') as f:
f.write('\n'.join(map(os.path.relpath, walk('.'))))
EOF
- name: Create archive
run: |
cd build/dist/ZebraZoom
zip -r ../ZebraZoom.zip *
- name: Upload archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
ASSET_NAME: ZebraZoom-${{ runner.os }}.zip
ASSET_PATH: build/dist/ZebraZoom.zip
ASSET_CONTENT_TYPE: application/zip
run: |
/opt/python/bin/python* -m pip install requests
/opt/python/bin/python* upload_asset.py
deploy_mac:
name: Deploy on macOS
needs: create_release
runs-on: macOS-13
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master
- name: Install Python
uses: actions/setup-python@v5
id: python
with:
python-version: ${{ env.FULL_PYTHON_VERSION }}
- name: Install dependencies
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools wheel
${{ steps.python.outputs.python-path }} -m pip install pyinstaller
${{ steps.python.outputs.python-path }} -m pip install -e .
- name: Freeze the code
run: |
mkdir build
cd build
${{ steps.python.outputs.python-path }} -m PyInstaller --console --icon=../icon.ico --onedir --contents-directory ZebraZoom --osx-bundle-identifier ZebraZoom --collect-data zebrazoom --hidden-import="sklearn.utils._vector_sentinel" --hidden-import="sklearn.utils._heap" --hidden-import="sklearn.utils._sorting" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --hidden-import="sklearn.tree._partitioner" --hidden-import="ultralytics" -n ZebraZoomApp ../zebrazoom/__main__.py
${{ steps.python.outputs.python-path }} -m PyInstaller --onefile --icon=../icon.ico --windowed --osx-bundle-identifier ZebraZoom.updater -n updater ../updater.py
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/data/.gitignore
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/resultsClustering/.gitignore
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/resultsKinematic/.gitignore
mkdir dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/tracking
cp -r ../zebrazoom/code/tracking/customTrackingImplementations dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/tracking/customTrackingImplementations
mkdir dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/GUI/tracking
cp -r ../zebrazoom/code/GUI/tracking/customTrackingImplementations dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/GUI/tracking/customTrackingImplementations
mkdir dist/ZebraZoomApp/ZebraZoom/updater
mv dist/updater dist/ZebraZoomApp/ZebraZoom/updater
cp ../icon.ico dist/ZebraZoomApp/ZebraZoom
- name: Run the created executable
run: |
build/dist/ZebraZoomApp/ZebraZoomApp exit
rm build/dist/ZebraZoomApp/ZebraZoom/zebrazoom/ZZoutput/_groupsInternal.pkl
- name: Generate the list of installed files
run: |
cd build/dist/ZebraZoomApp/ZebraZoom
${{ steps.python.outputs.python-path }} - <<-EOF
import os
def walk(path):
files = []
for entry in os.scandir(path):
if entry.is_dir(follow_symlinks=False):
yield from walk(entry.path)
yield entry.path
else:
files.append(entry.path)
yield from files
with open('installedFiles.txt', 'w') as f:
f.write('\n'.join(map(os.path.relpath, walk('.'))))
EOF
#- name: Create Disk image # XXX: to enable creating app, use pyinstaller with --windowed and bundle the updater app within the zebrazoom app
# run: |
# brew install create-dmg
# cd build
# mkdir -p dist/dmg
# cp -r "dist/ZebraZoomApp.app" dist/dmg
# create-dmg \
# --volname "ZebraZoom" \
# --volicon "dist/ZebraZoomApp.app/Contents/Resources/icon-windowed.icns" \
# --window-pos 200 120 \
# --window-size 600 300 \
# --hide-extension "ZebraZoomApp.app" \
# --app-drop-link 425 120 \
# "dist/ZebraZoom.dmg" \
# "dist/dmg/"
#- name: Upload Disk image
# uses: actions/upload-release-asset@latest
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_name: ZebraZoom-${{ runner.os }}.dmg
# asset_path: build/dist/ZebraZoom.dmg
# asset_content_type: application/octet-stream
- name: Create archive
run: |
cd build/dist/ZebraZoomApp
zip -r ../ZebraZoom.zip *
- name: Upload archive
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ZebraZoom-${{ runner.os }}.zip
asset_path: build/dist/ZebraZoom.zip
asset_content_type: application/zip
deploy_windows_legacy:
name: Deploy legacy format on Windows
needs: create_release
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master
- name: Install Python
uses: actions/setup-python@v5
id: python
with:
python-version: ${{ env.FULL_PYTHON_VERSION }}
- name: Install dependencies
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools wheel
${{ steps.python.outputs.python-path }} -m pip install pyinstaller
${{ steps.python.outputs.python-path }} -m pip install -e .
- name: Freeze the code
run: |
mkdir build
cd build
pyinstaller --console --icon=../icon.ico --onedir --contents-directory . --collect-data zebrazoom --hidden-import="sklearn.utils._vector_sentinel" --hidden-import="sklearn.utils._heap" --hidden-import="sklearn.utils._sorting" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --hidden-import="sklearn.tree._partitioner" --hidden-import="ultralytics" -n ZebraZoom ../zebrazoom/__main__.py
pyinstaller --onefile --uac-admin --icon=../icon.ico --windowed -n updater ../updater.py
rm -erroraction silentlycontinue dist/ZebraZoom/zebrazoom/dataAnalysis/data/.gitignore
rm -erroraction silentlycontinue dist/ZebraZoom/zebrazoom/dataAnalysis/resultsClustering/.gitignore
rm -erroraction silentlycontinue dist/ZebraZoom/zebrazoom/dataAnalysis/resultsKinematic/.gitignore
mkdir dist/ZebraZoom/zebrazoom/code/tracking
cp -r ../zebrazoom/code/tracking/customTrackingImplementations dist/ZebraZoom/zebrazoom/code/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/zebrazoom/code/GUI/tracking
cp -r ../zebrazoom/code/GUI/tracking/customTrackingImplementations dist/ZebraZoom/zebrazoom/code/GUI/tracking/customTrackingImplementations
mkdir dist/ZebraZoom/updater
mv dist/updater.exe dist/ZebraZoom/updater
cp ../icon.ico dist/ZebraZoom
- name: Run the created executable
run: |
build/dist/ZebraZoom/ZebraZoom exit
rm build/dist/ZebraZoom/zebrazoom/ZZoutput/_groupsInternal.pkl
- name: Generate the list of installed files
run: |
cd build/dist/ZebraZoom
${{ steps.python.outputs.python-path }} -c "exec('''\nimport os\n\ndef walk(path):\n files = []\n for entry in os.scandir(path):\n if entry.is_dir(follow_symlinks=False):\n yield from walk(entry.path)\n yield entry.path\n else:\n files.append(entry.path)\n yield from files\n\nwith open('installedFiles.txt', 'w') as f:\n f.write('\\n'.join(map(os.path.relpath, walk('.'))))\n''')"
- name: Create installer
uses: joncloud/[email protected]
- name: Upload installer
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ZebraZoom-${{ runner.os }}.exe
asset_path: ZebraZoom.exe
asset_content_type: application/octet-stream
- name: Create update archive
run: |
cd build/dist/ZebraZoom
7z a -tzip ../ZebraZoomUpdate.zip *
- name: Upload update archive
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ZebraZoom-update-${{ runner.os }}.zip
asset_path: build/dist/ZebraZoomUpdate.zip
asset_content_type: application/zip
deploy_mac_legacy:
name: Deploy legacy format on macOS
needs: create_release
runs-on: macOS-13
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master
- name: Install Python
uses: actions/setup-python@v5
id: python
with:
python-version: ${{ env.FULL_PYTHON_VERSION }}
- name: Install dependencies
run: |
${{ steps.python.outputs.python-path }} -m pip install --upgrade pip setuptools wheel
${{ steps.python.outputs.python-path }} -m pip install pyinstaller
${{ steps.python.outputs.python-path }} -m pip install -e .
- name: Freeze the code
run: |
mkdir build
cd build
${{ steps.python.outputs.python-path }} -m PyInstaller --console --icon=../icon.ico --onedir --contents-directory ZebraZoom --osx-bundle-identifier ZebraZoom --collect-data zebrazoom --hidden-import="sklearn.utils._vector_sentinel" --hidden-import="sklearn.utils._heap" --hidden-import="sklearn.utils._sorting" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --hidden-import="sklearn.tree._partitioner" --hidden-import="ultralytics" -n ZebraZoomApp ../zebrazoom/__main__.py
${{ steps.python.outputs.python-path }} -m PyInstaller --onefile --icon=../icon.ico --windowed --osx-bundle-identifier ZebraZoom.updater -n updater ../updater.py
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/data/.gitignore
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/resultsClustering/.gitignore
rm -f dist/ZebraZoomApp/ZebraZoom/zebrazoom/dataAnalysis/resultsKinematic/.gitignore
mkdir dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/tracking
cp -r ../zebrazoom/code/tracking/customTrackingImplementations dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/tracking/customTrackingImplementations
mkdir dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/GUI/tracking
cp -r ../zebrazoom/code/GUI/tracking/customTrackingImplementations dist/ZebraZoomApp/ZebraZoom/zebrazoom/code/GUI/tracking/customTrackingImplementations
mkdir dist/ZebraZoomApp/ZebraZoom/updater
mv dist/updater dist/ZebraZoomApp/ZebraZoom/updater
cp ../icon.ico dist/ZebraZoomApp/ZebraZoom
- name: Run the created executable
run: |
build/dist/ZebraZoomApp/ZebraZoomApp exit
rm build/dist/ZebraZoomApp/ZebraZoom/zebrazoom/ZZoutput/_groupsInternal.pkl
- name: Generate the list of installed files
run: |
cd build/dist/ZebraZoomApp
${{ steps.python.outputs.python-path }} - <<-EOF
import os
def walk(path):
files = []
for entry in os.scandir(path):
if entry.is_dir(follow_symlinks=False):
yield from walk(entry.path)
yield entry.path
else:
files.append(entry.path)
yield from files
with open('installedFiles.txt', 'w') as f:
f.write('\n'.join(map(os.path.relpath, walk('.'))))
EOF
- name: Create update archive
run: |
cd build/dist/ZebraZoomApp
zip -r ../ZebraZoomUpdate.zip *
- name: Upload update archive
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ZebraZoom-update-${{ runner.os }}.zip
asset_path: build/dist/ZebraZoomUpdate.zip
asset_content_type: application/zip
publish_release:
name: Publish release
needs: [create_release, deploy_windows, deploy_linux, deploy_mac, deploy_windows_legacy, deploy_mac_legacy]
runs-on: ubuntu-latest
steps:
- name: Publish the release draft on Github
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create_release.outputs.release_id }}
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.FULL_PYTHON_VERSION }}
- name: Prepare package for PyPI release
run: |
pip install --upgrade pip setuptools wheel
python setup.py sdist bdist_wheel
- name: Publish the release on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}