Skip to content

Commit 307393a

Browse files
committed
chore: Do not use sed
1 parent 5c53951 commit 307393a

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

.github/recipes/io.github.mukonqi.nottodbox.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ modules:
2222
- name: nottodbox
2323
buildsystem: simple
2424
build-commands:
25-
- mkdir -p /app/share/applications
26-
- mkdir -p /app/share/icons/hicolor/scalable/apps
27-
- mkdir -p /app/share/metainfo
28-
- cp share/applications/io.github.mukonqi.nottodbox.desktop /app/share/applications
29-
- cp share/icons/hicolor/scalable/apps/io.github.mukonqi.nottodbox.svg /app/share/icons/hicolor/scalable/apps
30-
- cp share/metainfo/io.github.mukonqi.nottodbox.appdata.xml /app/share/metainfo
31-
- sed -i "s/APP_BUILD = .*/APP_BUILD = 'Flatpak'/" nottodbox/scripts/version.py
25+
- install -Dm644 share/applications/io.github.mukonqi.nottodbox.desktop -t /app/share/applications
26+
- install -Dm644 share/icons/hicolor/scalable/apps/io.github.mukonqi.nottodbox.svg -t /app/share/icons/hicolor/scalable/apps
27+
- install -Dm644 share/metainfo/io.github.mukonqi.nottodbox.appdata.xml -t /app/share/metainfo
28+
- python3 .github/scripts/consts.py --flatpak
3229
- cp .github/recipes/locale.py nottodbox/scripts/resources/locale.py # this line should be removed when https://github.com/flathub/io.qt.PySide.BaseApp/pull/25 pull request is merged
3330
# - python3 .github/scripts/translations.py # this line should be used when https://github.com/flathub/io.qt.PySide.BaseApp/pull/25 pull request is merged
3431
- pip3 install --no-build-isolation --no-deps --no-index --prefix=${FLATPAK_DEST} --verbose .

.github/scripts/consts.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import sys
3+
4+
with open(os.path.join("nottodbox", "scripts", "version.py")) as f_read:
5+
lines = f_read.readlines()
6+
7+
new_lines = []
8+
fount_app_build = False
9+
for line in lines:
10+
if line.startswith("APP_BUILD"):
11+
new_line = f'APP_BUILD = "{"Flatpak" if "--flatpak" in sys.argv else "AppImage" if os.environ.get("RUNNER_OS") == "Linux" else "PyInstaller"}"\n'
12+
new_lines.append(new_line)
13+
fount_app_build = True
14+
else:
15+
new_lines.append(line)
16+
17+
if not fount_app_build:
18+
new_lines.append(f'APP_BUILD = "{"Flatpak" if "--flatpak" in sys.argv else "AppImage" if os.environ.get("RUNNER_OS") == "Linux" else "PyInstaller"}"\n')
19+
20+
with open(os.path.join("nottodbox", "scripts", "version.py"), "w") as f_write:
21+
f_write.writelines(new_lines)

.github/scripts/pyinstaller.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1+
python3 .github/scripts/consts.py
2+
13
if [ "$RUNNER_OS" == "Linux" ]; then
2-
sed -i "s/APP_BUILD = .*/APP_BUILD = 'AppImage'/" nottodbox/scripts/version.py
34
pyinstaller --add-data 'nottodbox/color-schemes/:nottodbox/color-schemes' --add-data 'nottodbox/LICENSE.txt:nottodbox' -F -w -n nottodbox nottodbox/__main__.py
4-
55
elif [ "$RUNNER_OS" == "macOS" ]; then
6-
sed -i '' "s/APP_BUILD = .*/APP_BUILD = 'PyInstaller'/" nottodbox/scripts/version.py
7-
pyinstaller --add-data 'nottodbox/color-schemes/:nottodbox/color-schemes' --add-data 'nottodbox/LICENSE.txt:nottodbox' -D -w -i share/icons/pyinstaller/io.github.mukonqi.nottodbox.icns -n nottodbox nottodbox/__main__.py
8-
6+
pyinstaller --add-data 'nottodbox/color-schemes/:nottodbox/color-schemes' --add-data 'nottodbox/LICENSE.txt:nottodbox' -D -w -i share/icons/pyinstaller/io.github.mukonqi.nottodbox.icns -n nottodbox nottodbox/__main__.py
97
elif [ "$RUNNER_OS" == "Windows" ]; then
10-
sed -i "s/APP_BUILD = .*/APP_BUILD = 'PyInstaller'/" nottodbox/scripts/version.py
118
pyinstaller --add-data 'nottodbox/color-schemes/:nottodbox/color-schemes' --add-data 'nottodbox/LICENSE.txt:nottodbox' -F -w -i share/icons/pyinstaller/io.github.mukonqi.nottodbox.ico -n nottodbox nottodbox/__main__.py
129
fi

0 commit comments

Comments
 (0)