Skip to content

Added back in the package install step #8

Added back in the package install step

Added back in the package install step #8

Workflow file for this run

name: Build and Release
on:
push:
branches: [build-sign-test]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: linux
- os: windows-latest
artifact_name: win32.exe
- os: macos-latest
artifact_name: darwin
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: ${{ runner.os == 'Windows' && 'x64' || '' }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build pyinstaller
- name: Install package
run: |
pip install .
- name: Build Python package
run: |
python -m build
mkdir -p dist_python
mv dist/*.whl dist/*.tar.gz dist_python/ 2>/dev/null || true
- name: Create Linux executable
if: matrix.os == 'ubuntu-latest'
run: |
pyinstaller --onefile --name ecooptimizer-server $(which eco-ext)
mv dist/ecooptimizer-server dist/ecooptimizer-server-${{ matrix.artifact_name }}
pyinstaller --onefile --name ecooptimizer-server-dev $(which eco-ext-dev)
mv dist/ecooptimizer-server-dev dist/ecooptimizer-server-dev-${{ matrix.artifact_name }}
- name: Create Windows executable
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$entryProd = python -c "from importlib.metadata import entry_points; print([ep.value for ep in entry_points()['console_scripts'] if ep.name == 'eco-ext'][0])"
$pyPathProd = $entryProd.Split(':')[0].Replace('.', '\') + '.py'
$entryDev = python -c "from importlib.metadata import entry_points; print([ep.value for ep in entry_points()['console_scripts'] if ep.name == 'eco-ext-dev'][0])"
$pyPathDev = $entryDev.Split(':')[0].Replace('.', '\') + '.py'
pyinstaller --onefile --name ecooptimizer-server "src/$pyPathProd"
Move-Item dist\ecooptimizer-server.exe "dist\ecooptimizer-server-${{ matrix.artifact_name }}"
pyinstaller --onefile --name ecooptimizer-server-dev "src/$pyPathDev"
Move-Item dist\ecooptimizer-server-dev.exe "dist\ecooptimizer-server-dev-${{ matrix.artifact_name }}"
- name: Create macOS executable
if: matrix.os == 'macos-latest'
run: |
pyinstaller --onefile --name ecooptimizer-server $(which eco-ext)
mv dist/ecooptimizer-server dist/ecooptimizer-server-${{ matrix.artifact_name }}
pyinstaller --onefile --name ecooptimizer-server-dev $(which eco-ext-dev)
mv dist/ecooptimizer-server-dev dist/ecooptimizer-server-dev-${{ matrix.artifact_name }}
# Upload both Python package artifacts and executables
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.os }}
path: |
dist/ecooptimizer-server-*
dist/ecooptimizer-server-dev-*
dist_python/*.whl
dist_python/*.tar.gz
if-no-files-found: error
create-release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: false
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref_name }}
body: |
${{ github.event.head_commit.message }}
**Artifacts:**
- Python package: .whl and .tar.gz files
- Executables for Windows, macOS, and Linux
files: |
artifacts/artifacts-ubuntu-latest/*
artifacts/artifacts-windows-latest/*
artifacts/artifacts-macos-latest/*
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}