-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (118 loc) · 4.47 KB
/
package-build.yaml
File metadata and controls
136 lines (118 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build and Release
on:
push:
tags:
- "v*"
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: macos
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 pyinstaller
- name: Install package
run: |
pip install .
- 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 }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.os }}
path: |
dist/ecooptimizer-server-*
dist/ecooptimizer-server-dev-*
if-no-files-found: error
publish-pypi:
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build source distribution
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
create-release:
needs: [build, publish-pypi]
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 }} Test 1
body: |
${{ github.event.head_commit.message }}
**Artifacts:**
- Source distribution (.tar.gz) published to PyPI
- 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 }}