build #199
This file contains 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: | |
workflow_dispatch: | |
inputs: | |
platform: | |
description: 'Build platform' | |
required: true | |
default: 'all' | |
channel: | |
description: 'Snap channel' | |
required: true | |
default: 'stable' | |
env: | |
GO_VERSION: "1.19" | |
FLUTTER_VERSION: "3.16.1" | |
permissions: | |
contents: write | |
jobs: | |
get-release: | |
runs-on: ubuntu-latest | |
outputs: | |
tag_name: ${{ steps.get-release.outputs.tag_name }} | |
upload_url: ${{ steps.get-release.outputs.upload_url }} | |
steps: | |
- uses: monkeyWie/get-latest-release@v1 | |
id: get-release | |
with: | |
myToken: ${{ github.token }} | |
build-windows: | |
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }} | |
runs-on: windows-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: "1.20" | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
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" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop | |
cd ui/flutter | |
flutter build windows | |
$mingw = "C:\Program Files\Git\mingw64\bin" | |
$system = "C:\Windows\System32" | |
$release = "build\windows\x64\runner\Release\" | |
cp $mingw\libstdc++-6.dll $release | |
cp $mingw\libgcc_s_seh-1.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-$env:VERSION-windows-amd64-portable.zip" | |
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.substring(1))" | |
#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 | |
Compression=lzma | |
SolidCompression=yes | |
WizardStyle=modern | |
LanguageDetectionMethod=uilanguage | |
ShowLanguageDialog=yes | |
[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: ".\x64\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-$env:VERSION-windows-amd64.exe" | |
Compress-Archive -Path "Output\Gopeed-$env:VERSION-windows-amd64.exe" -DestinationPath "Output\Gopeed-$env:VERSION-windows-amd64.zip" | |
Remove-Item -Path "Output\Gopeed-$env:VERSION-windows-amd64.exe" | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: ui/flutter/build/windows/Output/* | |
overwrite: true | |
build-macos-arm64-lib: | |
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }} | |
runs-on: ubuntu-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Build | |
run: | | |
go install src.techknowlogick.com/xgo@latest | |
xgo -go go-$GO_VERSION.x --targets=darwin/arm64 -tags="nosqlite" -ldflags="-w -s" -buildmode=c-shared -pkg=bind/desktop -out=libgopeed . | |
mv libgopeed-*.dylib libgopeed.dylib | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: macos-arm64-lib | |
path: libgopeed.dylib | |
build-macos: | |
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }} | |
runs-on: macos-latest | |
needs: [ get-release, build-macos-arm64-lib ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
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 | |
npm install -g appdmg | |
- uses: actions/download-artifact@v3 | |
with: | |
name: macos-arm64-lib | |
path: ui/flutter/lib-arm64 | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
PROJECT_DIR=$(pwd) | |
# amd64 lib | |
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/lib-amd64/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop | |
# universal binary | |
mkdir -p ui/flutter/macos/Frameworks | |
cp ui/flutter/lib-amd64/libgopeed.dylib ui/flutter/macos/Frameworks/amd64-lib | |
cp ui/flutter/lib-arm64/libgopeed.dylib ui/flutter/macos/Frameworks/arm64-lib | |
cd ui/flutter/macos/Frameworks | |
lipo -create -output libgopeed.dylib amd64-lib arm64-lib | |
cd $PROJECT_DIR/ui/flutter | |
flutter build macos | |
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-$VERSION-macos.dmg | |
- 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: ubuntu-20.04 | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- run: | | |
sudo apt-get update -y | |
sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop | |
cd ui/flutter | |
flutter build linux | |
mkdir -p build/dist | |
# Build portable | |
tar -C build/linux/x64/release/bundle -czaf build/dist/Gopeed-$VERSION-linux-amd64-portable.tar.gz ./ | |
# Build deb package | |
mkdir -p debian/gopeed/opt/gopeed | |
mkdir -p debian/gopeed/usr/share/applications | |
mkdir -p debian/gopeed/usr/share/icons/hicolor/scalable/apps | |
mkdir -p debian/gopeed/DEBIAN | |
cp -r build/linux/x64/release/bundle/* debian/gopeed/opt/gopeed/ | |
cp assets/icon/icon.svg debian/gopeed/usr/share/icons/hicolor/scalable/apps/com.gopeed.Gopeed.svg | |
cat>debian/gopeed/DEBIAN/postinst<<EOF | |
#!/bin/bash | |
ln -sf /opt/gopeed/gopeed /usr/bin/gopeed | |
EOF | |
cat>debian/gopeed/DEBIAN/postrm<<EOF | |
#!/bin/bash | |
rm -rf /usr/bin/gopeed | |
EOF | |
chmod 0755 debian/gopeed/DEBIAN/postinst | |
chmod 0755 debian/gopeed/DEBIAN/postrm | |
cat>debian/gopeed/DEBIAN/control<<EOF | |
Package: gopeed | |
Version: ${VERSION:1} | |
Architecture: amd64 | |
Essential: no | |
Priority: optional | |
Depends: | |
Maintainer: monkeyWie | |
Description: High speed downloader that supports all platforms. | |
EOF | |
cp linux/assets/com.gopeed.Gopeed.desktop debian/gopeed/usr/share/applications/gopeed.desktop | |
dpkg-deb --build debian/gopeed | |
mv debian/gopeed.deb build/dist/Gopeed-$VERSION-linux-amd64.deb | |
# Build AppImage | |
sudo apt-get -y install libfuse2 | |
wget -O appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage | |
chmod +x appimage-builder | |
mkdir AppDir | |
cp -r build/linux/x64/release/bundle/* AppDir | |
mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps/ | |
cp assets/icon/icon.svg AppDir/usr/share/icons/hicolor/scalable/apps/gopeed.svg | |
cat>AppImageBuilder.yml<<EOF | |
version: 1 | |
AppDir: | |
path: ${PWD}/AppDir | |
app_info: | |
id: com.gopeed.gopeed | |
name: Gopeed | |
icon: gopeed | |
version: ${VERSION:1} | |
exec: gopeed | |
exec_args: \$@ | |
apt: | |
arch: amd64 | |
allow_unauthenticated: true | |
sources: | |
- sourceline: deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted | |
universe multiverse | |
- sourceline: deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main | |
restricted universe multiverse | |
- sourceline: deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports | |
main restricted universe multiverse | |
- sourceline: deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted | |
universe multiverse | |
include: [] | |
files: | |
include: [] | |
exclude: | |
- usr/share/man | |
- usr/share/doc/*/README.* | |
- usr/share/doc/*/changelog.* | |
- usr/share/doc/*/NEWS.* | |
- usr/share/doc/*/TODO.* | |
test: | |
fedora-30: | |
image: appimagecrafters/tests-env:fedora-30 | |
command: ./AppRun | |
debian-stable: | |
image: appimagecrafters/tests-env:debian-stable | |
command: ./AppRun | |
archlinux-latest: | |
image: appimagecrafters/tests-env:archlinux-latest | |
command: ./AppRun | |
centos-7: | |
image: appimagecrafters/tests-env:centos-7 | |
command: ./AppRun | |
ubuntu-xenial: | |
image: appimagecrafters/tests-env:ubuntu-xenial | |
command: ./AppRun | |
AppImage: | |
arch: x86_64 | |
update-information: guess | |
EOF | |
./appimage-builder --skip-tests --recipe AppImageBuilder.yml | |
mv Gopeed-*-x86_64.AppImage build/dist/Gopeed-$VERSION-linux-amd64.AppImage | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: ui/flutter/build/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@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Setup LXD | |
uses: canonical/[email protected] | |
with: | |
channel: latest/stable | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop | |
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:1} | |
summary: A modern download manager | |
description: High speed downloader that supports all platforms. | |
confinement: strict | |
base: core22 | |
grade: stable | |
architectures: | |
- build-on: amd64 | |
build-for: amd64 | |
slots: | |
dbus-gopeed: | |
interface: dbus | |
bus: session | |
name: com.gopeed.gopeed | |
apps: | |
gopeed: | |
command: gopeed | |
extensions: [gnome] | |
plugs: | |
- network | |
slots: | |
- dbus-gopeed | |
parts: | |
gopeed: | |
source: . | |
plugin: flutter | |
stage-packages: | |
- libgtk-3-dev | |
- libayatana-appindicator3-dev | |
flutter-target: lib/main.dart | |
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.channel }} gopeed_${VERSION:1}_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@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: "zulu" | |
java-version: "11" | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
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" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 19 -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 | |
mkdir dist | |
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-$VERSION-android.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-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
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.tag_name }} | |
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" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile | |
cd ui/flutter | |
flutter build ios --no-codesign | |
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-$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' }} | |
runs-on: ubuntu-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
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.tag_name }} | |
run: | | |
cd ui/flutter | |
flutter build web --web-renderer html | |
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-$VERSION-$goos_name-$goarch | |
dir="dist/$name/" | |
(GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w" -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 | |
- 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-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: 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 and push | |
uses: docker/build-push-action@v2 | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
with: | |
push: true | |
platforms: | | |
linux/386 | |
linux/amd64 | |
linux/arm64 | |
linux/arm/v6 | |
linux/arm/v7 | |
tags: | | |
liwei2633/gopeed:latest | |
liwei2633/gopeed:${{ env.VERSION }} |