Skip to content

Commit

Permalink
fix(desktop): correct Antares Desktop packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro authored and skamril committed Jun 15, 2023
1 parent ecc9a64 commit 95d7544
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 67 deletions.
77 changes: 40 additions & 37 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#file: noinspection YAMLSchemaValidation
name: deploy
on:
push:
Expand All @@ -14,68 +15,70 @@ jobs:
os: [ windows-latest, ubuntu-20.04 ]

steps:
- name: Checkout github repo (+ download lfs dependencies)
- name: 🐙 Checkout GitHub repo (+ download lfs dependencies)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install wget for windows

- name: 🔗 Install wget for Windows
if: matrix.os == 'windows-latest'
run: choco install wget --no-progress
- name: Set up Node.js
uses: actions/setup-node@v1

- name: 💚 Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: Install dependencies

- name: 💚 Install dependencies
run: npm install
working-directory: webapp
- name: Build

- name: 💚 Build webapp
run: bash ./build-front.sh
working-directory: scripts
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Set up Python

- name: 🐍 Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies

- name: 🐍 Install development dependencies
run: |
python -m pip install --upgrade pip
pip install pydantic --no-binary pydantic
pip install -r requirements-dev.txt
- name: Install Windows dependencies
- name: 🐍 Install Windows dependencies
if: matrix.os == 'windows-latest'
run: pip install -r requirements-windows.txt
- name: Generate Windows binary
if: matrix.os == 'windows-latest'
run: |
git log -1 HEAD --format=%H > .\resources\commit_id
pyinstaller AntaresWebWin.spec
- name: Generate linux binary
if: matrix.os == 'ubuntu-20.04'
run: |
git log -1 HEAD --format=%H > .\resources\commit_id
pyinstaller AntaresWebLinux.spec
- name: Generate Windows worker binary
if: matrix.os == 'windows-latest'
run: |
git log -1 HEAD --format=%H > .\resources\commit_id
pyinstaller -F antarest\worker\archive_worker_service.py -n AntaresWebWorker --add-data ".\resources;.\resources" --hidden-import 'pythonjsonlogger.jsonlogger'
- name: Generate Linux worker binary
if: matrix.os == 'ubuntu-20.04'
run: |
git log -1 HEAD --format=%H > ./resources/commit_id
pyinstaller -F antarest/worker/archive_worker_service.py -n AntaresWebWorker --add-data resources:resources --hidden-import 'pythonjsonlogger.jsonlogger'
- name: Packaging

- name: 📦 Packaging
run: bash ./package_antares_web.sh
working-directory: scripts
- name: install changelog requirements

- name: 📜 Install changelog requirements
run: npm install -g auto-changelog
- name: generate changelog file

- name: 📜️ Generate changelog file
run: |
auto-changelog -l false --hide-empty-releases
cp CHANGELOG.md dist/CHANGELOG.md
- name: Archive binaries
uses: actions/upload-artifact@v2
mv CHANGELOG.md dist/package/CHANGELOG.md
- name: 📦 Archive Antares Desktop + Worker for Windows
if: matrix.os == 'windows-latest'
run: 7z a AntaresWeb.zip *
working-directory: dist/package

- name: 📦 Archive Antares Desktop + Worker for Ubuntu
# this is the only way to preserve file permission and symlinks
if: matrix.os == 'ubuntu-20.04'
run: zip -r --symlinks AntaresWeb.zip *
working-directory: dist/package

