Skip to content

Commit

Permalink
Packaging (#1)
Browse files Browse the repository at this point in the history
* replace usage of .ui files with .py ones

* Add pipeline

* Add windwos release

* Add material for .deb packages

* Add .deb packaging

* Add icons to executables
  • Loading branch information
IZOBRETATEL777 authored Aug 21, 2021
1 parent 0099c31 commit af32cb6
Show file tree
Hide file tree
Showing 20 changed files with 1,260 additions and 44 deletions.
10 changes: 10 additions & 0 deletions .ci/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: bi-creator
Version: ${ver}
Installed-Size: ${size}
Maintainer: Roman Tolstosheyev <[email protected]>
Source: https://github.com/BreathOS/bi-creator
Homepage: https://breathos.github.io/
Depends: libc6 (>= 2.29)
Architecture: amd64
Priority: optional
Description: Suitcase creator
3 changes: 3 additions & 0 deletions .ci/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e
ln -fs /usr/share/bi-creator/bi-creator-linux /usr/bin/bi-creator
chmod a+x /usr/share/bi-creator/bi-creator-linux
Empty file added .ci/DEBIAN/preinst
Empty file.
2 changes: 2 additions & 0 deletions .ci/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
rm /usr/bin/bi-creator
11 changes: 11 additions & 0 deletions .ci/bi-creator.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Name=Bi Creator
Version=1.0
Exec=bi-creator
Comment=Suitcase Creator
Icon=bi-creator
Type=Application
Terminal=false
StartupNotify=true
Encoding=UTF-8
Categories=System;
674 changes: 674 additions & 0 deletions .ci/copyright

Large diffs are not rendered by default.

Binary file added .ci/icon.ico
Binary file not shown.
Binary file added .ci/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Release

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]

steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: Setup Python
uses: actions/[email protected]
with:
python-version: '3.7.9'

- name: Get the version
id: get_version
shell: bash
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo ::set-output name=VERSION::$VERSION
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -r requirements.txt
- name: Build Linux executable
if: matrix.os == 'ubuntu-20.04'
run: |
pyinstaller main.py --onefile --name bi-creator --icon=.ci/icon.ico
mv ${{ github.workspace }}/dist/bi-creator ${{ github.workspace }}/dist/bi-creator-linux
- name: Build .deb package
if: matrix.os == 'ubuntu-20.04'
run: |
pkgname="bi-creator-${{ steps.get_version.outputs.VERSION }}-amd64"
echo "::set-output name=pkgname::${pkgname}"
mkdir ${pkgname}/
cd ${pkgname}/
mkdir -p usr/share/applications/
cp ${{ github.workspace }}/.ci/bi-creator.desktop ./usr/share/applications/
mkdir -p ./usr/share/bi-creator
cp ${{ github.workspace }}/dist/bi-creator-linux ./usr/share/bi-creator
mkdir -p ./usr/share/doc/bi-creator
cp ${{ github.workspace }}/.ci/copyright ./usr/share/doc/bi-creator
mkdir -p usr/share/icons/
cp ${{ github.workspace }}/.ci/icon.png ./usr/share/icons/bi-creator.png
cd ${{ github.workspace }}/${pkgname}
cp -r ${{ github.workspace }}/.ci/DEBIAN .
sudo apt install md5deep
md5deep -rl usr/ > ./DEBIAN/md5sums
cd DEBIAN
chmod 775 p*
sed -i "s/\${ver}/${{ steps.get_version.outputs.VERSION }}/" control
SIZE=$(du -s ../../${pkgname}/ | cut -f1)
sed -i "s/\${size}/${SIZE}/" control
cd ${{ github.workspace }}/
fakeroot dpkg-deb --build ${pkgname}
- name: Build Windows executable
if: matrix.os == 'windows-2019'
run: |
pyinstaller main.py --onefile --name bi-creator --icon=.ci/icon.ico --noconsole
move ${{ github.workspace }}/dist/bi-creator.exe ${{ github.workspace }}/dist/bi-creator-win.exe
- name: Create Linux executable release
if: matrix.os == 'ubuntu-20.04'
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/dist/bi-creator-linux
name: Bi Creator ${{steps.get_version.outputs.VERSION}}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create .deb package release release
if: matrix.os == 'ubuntu-20.04'
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.deb
name: Bi Creator ${{steps.get_version.outputs.VERSION}}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Windows executable release
if: matrix.os == 'windows-2019'
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/dist/bi-creator-win.exe
name: Bi Creator ${{steps.get_version.outputs.VERSION}}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72 changes: 38 additions & 34 deletions MainWindow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from functools import partial

