fresh-editor 0.1.43

A lightweight, fast terminal-based text editor with LSP support and TypeScript plugins
Documentation
# Linux packaging workflow - builds .deb and .rpm packages

name: Linux Packages

on:
  workflow_call:
  workflow_dispatch:

jobs:
  # Build .deb and .rpm packages for Linux
  build-linux-packages:
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            arch: amd64
            rpm_arch: x86_64
            runner: ubuntu-22.04
          - target: aarch64-unknown-linux-gnu
            arch: arm64
            rpm_arch: aarch64
            runner: ubuntu-22.04
    runs-on: ${{ matrix.runner }}
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
          submodules: recursive

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Install cargo-deb and cargo-generate-rpm
        run: |
          cargo install cargo-deb cargo-generate-rpm

      - name: Build release binary
        run: |
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
            export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
          fi
          cargo build --release --target ${{ matrix.target }}

      - name: Strip binary to reduce size
        run: |
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
            aarch64-linux-gnu-strip target/${{ matrix.target }}/release/fresh
          else
            strip target/${{ matrix.target }}/release/fresh
          fi
          ls -la target/${{ matrix.target }}/release/fresh

      - name: Build .deb package
        run: |
          cargo deb --no-build --target ${{ matrix.target }}

      - name: Build .rpm package
        run: |
          cargo generate-rpm --target ${{ matrix.target }}

      - name: Rename packages with architecture suffix
        run: |
          mkdir -p packages
          # Find and copy deb package
          find target/${{ matrix.target }}/debian -name "*.deb" -exec cp {} packages/ \;
          # Find and copy rpm package
          find target/${{ matrix.target }}/generate-rpm -name "*.rpm" -exec cp {} packages/ \;
          ls -la packages/

      - name: Upload Linux packages
        uses: actions/upload-artifact@v5
        with:
          name: artifacts-linux-packages-${{ matrix.arch }}
          path: packages/*

  # Test .deb package installation on multiple Ubuntu versions
  test-deb-package:
    needs:
      - build-linux-packages
    strategy:
      fail-fast: false
      matrix:
        include:
          - distro: ubuntu:22.04
            name: Ubuntu 22.04
          - distro: ubuntu:24.04
            name: Ubuntu 24.04
          - distro: debian:12
            name: Debian 12
    runs-on: ubuntu-22.04
    container:
      image: ${{ matrix.distro }}
    env:
      DEBIAN_FRONTEND: noninteractive
    steps:
      - name: Download .deb package
        uses: actions/download-artifact@v4
        with:
          name: artifacts-linux-packages-amd64
          path: packages/

      - name: Install .deb package
        run: |
          apt-get update
          apt-get install -y ./packages/*.deb

      - name: Verify installation
        run: |
          echo "=== Testing on ${{ matrix.name }} ==="

          echo ""
          echo "=== Checking installed files ==="
          dpkg -L fresh-editor

          echo ""
          echo "=== Testing binary ==="
          fresh --version

          echo ""
          echo "=== Checking plugins directory ==="
          ls -la /usr/share/fresh-editor/plugins/
          ls -la /usr/share/fresh-editor/plugins/lib/

          echo ""
          echo "=== Testing uninstall ==="
          apt-get remove -y fresh-editor

          echo ""
          echo "deb package test PASSED on ${{ matrix.name }}"

  # Test .rpm package installation on multiple Fedora/RHEL versions
  test-rpm-package:
    needs:
      - build-linux-packages
    strategy:
      fail-fast: false
      matrix:
        include:
          - distro: fedora:39
            name: Fedora 39
          - distro: fedora:40
            name: Fedora 40
          - distro: rockylinux:9
            name: Rocky Linux 9
    runs-on: ubuntu-22.04
    container:
      image: ${{ matrix.distro }}
    steps:
      - name: Download .rpm package
        uses: actions/download-artifact@v4
        with:
          name: artifacts-linux-packages-amd64
          path: packages/

      - name: Install .rpm package
        run: |
          dnf install -y packages/*.rpm

      - name: Verify installation
        run: |
          echo "=== Testing on ${{ matrix.name }} ==="

          echo ""
          echo "=== Checking installed files ==="
          rpm -ql fresh-editor

          echo ""
          echo "=== Testing binary ==="
          fresh --version

          echo ""
          echo "=== Checking plugins directory ==="
          ls -la /usr/share/fresh-editor/plugins/
          ls -la /usr/share/fresh-editor/plugins/lib/

          echo ""
          echo "=== Testing uninstall ==="
          dnf remove -y fresh-editor

          echo ""
          echo "rpm package test PASSED on ${{ matrix.name }}"