Add build version when packaging.

This commit is contained in:
Matthew Stratford 2021-04-11 19:02:19 +01:00
parent 2bc61be133
commit d511f1774d
8 changed files with 61 additions and 26 deletions

View file

@ -1,11 +1,18 @@
#!/bin/bash
cd "$(dirname "$0")"
build_commit="$(git rev-parse --short HEAD)"
echo "$build_commit"
sed -i "s/BUILD_COMMIT/$build_commit/" ../config.py
apt install libportaudio2
python3 -m venv ../venv
source ../venv/bin/activate
pip3 install -r requirements.txt
pip3 install -r requirements-linux.txt
pip3 install -e ..\
pip3 install -e ../
python3 ./generate-build-exe-config.py

View file

@ -1,6 +1,13 @@
#!/bin/bash
cd "$(dirname "$0")"
build_commit="$(git rev-parse --short HEAD)"
echo "$build_commit"
sed -i '' -e "s/BUILD_COMMIT/$build_commit/" "../config.py"
python3 -m venv ../venv
source ../venv/bin/activate
pip3 install -r requirements.txt
pip3 install -r requirements-macos.txt
pip3 install -e ..\
@ -16,6 +23,3 @@ rm ./*.spec
brew install platypus
platypus --load-profile ./BAPSicle.platypus --overwrite ./output/BAPSicle.app
mkdir ./output/state
mkdir ./output/logs
mkdir ./output/music-tmp

View file

@ -1,4 +1,15 @@
cd /D "%~dp0"
: Get the git commit and write it into config.py.
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO (
SET build_commit=%%F
)
(Get-Content "..\config.py") -replace 'BUILD_COMMIT', '%build_commit%' | Out-File -encoding ASCII "..\config.py"
py -m venv ..\venv
..\venv\Scripts\activate
pip install -r requirements.txt
pip install -r requirements-windows.txt
pip install -e ..\
@ -15,4 +26,4 @@ build-exe-pyinstaller-command.bat
del *.spec /q
echo "Output file should be located in 'output/' folder."
TIMEOUT 5
TIMEOUT 5

0
build/install-ubuntu.sh Normal file → Executable file
View file

0
build/macos-platypus.sh Normal file → Executable file
View file

View file

@ -1,2 +1,3 @@
# BAPSicle Details
VERSION: float = 0.1
VERSION: str = "0.1.0"
BUILD: str = "2bc61be"

View file

@ -27,7 +27,7 @@ import logging
from player_handler import PlayerHandler
from helpers.os_environment import isMacOS
from helpers.os_environment import isBundelled, isMacOS
from helpers.device_manager import DeviceManager
if not isMacOS():
@ -48,15 +48,16 @@ class BAPSicleServer:
startServer()
def __del__(self):
stopServer()
# def __del__(self):
# stopServer()
def get_flask(self):
return app
default_state = {
"server_version": 0,
"server_version": config.VERSION,
"server_build": config.BUILD,
"server_name": "URY BAPSicle",
"host": "localhost",
"port": 13500,
@ -64,7 +65,7 @@ default_state = {
"num_channels": 3,
"serial_port": None,
"ser_connected": False,
"api_key": None,
"myradio_api_key": None,
"myradio_base_url": "https://ury.org.uk/myradio",
"myradio_api_url": "https://ury.org.uk/api"
}
@ -104,7 +105,8 @@ def ui_index():
data = {
"ui_page": "index",
"ui_title": "",
"server_version": config.VERSION,
"server_version": state.state["server_version"],
"server_build": state.state["server_build"],
"server_name": state.state["server_name"],
}
return render_template("index.html", data=data)
@ -467,10 +469,10 @@ def clear_all_channels():
@app.route("/logs")
def list_logs():
data = {
"ui_page": "loglist",
"ui_page": "logs",
"ui_title": "Logs",
"logs": ["BAPSicleServer"]
+ ["channel{}".format(x) for x in range(state.state["num_channels"])],
+ ["Player{}".format(x) for x in range(state.state["num_channels"])],
}
return render_template("loglist.html", data=data)
@ -480,7 +482,7 @@ def send_logs(path):
log_file = open("logs/{}.log".format(path))
data = {
"logs": log_file.read().splitlines(),
"ui_page": "log",
"ui_page": "logs",
"ui_title": "Logs - {}".format(path),
}
log_file.close()
@ -507,7 +509,13 @@ def startServer():
logger = LoggingManager("BAPSicleServer")
state = StateManager("BAPSicleServer", logger, default_state)
# TODO: Check these match, if not, trigger any upgrade noticies / welcome
state.update("server_version", config.VERSION)
if isBundelled():
build = config.BUILD
else:
build = "Dev"
state.update("server_build", build)
if isMacOS():
multiprocessing.set_start_method("spawn", True)
@ -610,19 +618,21 @@ def startServer():
def stopServer():
global channel_p, channel_from_q, channel_to_q, websockets_server, webserver, controller_handler
global channel_p, channel_from_q, channel_to_q, websockets_server, controller_handler, webserver
print("Stopping Controllers")
controller_handler.terminate()
controller_handler.join()
if controller_handler:
controller_handler.terminate()
controller_handler.join()
print("Stopping Websockets")
websocket_to_q[0].put("WEBSOCKET:QUIT")
websockets_server.join()
del websockets_server
if websockets_server:
websockets_server.join()
del websockets_server
print("Stopping server.py")
for q in channel_to_q:
q.put("QUIT")
q.put("ALL:QUIT")
for channel in channel_p:
try:
channel.join()
@ -636,9 +646,10 @@ def stopServer():
print("Stopped all players.")
print("Stopping webserver")
global webserver
webserver.terminate()
webserver.join()
if webserver:
webserver.terminate()
webserver.join()
print("Stopped webserver")

View file

@ -17,9 +17,10 @@
Open WebStudio
</a>
<hr>
<p>Version: {{data.server_version}} | Server Name: {{data.server_name}}</p>
<p>Version: {{data.server_version}} - Build: {{data.server_build}}</p>
<p>Server Name: {{data.server_name}}</p>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}