from PyQt6 import uic, QtCore
from forms.mainwindow import Ui_MainMenu
from forms.loadingscreen import Ui_LoadScreenWindow

from PyQt6 import QtCore
from PyQt6.QtWidgets import QMainWindow, QLabel, QPushButton, QFileDialog, QMessageBox, QWidget
from PyQt6.QtCore import QThread, Qt, pyqtSlot

Expand All @@ -16,27 +19,27 @@ class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.msg = LoadingScreen()
uic.loadUi('forms/mainwindow.ui', self)
self.show()
self.ui = Ui_MainMenu()
self.ui.setupUi(self)
self.packageElement = None
self.biPackage = None
self.creator = None
self.addButton.clicked.connect(self.addElement)
self.createPackageButton.clicked.connect(self.createPackage)
self.saveChangesButton.clicked.connect(self.saveChanges)
self.cancelButton.clicked.connect(self.cancel)
self.elementType.activated.connect(self.typeSelected)
self.ui.addButton.clicked.connect(self.addElement)
self.ui.createPackageButton.clicked.connect(self.createPackage)
self.ui.saveChangesButton.clicked.connect(self.saveChanges)
self.ui.cancelButton.clicked.connect(self.cancel)
self.ui.elementType.activated.connect(self.typeSelected)
self.worker = QThread()

def typeSelected(self):
curOption = self.elementType.currentText()
curOption = self.ui.elementType.currentText()
if curOption == 'Select type':
self.addButton.setEnabled(False)
self.ui.addButton.setEnabled(False)
else:
self.addButton.setEnabled(True)
self.ui.addButton.setEnabled(True)

def addElement(self):
curOption = self.elementType.currentText()
curOption = self.ui.elementType.currentText()
if curOption == 'File':
self.packageElement = FileController()
if curOption == 'Folder':
Expand All @@ -48,16 +51,16 @@ def addElement(self):

def createPackage(self):
self.biPackage = BiPackage()
self.elementType.setEnabled(True)
self.saveChangesButton.setEnabled(True)
self.cancelButton.setEnabled(True)
self.createPackageButton.setEnabled(False)
self.biPackageName.setEnabled(True)
self.biPackageVersion.setEnabled(True)
self.ui.elementType.setEnabled(True)
self.ui.saveChangesButton.setEnabled(True)
self.ui.cancelButton.setEnabled(True)
self.ui.createPackageButton.setEnabled(False)
self.ui.biPackageName.setEnabled(True)
self.ui.biPackageVersion.setEnabled(True)

def saveChanges(self):
name = self.biPackageName.text()
version = self.biPackageVersion.text()
name = self.ui.biPackageName.text()
version = self.ui.biPackageVersion.text()
if len(self.biPackage.getElements()) == 0:
QMessageBox().critical(self, "Error", "Suitcase cannot be empty")
elif not name or name.isspace():
Expand All @@ -81,39 +84,40 @@ def saveChanges(self):
self.worker.start()

def cancel(self):
self.elementType.setEnabled(False)
self.addButton.setEnabled(False)
self.saveChangesButton.setEnabled(False)
self.cancelButton.setEnabled(False)
self.createPackageButton.setEnabled(True)
self.biPackageName.setEnabled(False)
self.biPackageVersion.setEnabled(False)
self.elementType.setCurrentIndex(0)
self.ui.elementType.setEnabled(False)
self.ui.addButton.setEnabled(False)
self.ui.saveChangesButton.setEnabled(False)
self.ui.cancelButton.setEnabled(False)
self.ui.createPackageButton.setEnabled(True)
self.ui.biPackageName.setEnabled(False)
self.ui.biPackageVersion.setEnabled(False)
self.ui.elementType.setCurrentIndex(0)

def uploadPackageToGui(self):
for i in reversed(range(self.elements.count())):
self.elements.itemAt(i).widget().deleteLater()
for i in reversed(range(self.ui.elements.count())):
self.ui.elements.itemAt(i).widget().deleteLater()
elements = self.biPackage.getElements()
for i in range(len(elements)):
(elementType, element), = elements[i].items()
self.elements.addWidget(QLabel(element.description), i, 0)
self.ui.elements.addWidget(QLabel(element.description), i, 0)
btn = QPushButton('Remove')
btn.clicked.connect(partial(self.biPackage.deleteElement, i))
btn.clicked.connect(self.uploadPackageToGui)
self.elements.addWidget(btn, i, 1)
self.ui.elements.addWidget(btn, i, 1)

