mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-04 08:10:55 +00:00
776 lines
32 KiB
YAML
776 lines
32 KiB
YAML
name: build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
platform:
|
|
description: "Build platform"
|
|
required: true
|
|
default: "all"
|
|
test:
|
|
description: "Test mode"
|
|
required: true
|
|
default: "false"
|
|
|
|
env:
|
|
GO_VERSION: "1.25"
|
|
FLUTTER_VERSION: "3.41.6"
|
|
GA4_MEASUREMENT_ID: ${{ secrets.GA4_MEASUREMENT_ID }}
|
|
GA4_API_SECRET: ${{ secrets.GA4_API_SECRET }}
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
get-release:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.get-release.outputs.version }}
|
|
upload_url: ${{ steps.get-release.outputs.upload_url }}
|
|
|
|
steps:
|
|
- uses: monkeyWie/get-latest-release@v2.1
|
|
id: get-release
|
|
with:
|
|
myToken: ${{ github.token }}
|
|
|
|
build-windows:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }}
|
|
needs: [get-release]
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- arch: arm64
|
|
os: windows-11-arm
|
|
llvm_ver: "20251202" # Only ARM64
|
|
flutter_channel: "main"
|
|
flutter_version: "7e1c8868"
|
|
- arch: amd64
|
|
os: windows-2022
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Enable long paths for flutter main branch checks
|
|
run: |
|
|
git config --global core.longpaths true
|
|
|
|
# Install LLVM environment only on ARM64
|
|
- name: Install llvm-mingw-ucrt-aarch64 (ARM64 only)
|
|
if: matrix.arch == 'arm64'
|
|
run: |
|
|
$ver = "${{ matrix.llvm_ver }}"
|
|
$url = "https://github.com/mstorsjo/llvm-mingw/releases/download/$ver/llvm-mingw-$ver-ucrt-aarch64.zip"
|
|
$zip = "$env:RUNNER_TEMP\\llvm.zip"
|
|
$extract = "$env:RUNNER_TEMP\\extract"
|
|
$target = "C:\\clangarm64"
|
|
|
|
curl -L $url -o $zip
|
|
rm -r -fo $extract,$target -ea Ignore
|
|
mkdir $extract | Out-Null
|
|
|
|
tar -xf $zip -C $extract
|
|
mv (Get-ChildItem $extract)[0].FullName $target
|
|
|
|
$b = "$target\\bin"
|
|
"CC=$b\\clang.exe" >> $env:GITHUB_ENV
|
|
"CXX=$b\\clang++.exe" >> $env:GITHUB_ENV
|
|
"CLANGARM64_BIN=$b" >> $env:GITHUB_ENV
|
|
"CGO_ENABLED=1" >> $env:GITHUB_ENV
|
|
"CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
|
|
$b >> $env:GITHUB_PATH
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: ${{ matrix.flutter_channel || 'stable' }}
|
|
flutter-version: ${{ matrix.flutter_version || env.FLUTTER_VERSION }}
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
GOARCH: ${{ matrix.arch }}
|
|
run: |
|
|
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "ChineseSimplified.isl"
|
|
mv ChineseSimplified.isl "C:\Program Files (x86)\Inno Setup 6\Languages\"
|
|
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$env:VERSION" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/host.exe github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater.exe github.com/GopeedLab/gopeed/cmd/updater
|
|
cd ui/flutter
|
|
$TAG = "v$env:VERSION"
|
|
flutter build windows --dart-define="UPDATE_CHANNEL=windowsPortable" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
$system = "C:\Windows\System32"
|
|
if ("${{ matrix.arch }}" -eq "amd64") {
|
|
# for amd64
|
|
$release = "build\windows\x64\runner\Release\"
|
|
$mingw = "C:\Program Files\Git\mingw64\bin"
|
|
cp $mingw\libstdc++-6.dll $release
|
|
cp $mingw\libgcc_s_seh-1.dll $release
|
|
} else {
|
|
# for ARM64
|
|
$release = "build\windows\arm64\runner\Release\"
|
|
$mingw = "$env:CLANGARM64_ROOT\aarch64-w64-mingw32\bin"
|
|
cp $mingw\libc++.dll $release
|
|
cp $mingw\libunwind.dll $release
|
|
}
|
|
cp $mingw\libwinpthread-1.dll $release
|
|
cp $system\msvcp140.dll $release
|
|
cp $system\vcruntime140.dll $release
|
|
cp $system\vcruntime140_1.dll $release
|
|
|
|
New-Item -Path build\windows\Output -ItemType Directory
|
|
Compress-Archive -Path "$release*" -DestinationPath "build\windows\Output\Gopeed-$TAG-windows-${{ matrix.arch }}-portable.zip"
|
|
|
|
flutter build windows --dart-define="UPDATE_CHANNEL=windowsInstaller" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
cd build/windows
|
|
echo @"
|
|
; Script generated by the Inno Setup Script Wizard.
|
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
|
|
|
#define MyAppName "Gopeed"
|
|
#define MyAppVersion "$env:VERSION"
|
|
#define MyAppPublisher "monkeyWie"
|
|
#define MyAppURL "https://gopeed.com"
|
|
#define MyAppExeName "gopeed.exe"
|
|
|
|
[Setup]
|
|
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
|
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
|
AppId={{5960F34D-1E42-402C-8C85-DE2FF24CBAE4}
|
|
AppName={#MyAppName}
|
|
AppVersion={#MyAppVersion}
|
|
;AppVerName={#MyAppName} {#MyAppVersion}
|
|
AppPublisher={#MyAppPublisher}
|
|
AppPublisherURL={#MyAppURL}
|
|
AppSupportURL={#MyAppURL}
|
|
AppUpdatesURL={#MyAppURL}
|
|
DefaultDirName={autopf}\gopeed
|
|
DisableProgramGroupPage=yes
|
|
LicenseFile=..\..\..\..\LICENSE
|
|
; Remove the following line to run in administrative install mode (install for all users.)
|
|
PrivilegesRequired=lowest
|
|
OutputBaseFilename=gopeed
|
|
SetupIconFile=..\..\assets\icon\icon.ico
|
|
UninstallDisplayIcon={app}\{#MyAppExeName}
|
|
Compression=lzma
|
|
SolidCompression=yes
|
|
WizardStyle=modern
|
|
LanguageDetectionMethod=uilanguage
|
|
ShowLanguageDialog=yes
|
|
CloseApplications=force
|
|
|
|
[Languages]
|
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
|
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
|
|
|
|
[Tasks]
|
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
|
|
|
[Files]
|
|
Source: ".\${{ matrix.arch == 'amd64' && 'x64' || 'arm64' }}\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs;
|
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
|
|
|
[UninstallDelete]
|
|
Type: filesandordirs; Name: "{app}"
|
|
|
|
[Icons]
|
|
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
|
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
|
|
|
[Run]
|
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
|
"@ > setup.iss
|
|
iscc.exe setup.iss
|
|
mv "Output\gopeed.exe" "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.exe"
|
|
Compress-Archive -Path "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.exe" -DestinationPath "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.zip"
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1.9.2
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: ui/flutter/build/windows/Output/*
|
|
overwrite: true
|
|
build-macos-amd64-lib:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
|
|
runs-on: macos-15-intel
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -buildmode=c-shared -o libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" github.com/GopeedLab/gopeed/cmd/updater
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: macos-amd64-lib
|
|
path: |
|
|
libgopeed.dylib
|
|
host
|
|
updater
|
|
build-macos:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
|
|
runs-on: macos-latest
|
|
strategy:
|
|
matrix:
|
|
channel: [arm64, amd64, universal]
|
|
needs: [get-release, build-macos-amd64-lib]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
- name: Install appdmg
|
|
run: |
|
|
python3 -m pip install setuptools --break-system-packages
|
|
npm install -g appdmg
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: macos-amd64-lib
|
|
path: ui/flutter/lib-amd64
|
|
- if: ${{ matrix.channel == 'arm64' }}
|
|
name: Build Arm64 Libraries
|
|
run: |
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/host github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater github.com/GopeedLab/gopeed/cmd/updater
|
|
- if: ${{ matrix.channel == 'amd64' }}
|
|
name: Build Amd64 Libraries
|
|
run: |
|
|
mkdir -p ui/flutter/macos/Frameworks
|
|
|
|
cp ui/flutter/lib-amd64/libgopeed.dylib ui/flutter/macos/Frameworks/libgopeed.dylib
|
|
cp ui/flutter/lib-amd64/host ui/flutter/assets/exec/host
|
|
cp ui/flutter/lib-amd64/updater ui/flutter/assets/exec/updater
|
|
- if: ${{ matrix.channel == 'universal' }}
|
|
name: Build Universal Libraries
|
|
run: |
|
|
mkdir -p ui/flutter/macos/Frameworks
|
|
|
|
# arm64 lib
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -buildmode=c-shared -o ui/flutter/.temp/libgopeed.dylib.arm64 github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" -o ui/flutter/.temp/host.arm64 github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" -o ui/flutter/.temp/updater.arm64 github.com/GopeedLab/gopeed/cmd/updater
|
|
|
|
# amd64 lib
|
|
cp ui/flutter/lib-amd64/libgopeed.dylib ui/flutter/.temp/libgopeed.dylib.amd64
|
|
cp ui/flutter/lib-amd64/host ui/flutter/.temp/host.amd64
|
|
cp ui/flutter/lib-amd64/updater ui/flutter/.temp/updater.amd64
|
|
|
|
# universal lib
|
|
lipo -create -output ui/flutter/macos/Frameworks/libgopeed.dylib ui/flutter/.temp/libgopeed.dylib.arm64 ui/flutter/.temp/libgopeed.dylib.amd64
|
|
lipo -create -output ui/flutter/assets/exec/host ui/flutter/.temp/host.arm64 ui/flutter/.temp/host.amd64
|
|
lipo -create -output ui/flutter/assets/exec/updater ui/flutter/.temp/updater.arm64 ui/flutter/.temp/updater.amd64
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
cd ui/flutter
|
|
flutter build macos --dart-define="UPDATE_CHANNEL=macosDmg" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
cd build/macos/Build/Products/Release
|
|
cat>appdmg.json<<EOF
|
|
{
|
|
"title": "Gopeed",
|
|
"icon": "Gopeed.app/Contents/Resources/AppIcon.icns",
|
|
"contents": [
|
|
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
|
|
{ "x": 192, "y": 344, "type": "file", "path": "Gopeed.app" }
|
|
]
|
|
}
|
|
EOF
|
|
mkdir dist
|
|
appdmg appdmg.json dist/Gopeed-v$VERSION-macos.dmg
|
|
|
|
if [[ "${{ matrix.channel }}" == "arm64" ]]; then
|
|
mv dist/Gopeed-v$VERSION-macos.dmg dist/Gopeed-v$VERSION-macos-arm64.dmg
|
|
fi
|
|
if [[ "${{ matrix.channel }}" == "amd64" ]]; then
|
|
mv dist/Gopeed-v$VERSION-macos.dmg dist/Gopeed-v$VERSION-macos-amd64.dmg
|
|
fi
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: ui/flutter/build/macos/Build/Products/Release/dist/*
|
|
overwrite: true
|
|
build-linux:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-22.04, ubuntu-22.04-arm]
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
channel: master
|
|
- run: |
|
|
sudo apt update -y
|
|
sudo apt install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-1 libayatana-appindicator3-dev rpm patchelf libfuse2 locate libkeybinder-3.0-dev
|
|
arch=$(uname -m)
|
|
wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${arch}.AppImage"
|
|
chmod +x appimagetool
|
|
sudo mv appimagetool /usr/local/bin/
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/host github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater github.com/GopeedLab/gopeed/cmd/updater
|
|
|
|
cd ui/flutter
|
|
|
|
RPM_ARCH=$(uname -m)
|
|
mkdir -p linux/packaging/rpm
|
|
cat << EOF > linux/packaging/rpm/make_config.yaml
|
|
display_name: Gopeed
|
|
icon: assets/icon/icon.svg
|
|
summary: High speed downloader.
|
|
description: A high speed downloader that supports all platforms.
|
|
group: Applications/Internet
|
|
license: GPL-3.0
|
|
url: https://github.com/GopeedLab/gopeed
|
|
vendor: GopeedLab
|
|
maintainer: GopeedLab <support@gopeed.com>
|
|
build_arch: $RPM_ARCH
|
|
EOF
|
|
|
|
cat << EOF > distribute_options.yaml
|
|
output: dist/
|
|
releases:
|
|
- name: linux
|
|
jobs:
|
|
- name: appimage
|
|
package:
|
|
platform: linux
|
|
target: appimage
|
|
build_args:
|
|
dart-define:
|
|
UPDATE_CHANNEL: linuxAppImage
|
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
|
- name: deb
|
|
package:
|
|
platform: linux
|
|
target: deb
|
|
build_args:
|
|
dart-define:
|
|
UPDATE_CHANNEL: linuxDeb
|
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
|
- name: rpm
|
|
package:
|
|
platform: linux
|
|
target: rpm
|
|
build_args:
|
|
dart-define:
|
|
UPDATE_CHANNEL: linuxRpm
|
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
|
EOF
|
|
dart pub global activate -sgit https://github.com/GopeedLab/flutter_distributor.git --git-path packages/flutter_distributor
|
|
flutter_distributor release --name linux
|
|
cd dist/*
|
|
|
|
ARCH="amd64"
|
|
if [[ "${{ matrix.os }}" == *-arm ]]; then
|
|
ARCH="arm64"
|
|
fi
|
|
|
|
mv gopeed-*-linux.AppImage Gopeed-v${VERSION}-linux-${ARCH}.AppImage
|
|
mv gopeed-*-linux.deb Gopeed-v${VERSION}-linux-${ARCH}.deb
|
|
mv gopeed-*-linux.rpm Gopeed-v${VERSION}-linux-${ARCH}.rpm
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: ui/flutter/dist/*/*
|
|
overwrite: true
|
|
build-snap:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'snap' }}
|
|
runs-on: ubuntu-latest
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- name: Setup LXD
|
|
uses: canonical/setup-lxd@v0.1.1
|
|
with:
|
|
channel: latest/stable
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/host github.com/GopeedLab/gopeed/cmd/host
|
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater github.com/GopeedLab/gopeed/cmd/updater
|
|
cd ui/flutter
|
|
|
|
sudo snap install snapcraft --classic
|
|
mkdir -p snap/gui
|
|
cp assets/icon/icon.svg snap/gui/gopeed.svg
|
|
|
|
cat>snap/snapcraft.yaml<<EOF
|
|
name: gopeed
|
|
version: $VERSION
|
|
summary: A modern download manager
|
|
description: High speed downloader that supports all platforms.
|
|
|
|
confinement: strict
|
|
base: core24
|
|
grade: stable
|
|
|
|
platforms:
|
|
amd64:
|
|
build-on: amd64
|
|
build-for: amd64
|
|
|
|
slots:
|
|
dbus-gopeed:
|
|
interface: dbus
|
|
bus: session
|
|
name: com.gopeed.gopeed
|
|
|
|
apps:
|
|
gopeed:
|
|
command-chain:
|
|
- bin/gpu-2404-wrapper
|
|
command: bin/gopeed
|
|
extensions: [gnome]
|
|
common-id: com.gopeed.Gopeed
|
|
plugs:
|
|
- network
|
|
- home
|
|
parts:
|
|
flutter-git:
|
|
source: https://github.com/flutter/flutter.git
|
|
source-tag: $FLUTTER_VERSION
|
|
source-depth: 1
|
|
plugin: nil
|
|
override-build: |
|
|
mkdir -p \$CRAFT_PART_INSTALL/usr/bin
|
|
mkdir -p \$CRAFT_PART_INSTALL/usr/libexec
|
|
cp -r \$CRAFT_PART_SRC \$CRAFT_PART_INSTALL/usr/libexec/flutter
|
|
ln -s \$CRAFT_PART_INSTALL/usr/libexec/flutter/bin/flutter \$CRAFT_PART_INSTALL/usr/bin/flutter
|
|
ln -s \$SNAPCRAFT_PART_INSTALL/usr/libexec/flutter/bin/dart \$SNAPCRAFT_PART_INSTALL/usr/bin/dart
|
|
\$CRAFT_PART_INSTALL/usr/bin/flutter doctor
|
|
build-packages:
|
|
- clang
|
|
- cmake
|
|
- curl
|
|
- libgtk-3-dev
|
|
- libwebkit2gtk-4.1-dev
|
|
- libkeybinder-3.0-dev
|
|
- ninja-build
|
|
- unzip
|
|
- xz-utils
|
|
- zip
|
|
override-prime: ''
|
|
zenity:
|
|
plugin: nil
|
|
stage-packages:
|
|
- zenity
|
|
gopeed:
|
|
after: [flutter-git,zenity]
|
|
source: .
|
|
plugin: nil
|
|
stage-packages:
|
|
- libwebkit2gtk-4.1-0
|
|
- libgtk-3-dev
|
|
- libkeybinder-3.0-dev
|
|
- libappindicator3-dev
|
|
override-build: |
|
|
# work around pub get stack overflow # https://github.com/dart-lang/sdk/issues/51068#issuecomment-1396588253
|
|
set +e
|
|
dart pub get
|
|
set -eux
|
|
flutter build linux --dart-define="UPDATE_CHANNEL=linuxSnap" --dart-define="GA4_MEASUREMENT_ID=$GA4_MEASUREMENT_ID" --dart-define="GA4_API_SECRET=$GA4_API_SECRET"
|
|
mkdir -p \$CRAFT_PART_INSTALL/bin/
|
|
cp -r build/linux/*/release/bundle/* \$CRAFT_PART_INSTALL/bin/
|
|
gpu-2404:
|
|
after: [gopeed]
|
|
source: https://github.com/canonical/gpu-snap.git
|
|
plugin: dump
|
|
override-prime: |
|
|
craftctl default
|
|
\${CRAFT_PART_SRC}/bin/gpu-2404-cleanup mesa-2404
|
|
prime:
|
|
- bin/gpu-2404-wrapper
|
|
|
|
plugs:
|
|
gpu-2404:
|
|
interface: content
|
|
target: \$SNAP/gpu-2404
|
|
default-provider: mesa-2404
|
|
|
|
layout:
|
|
/usr/share/libdrm:
|
|
bind: \$SNAP/gpu-2404/libdrm
|
|
/usr/share/drirc.d:
|
|
symlink: \$SNAP/gpu-2404/drirc.d
|
|
/usr/share/X11/XErrorDB:
|
|
symlink: \$SNAP/gpu-2404/X11/XErrorDB
|
|
EOF
|
|
|
|
cp linux/assets/com.gopeed.Gopeed.desktop snap/gui/gopeed.desktop
|
|
sed -i 's/Icon=com.gopeed.Gopeed/Icon=\${SNAP}\/meta\/gui\/gopeed.svg/g' snap/gui/gopeed.desktop
|
|
|
|
snapcraft --use-lxd
|
|
|
|
# Snapcraft login
|
|
export SNAPCRAFT_STORE_CREDENTIALS=${{ secrets.SNAP_STORE_LOGIN }}
|
|
snapcraft upload --release=${{ github.event.inputs.test == 'true' && 'edge' || 'stable' }} gopeed_${VERSION}_amd64.snap
|
|
build-android:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
|
|
runs-on: ubuntu-latest
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: actions/setup-java@v3
|
|
with:
|
|
distribution: "zulu"
|
|
java-version: "17"
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
APK_KEYSTORE: ${{ secrets.APK_KEYSTORE }}
|
|
APK_KEY_PASSWORD: ${{ secrets.APK_KEY_PASSWORD }}
|
|
APK_STORE_PASSWORD: ${{ secrets.APK_STORE_PASSWORD }}
|
|
run: |
|
|
go install golang.org/x/mobile/cmd/gomobile@latest
|
|
go get golang.org/x/mobile/bind
|
|
gomobile init
|
|
gomobile bind -tags nosqlite -ldflags="-w -s -checklinkname=0 -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 21 -javapkg=com.gopeed github.com/GopeedLab/gopeed/bind/mobile
|
|
cd ui/flutter
|
|
echo $APK_KEYSTORE | base64 -di > android/app/upload-keystore.jks
|
|
flutter build apk --dart-define="UPDATE_CHANNEL=androidApk" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
flutter build apk --split-per-abi --dart-define="UPDATE_CHANNEL=androidApk" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
mkdir dist
|
|
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-v$VERSION-android.apk
|
|
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk dist/Gopeed-v$VERSION-android-armeabi-v7a.apk
|
|
cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk dist/Gopeed-v$VERSION-android-arm64-v8a.apk
|
|
cp build/app/outputs/flutter-apk/app-x86_64-release.apk dist/Gopeed-v$VERSION-android-x86_64.apk
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: ui/flutter/dist/*
|
|
overwrite: true
|
|
build-ios:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' }}
|
|
runs-on: macos-14
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
go install golang.org/x/mobile/cmd/gomobile@latest
|
|
go get golang.org/x/mobile/bind
|
|
gomobile init
|
|
gomobile bind -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile
|
|
cd ui/flutter
|
|
flutter build ios --no-codesign --dart-define="UPDATE_CHANNEL=iosIpa" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
mkdir Payload
|
|
cp -r build/ios/iphoneos/Runner.app Payload
|
|
zip -r -y Payload.zip Payload/Runner.app
|
|
mkdir dist
|
|
mv Payload.zip dist/Gopeed-v$VERSION-ios.ipa
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: ui/flutter/dist/*
|
|
overwrite: true
|
|
build-web:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'web' || github.event.inputs.platform == 'qnap' }}
|
|
runs-on: ubuntu-latest
|
|
needs: [get-release]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
cd ui/flutter
|
|
flutter build web --no-web-resources-cdn --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
dart ../../.github/workflows/scripts/flutter_local_font.dart
|
|
cd ../../
|
|
cp -r ui/flutter/build/web cmd/web/dist
|
|
mkdir -p dist/zip
|
|
|
|
goos_arr=(windows darwin linux)
|
|
goarch_arr=(386 amd64 arm64)
|
|
export CGO_ENABLED=0
|
|
for goos in "${goos_arr[@]}"; do
|
|
for goarch in "${goarch_arr[@]}"; do
|
|
goos_name=$goos
|
|
if [ $goos = "darwin" ]; then
|
|
goos_name="macos"
|
|
fi
|
|
name=gopeed-web-v$VERSION-$goos_name-$goarch
|
|
dir="dist/$name/"
|
|
(GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o $dir github.com/GopeedLab/gopeed/cmd/web \
|
|
&& cd $dir \
|
|
&& file=$(ls -AU | head -1) \
|
|
&& mkdir $name \
|
|
&& mv $file $name/$(echo $file | sed -e "s/web/gopeed/g") \
|
|
&& zip -r ../zip/$name.zip * \
|
|
&& cd ../..) \
|
|
|| true
|
|
done
|
|
done
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-dist
|
|
path: dist/zip/
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: dist/zip/*
|
|
overwrite: true
|
|
build-qnap:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'qnap' }}
|
|
runs-on: ubuntu-latest
|
|
needs: [get-release, build-web]
|
|
steps:
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.8.18"
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: web-dist
|
|
path: dist/zip/
|
|
- name: Build
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
run: |
|
|
sudo apt update -y
|
|
sudo apt install -y pv bsdmainutils
|
|
wget -O qdk2_0.32.bionic_amd64.deb "https://github.com/qnap-dev/qdk2/releases/download/v0.32/qdk2_0.32.bionic_amd64.deb"
|
|
dpkg -X qdk2_0.32.bionic_amd64.deb qdk2 # Direct installs will fail due to missing dependencies!
|
|
[[ -d qdk2 ]] || exit 1
|
|
|
|
export PATH=$(pwd)/qdk2/usr/bin:$(pwd)/qdk2/usr/share/qdk2/QDK/bin:${PATH}
|
|
wget -O Gopeed.template.tar.gz "https://github.com/GopeedLab/QpkgBuild/raw/refs/heads/master/template/Gopeed.template.tar.gz"
|
|
tar -zxf Gopeed.template.tar.gz
|
|
[[ -d Gopeed ]] || exit 1
|
|
|
|
goos=linux
|
|
goarch_arr=(amd64 arm64)
|
|
for goarch in "${goarch_arr[@]}"; do
|
|
qarch=x86_64
|
|
[[ "${goarch}" == "arm64" ]] && qarch=arm_64
|
|
name=gopeed-web-v${VERSION}-${goos}-${goarch}
|
|
unzip dist/zip/${name}.zip -d dist/${name}
|
|
cp dist/${name}/${name}/* Gopeed/${qarch}/
|
|
done
|
|
cd Gopeed
|
|
sed -i -e 's/__QPKG_VER__/${VERSION}/g' qpkg.cfg
|
|
qbuild || exit 1
|
|
|
|
mkdir -p ../dist/qnap
|
|
goos=qnap
|
|
for goarch in "${goarch_arr[@]}"; do
|
|
qarch=x86_64
|
|
[[ "${goarch}" == "arm64" ]] && qarch=arm_64
|
|
sname=Gopeed_${VERSION}_${qarch}.qpkg
|
|
dname=gopeed-v${VERSION}-${goos}-${goarch}.qpkg
|
|
[[ -f build/${sname} ]] && cp -ra build/${sname} ../dist/qnap/${dname}
|
|
done
|
|
- name: Upload
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
asset_path: dist/qnap/*
|
|
overwrite: true
|
|
build-docker:
|
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'docker' }}
|
|
runs-on: ubuntu-latest
|
|
needs: [get-release]
|
|
steps:
|
|
- name: Remove unnecessary files
|
|
run: |
|
|
sudo rm -rf /usr/share/dotnet
|
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
|
- uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
- uses: actions/checkout@v3
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: liwei2633
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Build flutter web
|
|
run: |
|
|
cd ui/flutter
|
|
flutter build web --no-web-resources-cdn --dart-define="UPDATE_CHANNEL=docker" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
|
dart ../../.github/workflows/scripts/flutter_local_font.dart
|
|
cd ../../
|
|
rm -rf cmd/web/dist
|
|
cp -r ui/flutter/build/web cmd/web/dist
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
env:
|
|
VERSION: ${{ needs.get-release.outputs.version }}
|
|
with:
|
|
context: .
|
|
push: ${{ github.event.inputs.test == 'true' && 'false' || 'true' }}
|
|
build-args: |
|
|
VERSION=${{ env.VERSION }}
|
|
IN_DOCKER=true
|
|
platforms: |
|
|
linux/386
|
|
linux/amd64
|
|
linux/arm64
|
|
linux/arm/v7
|
|
tags: |
|
|
liwei2633/gopeed:latest
|
|
liwei2633/gopeed:v${{ env.VERSION }}
|