Add snap build/publish to CI and dynamic version extraction #42
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 | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| app_version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: get_version | |
| run: | | |
| VERSION=$(python3 -c "import re; m=re.search(r'APP_VERSION\s*=\s*\"(.+?)\"', open('src/utils/constants.py').read()); print(m.group(1))") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| build-linux: | |
| needs: version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libxcb-cursor0 | |
| pip install -r requirements.txt pyinstaller | |
| - name: Build GUI and CLI | |
| run: python build.py build-all | |
| - name: Create release archive | |
| run: | | |
| mkdir -p Merisio-linux-x64 | |
| cp dist/Merisio Merisio-linux-x64/ | |
| cp dist/merisio-cli Merisio-linux-x64/ | |
| cp README.md Merisio-linux-x64/ | |
| cp merisio.desktop Merisio-linux-x64/ | |
| cp resources/icons/app_icon.png Merisio-linux-x64/ | |
| cp -r man Merisio-linux-x64/ | |
| tar -czvf Merisio-linux-x64.tar.gz Merisio-linux-x64/ | |
| - name: Create .deb package | |
| run: | | |
| mkdir -p merisio-deb/DEBIAN | |
| mkdir -p merisio-deb/usr/bin | |
| mkdir -p merisio-deb/usr/share/applications | |
| mkdir -p merisio-deb/usr/share/icons/hicolor/256x256/apps | |
| mkdir -p merisio-deb/usr/share/man/man1 | |
| cat > merisio-deb/DEBIAN/control << EOF | |
| Package: merisio | |
| Version: ${{ needs.version.outputs.app_version }} | |
| Section: database | |
| Priority: optional | |
| Architecture: amd64 | |
| Maintainer: Achraf SOLTANI <achraf.soltani@pm.me> | |
| Description: MERISE Database Modeling Tool | |
| Merisio is a modern MERISE database modeling application. | |
| It allows you to create MCD diagrams, generate MLD views, | |
| and export SQL scripts for PostgreSQL databases. | |
| . | |
| Includes merisio-cli for headless validation, SQL generation, | |
| MLD inspection, and diagram export from .merisio project files. | |
| Homepage: https://github.com/AchrafSoltani/Merisio | |
| EOF | |
| # Remove leading spaces from control file | |
| sed -i 's/^ //' merisio-deb/DEBIAN/control | |
| cp dist/Merisio merisio-deb/usr/bin/merisio | |
| chmod 755 merisio-deb/usr/bin/merisio | |
| cp dist/merisio-cli merisio-deb/usr/bin/merisio-cli | |
| chmod 755 merisio-deb/usr/bin/merisio-cli | |
| cp resources/icons/app_icon.png merisio-deb/usr/share/icons/hicolor/256x256/apps/merisio.png | |
| cp man/merisio.1 merisio-deb/usr/share/man/man1/merisio.1 | |
| cp man/merisio-cli.1 merisio-deb/usr/share/man/man1/merisio-cli.1 | |
| cat > merisio-deb/usr/share/applications/merisio.desktop << EOF | |
| [Desktop Entry] | |
| Name=Merisio | |
| Comment=MERISE Database Modeling Tool | |
| Exec=/usr/bin/merisio | |
| Icon=merisio | |
| Terminal=false | |
| Type=Application | |
| Categories=Development;Database; | |
| Keywords=database;modeling;merise;mcd;sql; | |
| EOF | |
| # Remove leading spaces from desktop file | |
| sed -i 's/^ //' merisio-deb/usr/share/applications/merisio.desktop | |
| dpkg-deb --build merisio-deb merisio_${{ needs.version.outputs.app_version }}_amd64.deb | |
| - name: Upload Linux artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: merisio-linux | |
| path: | | |
| Merisio-linux-x64.tar.gz | |
| merisio_${{ needs.version.outputs.app_version }}_amd64.deb | |
| build-windows: | |
| needs: version | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt pyinstaller pillow | |
| - name: Create .ico file | |
| run: | | |
| python -c "from PIL import Image; img = Image.open('resources/icons/app_icon.png'); img.save('resources/icons/app_icon.ico', format='ICO', sizes=[(256,256), (128,128), (64,64), (48,48), (32,32), (16,16)])" | |
| - name: Build GUI and CLI | |
| run: python build.py build-all | |
| - name: Create release archive | |
| run: | | |
| mkdir Merisio-windows-x64 | |
| copy dist\Merisio.exe Merisio-windows-x64\ | |
| copy dist\merisio-cli.exe Merisio-windows-x64\ | |
| copy README.md Merisio-windows-x64\ | |
| Compress-Archive -Path Merisio-windows-x64 -DestinationPath Merisio-windows-x64.zip | |
| - name: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: merisio-windows | |
| path: Merisio-windows-x64.zip | |
| build-snap: | |
| needs: version | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build snap | |
| uses: snapcore/action-build@v1 | |
| id: snapcraft | |
| - name: Upload snap artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: merisio-snap | |
| path: ${{ steps.snapcraft.outputs.snap }} | |
| release: | |
| needs: [version, build-linux, build-windows, build-snap] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download Linux artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: merisio-linux | |
| - name: Download Windows artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: merisio-windows | |
| - name: Download Snap artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: merisio-snap | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| Merisio-linux-x64.tar.gz | |
| merisio_${{ needs.version.outputs.app_version }}_amd64.deb | |
| Merisio-windows-x64.zip | |
| *.snap | |
| generate_release_notes: true | |
| publish-snap: | |
| needs: [build-snap] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download Snap artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: merisio-snap | |
| - name: Publish to Snap Store | |
| uses: snapcore/action-publish@v1 | |
| env: | |
| SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_TOKEN }} | |
| with: | |
| snap: merisio_*.snap | |
| release: stable |