Build and Release #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| build_windows: | |
| description: 'Build Windows x64 executable' | |
| required: true | |
| default: true | |
| type: boolean | |
| build_linux: | |
| description: 'Build Linux x64 deb package' | |
| required: true | |
| default: true | |
| type: boolean | |
| create_release: | |
| description: 'Create GitHub Release' | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_windows == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyinstaller | |
| pip install -r requirements.txt | |
| - name: Build Windows executable | |
| run: | | |
| python build.py | |
| - name: Upload Windows artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AssignSticker-windows-x64 | |
| path: dist/AssignSticker.exe | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_linux == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyinstaller | |
| pip install -r requirements.txt | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y dpkg-dev fakeroot | |
| - name: Build Linux executable | |
| run: | | |
| pyinstaller --onefile --windowed --name assignsticker main.py | |
| - name: Prepare DEB package | |
| run: | | |
| mkdir -p release/deb/assignsticker/usr/local/bin | |
| mkdir -p release/deb/assignsticker/usr/share/assignsticker | |
| mkdir -p release/deb/assignsticker/usr/share/applications | |
| mkdir -p release/deb/assignsticker/DEBIAN | |
| # Copy executable | |
| cp dist/assignsticker release/deb/assignsticker/usr/local/bin/ | |
| chmod +x release/deb/assignsticker/usr/local/bin/assignsticker | |
| # Copy all project files (excluding unnecessary directories) | |
| for item in icons htmls saying desktop_widgets; do | |
| if [ -d "$item" ]; then | |
| cp -r "$item" release/deb/assignsticker/usr/share/assignsticker/ | |
| fi | |
| done | |
| for file in font.ttf icon.ico introduce banner.png LICENSE README.md; do | |
| if [ -f "$file" ]; then | |
| cp "$file" release/deb/assignsticker/usr/share/assignsticker/ | |
| fi | |
| done | |
| # Create desktop entry | |
| echo "[Desktop Entry]" > release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Name=AssignSticker" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Comment=Homework Kanban Application" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Exec=/usr/local/bin/assignsticker" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Icon=/usr/share/assignsticker/icon.ico" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Type=Application" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Categories=Education;Office;" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| echo "Terminal=false" >> release/deb/assignsticker/usr/share/applications/assignsticker.desktop | |
| # Create control file | |
| echo "Package: assignsticker" > release/deb/assignsticker/DEBIAN/control | |
| echo "Version: 1.3.0" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Section: education" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Priority: optional" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Architecture: amd64" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Depends: python3" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Maintainer: SECTL <sectl@example.com>" >> release/deb/assignsticker/DEBIAN/control | |
| echo "Description: Homework Kanban Application" >> release/deb/assignsticker/DEBIAN/control | |
| echo " AssignSticker is a homework management application" >> release/deb/assignsticker/DEBIAN/control | |
| echo " that helps users organize and track homework tasks." >> release/deb/assignsticker/DEBIAN/control | |
| # Build DEB package | |
| dpkg-deb --build release/deb/assignsticker | |
| mv release/deb/assignsticker.deb release/AssignSticker-linux-amd64.deb | |
| - name: Upload Linux artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AssignSticker-linux-amd64 | |
| path: release/AssignSticker-linux-amd64.deb | |
| release: | |
| needs: [build-windows, build-linux] | |
| runs-on: ubuntu-latest | |
| if: | | |
| always() && | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') || | |
| startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download Windows artifact | |
| if: needs.build-windows.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: AssignSticker-windows-x64 | |
| path: artifacts/windows | |
| - name: Download Linux artifact | |
| if: needs.build-linux.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: AssignSticker-linux-amd64 | |
| path: artifacts/linux | |
| - name: Prepare release files | |
| run: | | |
| mkdir -p release_files | |
| if [ -f artifacts/windows/AssignSticker.exe ]; then | |
| mv artifacts/windows/AssignSticker.exe release_files/ | |
| fi | |
| if [ -f artifacts/linux/AssignSticker-linux-amd64.deb ]; then | |
| mv artifacts/linux/AssignSticker-linux-amd64.deb release_files/ | |
| fi | |
| ls -la release_files/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: release_files/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |