Skip to content

Merge pull request #46 from OpenAstroTech/bugfix/js/45-unicode-decode… #242

Merge pull request #46 from OpenAstroTech/bugfix/js/45-unicode-decode…

Merge pull request #46 from OpenAstroTech/bugfix/js/45-unicode-decode… #242

on: push
defaults:
run:
shell: bash
jobs:
build-windows:
runs-on: 'windows-2022'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: Run set_version script
uses: ./.github/actions/run-set_version_script
with:
venv-bin-dir: Scripts # idk why windows does this different
- run: mkdir dist/
- name: Download python embedded
run: curl -L "https://www.python.org/ftp/python/3.10.7/python-3.10.7-embed-amd64.zip" -o python-embedded.zip
- name: Unzip python embedded
run: unzip python-embedded.zip -d dist/.python_local
- name: Weird DLL workaround so that pip can see all default embedded python modules
# See https://github.com/python/cpython/issues/100399#issuecomment-1381486117
run: |
mkdir dist/.python_local/DLLs
GLOBIGNORE="dist/.python_local/python3*.dll"
mv -v dist/.python_local/*.{dll,pyd} dist/.python_local/DLLs
- name: Modify python embedded to allow pip to run # See https://stackoverflow.com/questions/42666121/pip-with-embedded-python
run: rm -v dist/.python_local/python310._pth
- name: Download get-pip.py
run: curl -L "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
working-directory: dist/.python_local
- name: Run get-pip.py
run: ./python.exe ./get-pip.py
working-directory: dist/.python_local
- name: Install requirements
run: dist/.python_local/python.exe -m pip install --requirement requirements.txt
- name: Download portable git
run: curl -L "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-64-bit.7z.exe" -o "PortableGit.7z"
- name: Extract PortableGit
run: 7z x PortableGit.7z -o./dist/.portable_git
- name: PortableGit before size
run: du -sh ./dist/.portable_git
- name: Prune unused PortableGit dirs
run: |
while read -r line; do
del_path="./dist/.portable_git/${line//$'\r'}" # Remove trailing carriage return
if [ -d "$del_path" ]; then
rm -rv "$del_path"
else
echo "Cannot find dir:$del_path"
ls -l "./dist/.portable_git"
ls -l "$del_path"
exit 1
fi
done < ./bundle_pruning/PortableGit_dirs.txt
- name: Prune unused PortableGit files
run: |
while read -r line; do
del_path="./dist/.portable_git/${line//$'\r'}" # Remove trailing carriage return
if [ -f "$del_path" ]; then
rm -v "$del_path"
else
echo "Cannot find file:$del_path"
ls -l "./dist/.portable_git"
ls -l "$del_path"
exit 1
fi
done < ./bundle_pruning/PortableGit_files.txt
- name: PortableGit after size
run: du -sh ./dist/.portable_git
- name: Copy sourcecode into dist
run: cp -rv OATFWGUI/ dist/
- name: Copy bootstrap script into dist
run: cp -v scripts/OATFWGUI_Windows.bat dist/
- name: Prune unused windows files
run: |
rm -v ./dist/.python_local/Lib/site-packages/PySide6/lupdate.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Quick*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Qml*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Sql*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*DBus*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/linguist.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/designer.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/qmllint.exe
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/translations
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/qml
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/include
- name: Smoke test
run: ./dist/OATFWGUI_Windows.bat --no-gui
- name: Retrieve version
id: version
run: echo "OATFWGUI_VERSION=$(./dist/OATFWGUI_Windows.bat --version | tail -1)" >> $GITHUB_ENV
- name: Output version
run: echo "Version is ${{ env.OATFWGUI_VERSION }}"
- name: Remove smoke test artifacts
run: |
rm -rv ./dist/logs
rm -rv ./dist/OATFWGUI/__pycache__
- name: Set artifact name
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}" >> $GITHUB_ENV
- name: Rename and Zip artifacts
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
env:
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_ZIP_NAME }}
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
build-virtualenv:
runs-on: 'ubuntu-20.04'
strategy:
matrix:
py_version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
cache: 'pip'
- name: Run set_version script
uses: ./.github/actions/run-set_version_script
# Fixes a bug when running the smoke test
# https://stackoverflow.com/a/67205123
- name: Install OpenGL
run: sudo apt-get install freeglut3 freeglut3-dev
- run: mkdir dist/
- run: cp -rv OATFWGUI/ dist/
- run: cp -v scripts/OATFWGUI_Linux.sh dist/
- run: cp -v requirements.txt dist/
- name: Smoke test
run: QT_QPA_PLATFORM=offscreen ./dist/OATFWGUI_Linux.sh --no-gui
- name: Retrieve version
id: version
run: echo "OATFWGUI_VERSION=$(./dist/OATFWGUI_Linux.sh --version | tail -1)" >> $GITHUB_ENV
- name: Output version
run: echo "Version is ${{ env.OATFWGUI_VERSION }}"
- name: Remove smoke test artifacts
run: |
rm -rv ./dist/logs
rm -rv ./dist/.venv_*
rm -rv ./dist/OATFWGUI/__pycache__
- name: Set artifact name
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}" >> $GITHUB_ENV
- name: Rename and Zip artifacts
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
env:
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
- name: Upload artifact
if: ${{ matrix.py_version }} == "3.10" # Only publish one artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_ZIP_NAME }}
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
publish-release:
# only publish release on tags
if: ${{ startsWith(github.ref, 'refs/tags/') == true }}
needs: [build-windows, build-virtualenv]
runs-on: 'ubuntu-20.04'
permissions:
# See https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Show artifact contents
run: |
tree .
for zip_dist in artifacts/*/*.zip; do
echo "$zip_dist contains:"
zip -sf $zip_dist
done
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
generate_release_notes: true
fail_on_unmatched_files: true
files: artifacts/*/*.zip