Browse Source

1,调整,workflows 触发的条件
2,支持,VAD CGO=1 的编译
3,添加,ffmpeg 的支持

Signed-off-by: allan716 <[email protected]>

allan716 4 years ago
parent
commit
4c3c2d15a7

+ 48 - 0
.github/workflows/Build ChineseSubFinder DockerImage-Beta.yml

@@ -0,0 +1,48 @@
+name: Build ChineseSubFinder DockerImage-Beta
+
+on:
+  push:
+    tags:
+      - v*.*-Beta*
+      - v*.*-DockerBeta*
+  workflow_dispatch:
+
+jobs:
+  buildx:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+      # 获取 tag 版本
+      - name: Set Version
+        id: set-version
+        run: |
+          echo "::set-output name=version::${GITHUB_REF:10}"
+          echo "ReleaseTag=${GITHUB_REF:10}" 
+
+      # Docker Image 构建环境
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1 
+        with:
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PASSWORD }}
+
+      # Build and push
+      - name: Build dockerfile
+        uses: docker/build-push-action@v2
+        with:
+          file: ./Dockerfile
+          platforms: linux/amd64
+          push: true
+          tags: |
+            ${{ secrets.DOCKER_USERNAME }}/chinesesubfinder:${{ steps.set-version.outputs.version }}
+          build-args: |
+            VERSION=${{ steps.set-version.outputs.version }}
+
+

+ 1 - 1
.github/workflows/Build Image.yml → .github/workflows/Build ChineseSubFinder DockerImage-Release.yml

@@ -1,4 +1,4 @@
-name: Build Docker Image
+name: Build ChineseSubFinder DockerImage-Release
 
 on:
   push:

+ 32 - 0
.github/workflows/goreleaser-ChineseSubFinder-Beta.yml

@@ -0,0 +1,32 @@
+name: goreleaser-ChineseSubFinder
+
+on:
+  push:
+    tags:
+      - v*.*-Beta*
+      - v*.*-ExeBeta*
+  workflow_dispatch:
+
+jobs:
+  goreleaser:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+
+      - name: Set up Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.17
+          
+      - name: Run GoReleaser
+        uses: goreleaser/goreleaser-action@v2
+        with:
+          # either 'goreleaser' (default) or 'goreleaser-pro'
+          distribution: goreleaser
+          version: latest
+          args: release -f .goreleaser-ChineseSubFinder.yml --rm-dist
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN  }}

+ 2 - 2
.github/workflows/goreleaser.yml → .github/workflows/goreleaser-ChineseSubFinder.yml

@@ -1,4 +1,4 @@
-name: goreleaser
+name: goreleaser-ChineseSubFinder
 
 on:
   push:
@@ -26,6 +26,6 @@ jobs:
           # either 'goreleaser' (default) or 'goreleaser-pro'
           distribution: goreleaser
           version: latest
-          args: release --rm-dist
+          args: release -f .goreleaser-ChineseSubFinder.yml --rm-dist
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN  }}

+ 19 - 3
.goreleaser.yml → .goreleaser-ChineseSubFinder.yml

@@ -6,11 +6,13 @@ env:
 before:
   hooks:
     - go mod tidy
+    - sudo apt-get install gcc-multilib
+    - sudo apt-get install -y *-w64-x86-*
 builds:
-  - env:
-      - CGO_ENABLED=0
+  - id: linux-build
+    env:
+      - CGO_ENABLED=1
     goos:
-      - windows
       - linux
     goarch:
       - amd64
@@ -18,6 +20,20 @@ builds:
     ldflags:
       - -s -w -X main.AppVersion=v{{.Version}}
 
+  - id: windows-build
+    env:
+      - CGO_ENABLED=1
+      - CXX=x86_64-w64-mingw32-g++
+      - CC=x86_64-w64-mingw32-gcc
+    goos:
+      - windows
+    goarch:
+      - amd64
+    main: ./cmd/chinesesubfinder/main.go
+    ldflags:
+      - -s -w -X main.AppVersion=v{{.Version}}
+
+
 archives:
   - id: archive
     name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"

+ 2 - 2
Docker/root/etc/services.d/chinesesubfinder/run

@@ -1,6 +1,6 @@
 #!/usr/bin/with-contenv bash
-
-Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
+# 开启 Xvfb 给 Chrome 使用
+# Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
 
 # 启动chinesesubfinder
 cd /app && exec s6-setuidgid abc ./chinesesubfinder

+ 2 - 17
Dockerfile

@@ -3,7 +3,7 @@ ARG VERSION=0.0.10
 LABEL stage=gobuilder
 
 # 开始编译
-ENV CGO_ENABLED 0
+ENV CGO_ENABLED 1
 ENV GO111MODULE=on
 ENV GOOS linux
 ENV GOPROXY https://goproxy.cn,direct
@@ -25,26 +25,11 @@ RUN ln -s /root/.cache/rod/chromium-856583/chrome-linux/chrome /usr/bin/chrome &
     # sed -i "s@http://archive.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && \
     apt-get update && \
     apt-get install --no-install-recommends -y \
+    yasm ffmpeg \
     # C、C++ 支持库
     libgcc-6-dev libstdc++6 \
-    # chromium dependencies
-    libnss3 \
-    libxss1 \
-    libasound2 \
-    libxtst6 \
-    libgtk-3-0 \
-    libgbm1 \
     ca-certificates \
     wget \
-    # fonts
-    fonts-liberation fonts-noto-color-emoji fonts-noto-cjk \
-    # processs reaper
-    dumb-init \
-    # headful mode support, for example: $ xvfb-run chromium-browser --remote-debugging-port=9222
-    xvfb \
-    xorg gtk2-engines-pixbuf \
-    dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable \
-    imagemagick x11-apps \
     # cleanup
     && apt-get clean \
     && rm -rf \

+ 1 - 1
cmd/chinesesubfinder/main.go

@@ -161,7 +161,7 @@ func DownLoadStart(httpProxy string) {
 	defer func() {
 		log.Infoln("Download One End...")
 		notify_center.Notify.Send()
-		pkg.CloseChrome()
+		//pkg.CloseChrome()
 		rod_helper.Clear()
 	}()
 

+ 4 - 0
internal/logic/sub_timeline_fixer/sub_timeline_fixer_helper.go

@@ -14,6 +14,7 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_parser_hub"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_timeline_fixer"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/vad"
 	"github.com/allanpk716/ChineseSubFinder/internal/types"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/emby"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/sub_timeline_fiexer"
@@ -90,6 +91,9 @@ func (s SubTimelineFixerHelper) FixRecentlyItemsSubTimeline(movieRootDir, series
 		}
 	}
 
+	// 强制调用,测试 CGO=1 编译问题
+	println(vad.Mode)
+
 	return nil
 }