build #47
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: | |
release: | |
types: [ published ] | |
env: | |
GO_VERSION: "^1.21" | |
FLUTTER_VERSION: "3.16.0" | |
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: actions/checkout@v4 | |
- uses: thebritican/fetch-latest-release@v2.0.0 | |
id: get-release | |
build-windows: | |
runs-on: windows-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
cd core | |
go build -ldflags="-w -s" -buildmode=c-shared -o ./dist/libclash.dll mapleafgo.cn/clash_for_flutter/core | |
cd ../ | |
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\" | |
flutter build windows | |
$mingw = "C:\Program Files\Git\mingw64\bin" | |
$system = "C:\Windows\System32" | |
$release = "build\windows\x64\runner\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\x64\Output\clash_for_flutter-$env:VERSION-windows-amd64-portable.zip" | |
cd build/windows/x64 | |
echo @" | |
; Script generated by the Inno Setup Script Wizard. | |
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! | |
#define MyAppName "Clash For Flutter" | |
#define MyAppVersion "$($env:VERSION)" | |
#define MyAppPublisher "mapleafgo" | |
#define MyAppURL "https://github.com/mapleafgo/clash-for-flutter" | |
#define MyAppExeName "clash_for_flutter.exe" | |
#define MyOutputName "clash_for_flutter" | |
[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={{B3039CF4-E394-42B6-971C-4BE97F322DE8} | |
AppName={#MyAppName} | |
AppVersion={#MyAppVersion} | |
;AppVerName={#MyAppName} {#MyAppVersion} | |
AppPublisher={#MyAppPublisher} | |
AppPublisherURL={#MyAppURL} | |
AppSupportURL={#MyAppURL} | |
AppUpdatesURL={#MyAppURL} | |
DefaultDirName={autopf}\{#MyOutputName} | |
DisableProgramGroupPage=yes | |
LicenseFile=..\..\..\LICENSE | |
; Remove the following line to run in administrative install mode (install for all users.) | |
PrivilegesRequired=lowest | |
OutputBaseFilename={#MyOutputName} | |
SetupIconFile=..\..\..\assets\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: ".\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\clash_for_flutter.exe" "Output\clash_for_flutter-$env:VERSION-windows-amd64.exe" | |
Compress-Archive -Path "Output\clash_for_flutter-$env:VERSION-windows-amd64.exe" -DestinationPath "Output\clash_for_flutter-$env:VERSION-windows-amd64.zip" | |
Remove-Item -Path "Output\clash_for_flutter-$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: build/windows/x64/Output/* | |
overwrite: true | |
build-linux: | |
runs-on: ubuntu-20.04 | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
- run: | | |
sudo apt-get update -y | |
sudo apt-get install -y locate ninja-build libgtk-3-dev libayatana-appindicator3-dev libnotify-dev \ | |
binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
curl -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o /usr/local/bin/appimagetool | |
chmod +x /usr/local/bin/appimagetool | |
cd core | |
go build -ldflags="-w -s" -buildmode=c-shared -o ./dist/libclash.so mapleafgo.cn/clash_for_flutter/core | |
cd ../ | |
dart pub global activate flutter_distributor | |
flutter_distributor package --platform=linux --targets=appimage,zip | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: dist/*/* | |
overwrite: true | |
build-macos-arm64-lib: | |
runs-on: ubuntu-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Build | |
run: | | |
cd core | |
go install src.techknowlogick.com/xgo@latest | |
xgo --targets=darwin/arm64 -ldflags="-w -s" -buildmode=c-shared -out=libclash . | |
mv libclash-*.dylib libclash.dylib | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: macos-arm64-lib | |
path: core/libclash.dylib | |
build-macos: | |
runs-on: macos-latest | |
needs: [ get-release, build-macos-arm64-lib ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
- name: Install appdmg | |
run: | | |
python3 -m pip install setuptools | |
npm install -g appdmg | |
- uses: actions/download-artifact@v3 | |
with: | |
name: macos-arm64-lib | |
path: lib-arm64 | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
PROJECT_DIR=$(pwd) | |
cd $PROJECT_DIR/core | |
go build -ldflags="-w -s" -buildmode=c-shared -o ./dist/libclash.dylib mapleafgo.cn/clash_for_flutter/core | |
cp ./dist/libclash.dylib $PROJECT_DIR/macos/Frameworks/amd64-lib/libclash.dylib | |
cp $PROJECT_DIR/lib-arm64/libclash.dylib $PROJECT_DIR/macos/Frameworks/arm64-lib/libclash.dylib | |
cd $PROJECT_DIR/macos/Frameworks | |
lipo -create -output libclash.dylib amd64-lib arm64-lib | |
cd $PROJECT_DIR | |
flutter build macos | |
cd build/macos/Build/Products/Release | |
cat>appdmg.json<<EOF | |
{ | |
"title": "Clash For Flutter", | |
"icon": "clash_for_flutter.app/Contents/Resources/AppIcon.icns", | |
"contents": [ | |
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" }, | |
{ "x": 192, "y": 344, "type": "file", "path": "clash_for_flutter.app" } | |
] | |
} | |
EOF | |
mkdir dist | |
appdmg appdmg.json dist/clash_for_flutter-$VERSION-macos.dmg | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: build/macos/Build/Products/Release/dist/* | |
overwrite: true |