Skip to content

ci: change python build tool with pyinstaller #102

ci: change python build tool with pyinstaller

ci: change python build tool with pyinstaller #102

Workflow file for this run

name: GitHub Actions Build
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build_and_pack:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Get pip cache dir
id: pip-cache
run: echo "dir=$(pip cache dir)" >> ${env:GITHUB_OUTPUT}
- name: pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: install python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies
- run: mkdir OTB-9.0.0-Win64
- name: Get otb cache directory
id: otb-cache
shell: pwsh
run: echo "dir=$(pwd)\OTB-9.0.0-Win64" >> ${env:GITHUB_OUTPUT}
- name: otb cache
uses: actions/cache@v3
with:
path: ${{ steps.otb-cache.outputs.dir }}
key: ${{ runner.os }}-otb-${{ hashFiles('**/main.py') }}
restore-keys: |
${{ runner.os }}-otb-
- if: ${{ steps.otb-cache.outputs.cache-hit != 'true'}}
name: download OTB-9.0.0-Win64.zip
uses: gamedev-thingy/Download-Extract@done
with:
url: https://www.orfeo-toolbox.org/packages/OTB-9.0.0-Win64.zip
destination: OTB-9.0.0-Win64
ZIPname: OTB-9.0.0-Win64
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.
# node-version: 20.x
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
architecture: package.json
# Set this option if you want the action to check for the latest available version that satisfies the version spec.
check-latest: true
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
cache: npm
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.
cache-dependency-path: package-lock.json
- name: Get npm cache directory
id: npm-cache-dir
shell: pwsh
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
- name: npm cache
uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: building and pack
run: |
pip install -r requirements.txt
pip install pyinstaller
pyinstaller main.py
npm install
npm run pack
cp -r "dist/main" "."
ren "main" "bin"
cp -r "bin" "dist/win-unpacked"
cp -r "OTB-9.0.0-Win64" "dist/win-unpacked/bin"
cp -r "data" "dist/win-unpacked/bin"
dir
dir dist
dir "dist/win-unpacked"
dir "dist/win-unpacked/bin"
cd dist/win-unpacked/
7z a -tzip GaoFen-Batch.zip .
- name: Upload
uses: actions/upload-artifact@v4
with:
# Artifact name
name: GaoFen-Batch
# A file, directory or wildcard pattern that describes what to upload
path: "dist/win-unpacked/Gaofen-Batch.zip"