Skip to content

Commit 4449c8f

Browse files
authored
New GUI with automatic builds (#1)
* imported OoliteDebugConsole2-03.zip from https://bb.oolite.space/viewtopic.php?p=295750#p295750 * add first draft of build script * Add Windows build * Add MacOS build * rename builds
1 parent fb9473e commit 4449c8f

21 files changed

+4745
-1208
lines changed

.github/workflows/build.yml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
# This workflow will build a python project with pyinstaller
2+
3+
name: build
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
# branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
semver:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
GITVERSION_SEMVER: ${{ steps.gitversion.outputs.SemVer }}
17+
GITVERSION_ASSEMBLYSEMVER: "${{ steps.gitversion.outputs.AssemblySemVer }}"
18+
GITVERSION_MAJORMINORPATCH: "${{ steps.gitversion.outputs.MajorMinorPatch }}"
19+
GITVERSION_MAJOR: ${{ steps.gitversion.outputs.GITVERSION_MAJOR }}
20+
GITVERSION_MINOR: ${{ steps.gitversion.outputs.GITVERSION_MINOR }}
21+
GITVERSION_PATCH: ${{ steps.gitversion.outputs.GITVERSION_PATCH }}
22+
MACOS_MAJORMINORPATCH: ${{ steps.output1.outputs.MACOS_MAJORMINORPATCH }}
23+
DEBIAN_PKGVERSION: ${{ steps.output1.outputs.DEBIAN_PKGVERSION }}
24+
steps:
25+
- name: Checkout project
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Install GitVersion
31+
uses: gittools/actions/gitversion/setup@v0
32+
with:
33+
versionSpec: '5.x'
34+
35+
- name: Determine Version
36+
id: gitversion
37+
uses: gittools/actions/gitversion/execute@v0
38+
39+
- id: output1
40+
run: |
41+
set -x
42+
printenv | grep GitVersion_ | sort
43+
echo "GITVERSION_SEMVER=${GitVersion_SemVer}" >> "$GITHUB_OUTPUT"
44+
echo "GITVERSION_ASSEMBLYSEMVER=${GitVersion_AssemblySemVer}" >> "$GITHUB_OUTPUT"
45+
echo "GITVERSION_MAJORMINORPATCH=${GitVersion_MajorMinorPatch}" >> "$GITHUB_OUTPUT"
46+
echo "GITVERSION_MAJOR=${GitVersion_Major}" >> "$GITHUB_OUTPUT"
47+
echo "GITVERSION_MINOR=${GitVersion_Minor}" >> "$GITHUB_OUTPUT"
48+
echo "GITVERSION_PATCH=${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
49+
echo "DEBIAN_PKGVERSION=${GitVersion_Major}.${GitVersion_Minor}-${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
50+
if [ "${GitVersion_Major}" == "0" ]
51+
then
52+
echo "MACOS_MAJORMINORPATCH=1.${GitVersion_Minor}.${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "MACOS_MAJORMINORPATCH=${GitVersion_MajorMinorPatch}" >> "$GITHUB_OUTPUT"
55+
fi
56+
57+
package-linux:
58+
needs: [semver]
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Checkout project
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
67+
- name: setup pyenv
68+
run: |
69+
sudo apt-get install python3-tk python3-venv python3-pip
70+
venv="$HOME/python3/pyinstaller"
71+
rm -Rf "$venv" # uncomment to make fresh venv.
72+
python3 -m venv "$venv"
73+
source "${venv}"/bin/activate
74+
pip install pyinstaller
75+
pip install twisted
76+
77+
- name: Build using pyinstaller
78+
run: |
79+
venv="$HOME/python3/pyinstaller"
80+
source "${venv}"/bin/activate
81+
pyinstaller \
82+
--onefile \
83+
--add-binary "oojsc.xbm:." \
84+
--add-binary "OoJSC.ico:." \
85+
DebugConsole.py
86+
87+
- name: create archive
88+
run: |
89+
tar cvfz Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-linux.tgz dist/
90+
91+
- uses: actions/upload-artifact@v4
92+
with:
93+
name: Oolite-Debug-Console-Ubuntu
94+
path: ./Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-linux.tgz
95+
96+
package-windows:
97+
needs: [semver]
98+
runs-on: windows-latest
99+
steps:
100+
- name: Checkout project
101+
uses: actions/checkout@v4
102+
with:
103+
fetch-depth: 0
104+
105+
- name: Install pyinstaller
106+
run: |
107+
pip install -U pyinstaller
108+
pip install -U twisted
109+
pip install -U pywin32
110+
111+
# in Windows PowerShell the backtick indicates a multiline command
112+
# see https://stackoverflow.com/questions/3235850/how-to-enter-a-multi-line-command
113+
- name: Build using pyinstaller
114+
run: |
115+
pyinstaller `
116+
--noconfirm `
117+
--clean `
118+
--log-level=WARN `
119+
--onefile `
120+
--name OoDebugConsole `
121+
--add-binary "OoJSC.ico:." `
122+
--add-binary "oojsc.xbm:." `
123+
--noconsole `
124+
--icon=OoJSC.ico `
125+
DebugConsole.py
126+
127+
# --version-file=OoDebug_version_info.txt `
128+
# --paths "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86" `
129+
# --noupx `
130+
131+
- name: check filesystem
132+
run: |
133+
Get-ChildItem -Path "$env:GITHUB_WORKSPACE" –Recurse
134+
135+
- name: create archive
136+
run: |
137+
7z a -tzip -r -wdist Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-win.zip dist\*
138+
139+
- uses: actions/upload-artifact@v4
140+
with:
141+
name: Oolite-Debug-Console-Windows
142+
path: Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-win.zip
143+
144+
package-macos:
145+
needs: [semver]
146+
runs-on: macos-latest
147+
148+
steps:
149+
- name: Checkout project
150+
uses: actions/checkout@v4
151+
with:
152+
fetch-depth: 0
153+
154+
- name: Install pyinstaller
155+
run: |
156+
pip install -U pyinstaller
157+
158+
- name: Build using pyinstaller
159+
run: |
160+
pyinstaller \
161+
--onefile \
162+
--add-binary "oojsc.xbm:." \
163+
--add-binary "OoJSC.ico:." \
164+
DebugConsole.py
165+
166+
- name: create archive
167+
run: |
168+
tar cvfz Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-macos.tgz dist/
169+
170+
- uses: actions/upload-artifact@v4
171+
with:
172+
name: Oolite-Debug-Console-MacOs
173+
path: ./Oolite-Debug-Console-${{ needs.semver.outputs.GITVERSION_SEMVER }}-macos.tgz
174+
175+
release:
176+
needs: [semver,package-linux,package-windows,package-macos]
177+
runs-on: ubuntu-latest
178+
179+
steps:
180+
- name: Download artifacts
181+
uses: actions/download-artifact@v4
182+
with:
183+
path: artifacts
184+
185+
- name: Check status
186+
run: |
187+
set
188+
echo -n "Current directory: "
189+
pwd
190+
find . -not -path "./oolitestarter/.git/*"
191+
192+
- name: Remove old prereleases
193+
if: github.ref != 'refs/heads/master'
194+
uses: dev-drprasad/[email protected]
195+
with:
196+
#repo: <owner>/<repoName> # defaults to current repo
197+
keep_latest: 6
198+
delete_tag_pattern: v\d+\.\d+\.\d+-.*
199+
delete_prerelease_only: 'true'
200+
#delete_branch: '${{ github.ref_name }}'
201+
env:
202+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
203+
204+
- name: Create Prerelease
205+
if: github.ref != 'refs/heads/master'
206+
id: create_prerelease
207+
uses: "marvinpinto/action-automatic-releases@latest"
208+
with:
209+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
210+
automatic_release_tag: "v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
211+
prerelease: true
212+
title: "Debug Console v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
213+
files: |
214+
artifacts/Oolite-Debug-Console-Ubuntu/*.tgz
215+
artifacts/Oolite-Debug-Console-Windows/*.zip
216+
artifacts/Oolite-Debug-Console-MacOs/*.tgz
217+
218+
- name: Remove old releases
219+
if: github.ref == 'refs/heads/master'
220+
uses: dev-drprasad/[email protected]
221+
with:
222+
#repo: <owner>/<repoName> # defaults to current repo
223+
keep_latest: 4
224+
delete_tag_pattern: v\d+\.\d+\.\d+
225+
delete_prerelease_only: 'false'
226+
#delete_branch: 'main'
227+
env:
228+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
229+
230+
- name: Create Release
231+
if: github.ref == 'refs/heads/master'
232+
id: create_release
233+
uses: "marvinpinto/action-automatic-releases@latest"
234+
with:
235+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
236+
automatic_release_tag: "v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
237+
prerelease: false
238+
title: "Debug Console v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
239+
files: |
240+
artifacts/Oolite-Debug-Console-Ubuntu/*.tgz
241+
artifacts/Oolite-Debug-Console-Windows/*.zip
242+
artifacts/Oolite-Debug-Console-MacOs/*.tgz
243+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ Icon?
99
# Python cruft
1010
*.pyc
1111
*.pyo
12+
13+
# pyinstaller cruft
14+
*.spec
15+
build/
16+
dist/

0 commit comments

Comments
 (0)