@pyqtSlot(Element)
def addElementGui(self, element):
self.biPackage.addElement(element)
self.uploadPackageToGui()
self.packageElement.newElement.disconnect()
self.elementType.setCurrentIndex(0)
self.ui.elementType.setCurrentIndex(0)


class LoadingScreen(QWidget):
def __init__(self):
super().__init__()
uic.loadUi('forms/loadingscreen.ui', self)
self.ui = Ui_LoadScreenWindow()
self.ui.setupUi(self)
self.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint |
Qt.WindowType.CustomizeWindowHint |
Qt.WindowType.FramelessWindowHint)
82 changes: 82 additions & 0 deletions forms/file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Form implementation generated from reading ui file 'file.ui'
#
# Created by: PyQt6 UI code generator 6.1.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_AddFileMenu(object):
def setupUi(self, AddFileMenu):
AddFileMenu.setObjectName("AddFileMenu")
AddFileMenu.resize(453, 216)
self.gridLayout = QtWidgets.QGridLayout(AddFileMenu)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.chooseFileButton = QtWidgets.QPushButton(AddFileMenu)
self.chooseFileButton.setObjectName("chooseFileButton")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.chooseFileButton)
self.filePath = QtWidgets.QLineEdit(AddFileMenu)
self.filePath.setObjectName("filePath")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.filePath)
self.label_2 = QtWidgets.QLabel(AddFileMenu)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_2)
self.destinationPath = QtWidgets.QLineEdit(AddFileMenu)
self.destinationPath.setObjectName("destinationPath")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.destinationPath)
self.label_4 = QtWidgets.QLabel(AddFileMenu)
self.label_4.setObjectName("label_4")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_4)
self.description = QtWidgets.QLineEdit(AddFileMenu)
self.description.setObjectName("description")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.FieldRole, self.description)
self.verticalLayout.addLayout(self.formLayout)
self.useHome = QtWidgets.QCheckBox(AddFileMenu)
self.useHome.setChecked(True)
self.useHome.setObjectName("useHome")
self.verticalLayout.addWidget(self.useHome)
self.isRequired = QtWidgets.QCheckBox(AddFileMenu)
self.isRequired.setChecked(True)
self.isRequired.setObjectName("isRequired")
self.verticalLayout.addWidget(self.isRequired)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.cancelButton = QtWidgets.QPushButton(AddFileMenu)
self.cancelButton.setObjectName("cancelButton")
self.horizontalLayout.addWidget(self.cancelButton)
self.addFile = QtWidgets.QPushButton(AddFileMenu)
self.addFile.setObjectName("addFile")
self.horizontalLayout.addWidget(self.addFile)
self.verticalLayout.addLayout(self.horizontalLayout)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

self.retranslateUi(AddFileMenu)
QtCore.QMetaObject.connectSlotsByName(AddFileMenu)

def retranslateUi(self, AddFileMenu):
_translate = QtCore.QCoreApplication.translate
AddFileMenu.setWindowTitle(_translate("AddFileMenu", "Add file"))
self.chooseFileButton.setText(_translate("AddFileMenu", "Choose file"))
self.label_2.setText(_translate("AddFileMenu", "Destination file"))
self.label_4.setText(_translate("AddFileMenu", "Description"))
self.useHome.setText(_translate("AddFileMenu", "Use home folder as root"))
self.isRequired.setText(_translate("AddFileMenu", "Required"))
self.cancelButton.setText(_translate("AddFileMenu", "Cancel"))
self.addFile.setText(_translate("AddFileMenu", "Add"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
AddFileMenu = QtWidgets.QWidget()
ui = Ui_AddFileMenu()
ui.setupUi(AddFileMenu)
AddFileMenu.show()
sys.exit(app.exec())
4 changes: 2 additions & 2 deletions forms/file.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<class>AddFileMenu</class>
<widget class="QWidget" name="AddFileMenu">
<property name="geometry">
<rect>
<x>0</x>
Expand Down
Loading

0 comments on commit af32cb6

Please sign in to comment.