GitHub Actions Build #75
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: GitHub Actions Build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
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 | |
- name: install python dependents | |
run: | | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- run: | |
pyinstaller main.py | |
- 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- | |
- run: | | |
npm install | |
npm run pack | |
- name: Build/release Electron app | |
uses: paneron/action-electron-builder@v1.8.1 | |
with: | |
# GitHub token, automatically provided to the action | |
# (No need to define this secret in the repo settings) | |
github_token: ${{ secrets.github_token }} | |
package_manager: npm | |
# If the commit is tagged with a version (e.g. "v1.0.0"), | |
# release the app after building | |
# release: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
release: false | |
- name: package asst | |
shell: cmd | |
run: | | |
mkdir "dist/win-unpacked/bin/OTB-9.0.0-Win64" | |
cp -r "data" "build/main/data" | |
cd build | |
ren main bin | |
cd .. | |
cp -r "build/bin" "dist/win-unpacked/" | |
cp -r "OTB-9.0.0-Win64" "dist/win-unpacked/bin" | |
dir dist | |
dir "dist/win-unpacked" | |
dir "dist/win-unpacked/bin" | |
- name: zip files | |
run: | | |
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" | |