From 76ee0626919646e138c62f728c2f05696a52da8d Mon Sep 17 00:00:00 2001
From: 4sterisk <4sterisk@ymail.ne.jp>
Date: Thu, 17 Oct 2024 01:47:09 +0900
Subject: [PATCH] build deb

---
 .github/workflows/deb_deploy.yml | 74 ++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 .github/workflows/deb_deploy.yml

diff --git a/.github/workflows/deb_deploy.yml b/.github/workflows/deb_deploy.yml
new file mode 100644
index 000000000..cdba21f77
--- /dev/null
+++ b/.github/workflows/deb_deploy.yml
@@ -0,0 +1,74 @@
+name: デプロイ(deb)
+on:
+  workflow_dispatch:
+  release:
+    types: [published]
+
+env:
+    APP_NAME: 'miria'
+    MAINTAINER: 'name@example.com'
+    DESC: 'Miria is Misskey Client App for iOS, Android and many targets which made by Flutter.'
+
+permissions:
+    contents: write
+
+jobs:
+  build-debs:
+    runs-on: ubuntu-latest
+    steps:
+        - name: Clone repository
+          uses: actions/checkout@v4
+
+        - name: Get Flutter version from .fvmrc
+          run:  echo "FLUTTER_FVM_VERSION=$(jq -r .flutter .fvmrc)" >> $GITHUB_ENV
+  
+        - name: Install Flutter
+          uses: subosito/flutter-action@v2
+          with:
+            flutter-version: ${{ env.FLUTTER_FVM_VERSION }}
+            cache: true
+
+        - name: Patch for linux build
+          run: |
+            sudo apt-get update -y
+            sudo apt-get install -y ninja-build libgtk-3-dev libsecret-1-dev  libstdc++-12-dev git python3-pip nasm libasound2-dev libass-dev
+            sudo pip3 install meson
+        - name: Build libmpv
+          run: |
+            git clone https://github.com/mpv-player/mpv-build.git
+            cd mpv-build
+            sed -i 's/checkout_ffmpeg=master/checkout_ffmpeg=@f3eb622fc455cbef7b2fc9efacd82666e16ffd76/g' update
+            sed -i 's/checkout_libplacebo=master/checkout_libplacebo=@ed29e541a55acf28022738440b2a925386292551/g' update
+            sed -i 's/checkout_mpv=master/checkout_mpv=@140ec21c89d671d392877a7f3b91d67e7d7b9239/g' update
+            sed -i '/meson setup build -Dbuildtype=release \$OPTIONS "\$@"/s/^/#/' scripts/mpv-config
+            echo -e "\npython3 ./bootstrap.py\n./waf configure --disable-alsa --enable-libmpv-shared\n./waf build" >> scripts/mpv-config
+            ./rebuild -j4
+            sudo ./waf install
+
+        - run: flutter pub get
+        #- run: flutter test
+        - run: flutter build linux
+        - name: Get Build Version
+          run: |
+            echo "VERSION=$(yq -r '.version' pubspec.yaml)" >> $GITHUB_ENV
+
+        - name: Move files
+          run: |
+            mkdir -p .debpkg/opt/miria
+            cp -rp ./build/linux/x64/release/bundle/* .debpkg/opt/miria/
+
+        - name: Build DEB package
+          uses: jiro4989/build-deb-action@v3
+          with:
+            desc: '${{ env.DESC }}'
+            package: ${{ env.APP_NAME }}
+            maintainer: ${{ env.MAINTAINER }}
+            version: ${{ env.VERSION }}
+            arch: "amd64"
+            package_root: ".debpkg"
+            depends: "libgtk-3-0, libstdc++6, libx11-6, libmpv2, libsecret-1-0"
+        - uses: actions/upload-artifact@v4
+          with:
+            name: artifact-deb
+            path: |
+              ./*.deb
\ No newline at end of file