- name: 🚀 Upload binaries
uses: actions/upload-artifact@v3
with:
name: AntaresWeb-${{ matrix.os }}
path: dist/*
name: AntaresWeb-${{ matrix.os }}-pkg
path: dist/package/AntaresWeb.zip
45 changes: 45 additions & 0 deletions AntaresWebWorker.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(
["antarest/worker/archive_worker_service.py"],
pathex=[],
binaries=[],
datas=[("resources", "resources")],
hiddenimports=["pythonjsonlogger.jsonlogger"],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(
a.pure,
a.zipped_data,
cipher=block_cipher,
)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name="AntaresWebWorker",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
2 changes: 1 addition & 1 deletion resources/deploy/examples/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Examples can be found at https://github.com/AntaresSimulatorTeam/Antares_Simulator_Examples
These can be copied into the studies directory.
These can be copied into the `studies` directory.
Binary file modified resources/deploy/examples/studies/example_study.zip
Binary file not shown.
100 changes: 71 additions & 29 deletions scripts/package_antares_web.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,100 @@
#!/bin/bash

# Antares Web Packaging -- Desktop Version
#
# This script is launch by the GitHub Workflow `.github/workflows/deploy.yml`.
# It builds the Desktop version of the Web Application and the Worker Application.
# Make sure you run the `npm install` stage before running this script.

set -e

ANTARES_SOLVER_VERSION="8.5"
ANTARES_SOLVER_FULL_VERSION="8.5.1"
ANTARES_SOLVER_FULL_VERSION_INT=$(echo $ANTARES_SOLVER_FULL_VERSION | sed 's/\.//g')
ANTARES_SOLVER_FULL_VERSION="8.5.0"
ANTARES_SOLVER_FULL_VERSION_INT="850"

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
PROJECT_DIR=$(dirname -- "${SCRIPT_DIR}")
DIST_DIR="${PROJECT_DIR}/dist/package"
RESOURCES_DIR="${PROJECT_DIR}/resources"
ANTARES_SOLVER_DIR="${DIST_DIR}/AntaresWeb/antares_solver"

if [[ "$OSTYPE" == "msys"* ]]; then
ANTARES_SOLVER_FOLDER_NAME="rte-antares-$ANTARES_SOLVER_FULL_VERSION-installer-64bits"
ANTARES_SOLVER_ZIPFILE_NAME="$ANTARES_SOLVER_FOLDER_NAME.zip"
else
ANTARES_SOLVER_FOLDER_NAME="antares-$ANTARES_SOLVER_FULL_VERSION-Ubuntu-20.04"
ANTARES_SOLVER_ZIPFILE_NAME="$ANTARES_SOLVER_FOLDER_NAME.tar.gz"
ANTARES_SOLVER_ZIPFILE_NAME="antares-solver_ubuntu20.04.tar.gz"
fi

LINK="https://github.com/AntaresSimulatorTeam/Antares_Simulator/releases/download/v$ANTARES_SOLVER_FULL_VERSION/$ANTARES_SOLVER_ZIPFILE_NAME"
DESTINATION="../dist/AntaresWeb/antares_solver"

echo "Downloading AntaresSimulator from $LINK"
wget $LINK
echo "INFO: Preparing the Git Commit ID..."
git log -1 HEAD --format=%H > ${RESOURCES_DIR}/commit_id

echo "Unzipping $ANTARES_SOLVER_ZIPFILE_NAME and move Antares solver to $DESTINATION"
7z x $ANTARES_SOLVER_ZIPFILE_NAME
if [[ "$OSTYPE" != "msys"* ]]; then
7z x "$ANTARES_SOLVER_FOLDER_NAME.tar"
echo "INFO: Generating the Desktop version of the Web Application..."
if [[ "$OSTYPE" == "msys"* ]]; then
pushd ${PROJECT_DIR}
pyinstaller --distpath ${DIST_DIR} AntaresWebWin.spec
popd
else
pushd ${PROJECT_DIR}
pyinstaller --distpath ${DIST_DIR} AntaresWebLinux.spec
popd
fi

mkdir $DESTINATION
echo "INFO: Generating the Worker Application..."
pushd ${PROJECT_DIR}
pyinstaller --distpath ${DIST_DIR} AntaresWebWorker.spec
popd

echo "INFO: Creating destination directory '${ANTARES_SOLVER_DIR}'..."
mkdir -p "${ANTARES_SOLVER_DIR}"

echo "INFO: Downloading '$ANTARES_SOLVER_ZIPFILE_NAME' in '$ANTARES_SOLVER_DIR'..."
cd "$ANTARES_SOLVER_DIR" || exit
wget $LINK

echo "INFO: Uncompressing '$ANTARES_SOLVER_ZIPFILE_NAME'..."
if [[ "$OSTYPE" == "msys"* ]]; then
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/antares-$ANTARES_SOLVER_VERSION-solver.exe" $DESTINATION
mv $ANTARES_SOLVER_FOLDER_NAME/bin/sirius_solver.dll $DESTINATION
mv $ANTARES_SOLVER_FOLDER_NAME/bin/zlib1.dll $DESTINATION
7z x $ANTARES_SOLVER_ZIPFILE_NAME
else
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/antares-$ANTARES_SOLVER_VERSION-solver" $DESTINATION
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/libsirius_solver.so" $DESTINATION
tar xzf $ANTARES_SOLVER_ZIPFILE_NAME
fi
rm $ANTARES_SOLVER_ZIPFILE_NAME

echo "Copy basic configuration files"
cp -r ../resources/deploy/* ../dist/
if [[ "$OSTYPE" == "msys"* ]]; then
sed -i "s/700: path\/to\/700/$ANTARES_SOLVER_FULL_VERSION_INT: .\/AntaresWeb\/antares_solver\/antares-$ANTARES_SOLVER_VERSION-solver.exe/g" ../dist/config.yaml
echo "INFO: Moving executables in '$ANTARES_SOLVER_DIR'..."
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/antares-$ANTARES_SOLVER_VERSION-solver.exe" "$ANTARES_SOLVER_DIR"
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/sirius_solver.dll" "$ANTARES_SOLVER_DIR"
mv "$ANTARES_SOLVER_FOLDER_NAME/bin/zlib1.dll" "$ANTARES_SOLVER_DIR"
rm -rf $ANTARES_SOLVER_FOLDER_NAME
fi

echo "INFO: Copying basic configuration files..."
rm -rf "${DIST_DIR}/examples" # in case of replay
cp -r "${RESOURCES_DIR}"/deploy/* "${DIST_DIR}"
if [[ "$OSTYPE" == "msys"* ]]; then
sed -i "s/700: path\/to\/700/$ANTARES_SOLVER_FULL_VERSION_INT: .\/AntaresWeb\/antares_solver\/antares-$ANTARES_SOLVER_VERSION-solver.exe/g" "${DIST_DIR}/config.yaml"
else
sed -i "s/700: path\/to\/700/$ANTARES_SOLVER_FULL_VERSION_INT: .\/AntaresWeb\/antares_solver\/antares-$ANTARES_SOLVER_VERSION-solver/g" ../dist/config.yaml
sed -i "s/700: path\/to\/700/$ANTARES_SOLVER_FULL_VERSION_INT: .\/AntaresWeb\/antares_solver\/antares-$ANTARES_SOLVER_VERSION-solver/g" "${DIST_DIR}/config.yaml"
fi

echo "Creating shortcuts"
echo "INFO: Creating shortcuts..."
if [[ "$OSTYPE" == "msys"* ]]; then
cp ../resources/AntaresWebServerShortcut.lnk ../dist/
cp "${RESOURCES_DIR}/AntaresWebServerShortcut.lnk" "${DIST_DIR}"
else
echo "INFO: Updating executable permissions..."
for excutable in "${DIST_DIR}/AntaresWeb/AntaresWebServer" "${DIST_DIR}/AntaresWeb/AntaresTool" "${DIST_DIR}/AntaresWebWorker"; do
chmod +x "${excutable}"
done
fi

echo "Unzipping example study"
cd ../dist/examples/studies || exit
7z x example_study.zip
echo "INFO: Unzipping example study..."
cd "${DIST_DIR}/examples/studies" || exit
if [[ "$OSTYPE" == "msys"* ]]; then
7z x example_study.zip
else
unzip -q example_study.zip
fi
rm example_study.zip

echo "Cleaning up"
rm $ANTARES_SOLVER_ZIPFILE_NAME
rm -rf $ANTARES_SOLVER_FOLDER_NAME
echo "INFO: Antares Web Packaging DONE."

0 comments on commit 95d7544

Please sign in to comment.