ci: fix windows build

This commit is contained in:
levi committed 2022-11-03 19:38:00 +08:00
1 parent 745afb600c
commit 8b997fa7f2
1 file changed
+226 -219
+226 -219
View File
@@ -30,21 +30,29 @@ jobs:
needs: [ release ]
steps:
- uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - uses: subosito/flutter-action@v2
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- uses: subosito/flutter-action@v2
- name: Build
env:
VERSION: ${{ needs.release.outputs.tag_name }}
run: |
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/monkeyWie/gopeed/bind/desktop
cd ui/flutter
flutter build windows
$mingw = "C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin\"
$release = "build\windows\runner\Release\"
cp $mingw\libstdc++-6.dll $release
cp $mingw\libgcc_s_seh-1.dll $release
cp $mingw\libwinpthread-1.dll $release
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 MyAppVersion "$($env:PATH.substring(1))"
#define MyAppPublisher "monkeyWie"
#define MyAppURL "https://gopeed.com"
#define MyAppExeName "gopeed.exe"
@@ -88,7 +96,6 @@ jobs:
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
"@ > setup.iss
type setup.iss
& "${Env:ProgramFiles(x86)}\Inno Setup 6\iscc.exe" setup.iss
mv "Output\gopeed.exe" "Output\Gopeed-$env:VERSION-windows-amd64.exe"
- name: Upload
@@ -97,219 +104,219 @@ jobs:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ui/flutter/build/windows/Output/*
overwrite: true
# build-macos-arm64-lib:
# runs-on: ubuntu-latest
# needs: [ release ]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - run: mkdir -p ~/image-cache
# - id: image-cache
# uses: actions/cache@v3
# with:
# path: ~/image-cache
# key: image-cache-xgo-v1.19
# - if: steps.image-cache.outputs.cache-hit != 'true'
# run: |
# docker pull techknowlogick/xgo:go-1.19.x
# docker save -o ~/image-cache/xgo.tar techknowlogick/xgo:go-1.19.x
# - if: steps.image-cache.outputs.cache-hit == 'true'
# run: docker load -i ~/image-cache/xgo.tar
# - name: Build
# run: |
# go install src.techknowlogick.com/xgo@latest
# xgo --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:
# runs-on: macos-latest
# needs: [ release, build-macos-arm64-lib ]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# - uses: subosito/flutter-action@v2
# - name: Install appdmg
# run: npm install -g appdmg
# - uses: actions/download-artifact@v3
# with:
# name: macos-arm64-lib
# path: ui/flutter/macos/Frameworks
# - name: Build
# env:
# VERSION: ${{ needs.release.outputs.tag_name }}
# run: |
# PROJECT_DIR=$(pwd)
build-macos-arm64-lib:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- run: mkdir -p ~/image-cache
- id: image-cache
uses: actions/cache@v3
with:
path: ~/image-cache
key: image-cache-xgo-v1.19
- if: steps.image-cache.outputs.cache-hit != 'true'
run: |
docker pull techknowlogick/xgo:go-1.19.x
docker save -o ~/image-cache/xgo.tar techknowlogick/xgo:go-1.19.x
- if: steps.image-cache.outputs.cache-hit == 'true'
run: docker load -i ~/image-cache/xgo.tar
- name: Build
run: |
go install src.techknowlogick.com/xgo@latest
xgo --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:
runs-on: macos-latest
needs: [ release, build-macos-arm64-lib ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: subosito/flutter-action@v2
- name: Install appdmg
run: npm install -g appdmg
- uses: actions/download-artifact@v3
with:
name: macos-arm64-lib
path: ui/flutter/macos/Frameworks
- name: Build
env:
VERSION: ${{ needs.release.outputs.tag_name }}
run: |
PROJECT_DIR=$(pwd)
# cd 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-arm64.dmg
cd 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-arm64.dmg
# # amd64
# cd $PROJECT_DIR
# go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o bin/libgopeed.dylib github.com/monkeyWie/gopeed/bind/desktop
# cp bin/libgopeed.dylib ui/flutter/build/macos/Build/Products/Release/Gopeed.app/Contents/Frameworks/
# cd ui/flutter/build/macos/Build/Products/Release
# appdmg appdmg.json dist/Gopeed-$VERSION-macos-amd64.dmg
# - name: Upload
# uses: shogo82148/actions-upload-release-asset@v1
# with:
# upload_url: ${{ needs.release.outputs.upload_url }}
# asset_path: ui/flutter/build/macos/Build/Products/Release/dist/*
# overwrite: true
# build-linux:
# runs-on: ubuntu-latest
# needs: [ release ]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - uses: subosito/flutter-action@v2
# - run: |
# sudo apt-get update -y
# sudo apt-get install -y ninja-build libgtk-3-dev
# - name: Build
# env:
# VERSION: ${{ needs.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/monkeyWie/gopeed/bind/desktop
# cd ui/flutter
# flutter build linux
# mkdir -p debian/gui
# cp assets/icon/icon_1024.png debian/gui/gopeed.png
# cat>debian/debian.yaml<<EOF
# flutter_app:
# command: gopeed
# arch: x64
# parent: /usr/local/lib
# control:
# Package: gopeed
# Version: ${VERSION:1}
# Architecture: amd64
# Essential: no
# Priority: optional
# Depends:
# Maintainer: monkeyWie
# Description: High speed downloader that supports all platforms.
# EOF
# amd64
cd $PROJECT_DIR
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o bin/libgopeed.dylib github.com/monkeyWie/gopeed/bind/desktop
cp bin/libgopeed.dylib ui/flutter/build/macos/Build/Products/Release/Gopeed.app/Contents/Frameworks/
cd ui/flutter/build/macos/Build/Products/Release
appdmg appdmg.json dist/Gopeed-$VERSION-macos-amd64.dmg
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ui/flutter/build/macos/Build/Products/Release/dist/*
overwrite: true
build-linux:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- uses: subosito/flutter-action@v2
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
- name: Build
env:
VERSION: ${{ needs.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/monkeyWie/gopeed/bind/desktop
cd ui/flutter
flutter build linux
mkdir -p debian/gui
cp assets/icon/icon_1024.png debian/gui/gopeed.png
cat>debian/debian.yaml<<EOF
flutter_app:
command: gopeed
arch: x64
parent: /usr/local/lib
control:
Package: gopeed
Version: ${VERSION:1}
Architecture: amd64
Essential: no
Priority: optional
Depends:
Maintainer: monkeyWie
Description: High speed downloader that supports all platforms.
EOF
# cat>debian/gui/gopeed.desktop<<EOF
# [Desktop Entry]
# Version=${VERSION:1}
# Name=Gopeed
# GenericName=Gopeed
# Comment=High speed downloader that supports all platforms.
# Terminal=false
# Type=Application
# Categories=Utility
# Keywords=Flutter;Downloader;
# EOF
cat>debian/gui/gopeed.desktop<<EOF
[Desktop Entry]
Version=${VERSION:1}
Name=Gopeed
GenericName=Gopeed
Comment=High speed downloader that supports all platforms.
Terminal=false
Type=Application
Categories=Utility
Keywords=Flutter;Downloader;
EOF
# dart pub global activate flutter_to_debian
# flutter_to_debian
# mv debian/packages/gopeed*.deb debian/packages/Gopeed-$VERSION-linux-amd64.deb
# - name: Upload
# uses: shogo82148/actions-upload-release-asset@v1
# with:
# upload_url: ${{ needs.release.outputs.upload_url }}
# asset_path: ui/flutter/debian/packages/*
# overwrite: true
# build-android:
# runs-on: ubuntu-latest
# needs: [ release ]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - uses: actions/setup-java@v3
# with:
# distribution: 'zulu'
# java-version: '11'
# - uses: subosito/flutter-action@v2
# - name: Build
# env:
# VERSION: ${{ needs.release.outputs.tag_name }}
# run: |
# mkdir ui/flutter/android/app/libs
# go install golang.org/x/mobile/cmd/gomobile@latest
# 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/monkeyWie/gopeed/bind/mobile
# cd ui/flutter
# 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.release.outputs.upload_url }}
# asset_path: ui/flutter/dist/*
# overwrite: true
# build-web:
# runs-on: ubuntu-latest
# needs: [ release ]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '^1.19'
# cache: true
# - uses: subosito/flutter-action@v2
# - name: Build
# env:
# VERSION: ${{ needs.release.outputs.tag_name }}
# run: |
# cd ui/flutter
# flutter build web
# 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
# name=gopeed-web-$VERSION-$goos-$goarch
# dir="dist/$name/"
# (GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w" -o $dir github.com/monkeyWie/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.release.outputs.upload_url }}
# asset_path: dist/zip/*
# overwrite: true
dart pub global activate flutter_to_debian
flutter_to_debian
mv debian/packages/gopeed*.deb debian/packages/Gopeed-$VERSION-linux-amd64.deb
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ui/flutter/debian/packages/*
overwrite: true
build-android:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
- name: Build
env:
VERSION: ${{ needs.release.outputs.tag_name }}
run: |
mkdir ui/flutter/android/app/libs
go install golang.org/x/mobile/cmd/gomobile@latest
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/monkeyWie/gopeed/bind/mobile
cd ui/flutter
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.release.outputs.upload_url }}
asset_path: ui/flutter/dist/*
overwrite: true
build-web:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
cache: true
- uses: subosito/flutter-action@v2
- name: Build
env:
VERSION: ${{ needs.release.outputs.tag_name }}
run: |
cd ui/flutter
flutter build web
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
name=gopeed-web-$VERSION-$goos-$goarch
dir="dist/$name/"
(GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w" -o $dir github.com/monkeyWie/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.release.outputs.upload_url }}
asset_path: dist/zip/*
overwrite: true