build #56
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: | |
FLUTTER_VERSION: "3.16.0" | |
CORE_VERSION: "1.18.1" | |
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: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
- name: Mkdir core | |
run: mkdir core | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
pushd core | |
Invoke-WebRequest -Uri "https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-windows-amd64.tar.gz" -OutFile "libclash.tar.gz" | |
tar -zxf libclash.tar.gz | |
mv build/*.dll libclash.dll | |
popd | |
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\x64\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-amd64: | |
runs-on: ubuntu-20.04 | |
needs: [ get-release ] | |
steps: | |
- 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: Mkdir core | |
run: mkdir core | |
- 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 | |
pushd core | |
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-linux-amd64.tar.gz -o libclash.tar.gz | |
tar -zxf libclash.tar.gz | |
mv build/*.so libclash.so | |
popd | |
dart pub global activate flutter_distributor | |
flutter_distributor package --platform=linux --targets=appimage,zip | |
mv dist/*/*.appimage dist/clash_for_flutter-$VERSION-linux-amd64.AppImage | |
mv dist/*/*.zip dist/clash_for_flutter-$VERSION-linux-amd64.zip | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: dist/*amd64* | |
overwrite: true | |
build-linux-arm64: | |
runs-on: ubuntu-20.04 | |
needs: [ get-release ] | |
steps: | |
- 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: Mkdir core | |
run: mkdir core | |
- 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 | |
pushd core | |
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-linux-arm64.tar.gz -o libclash.tar.gz | |
tar -zxf libclash.tar.gz | |
mv build/*.so libclash.so | |
popd | |
dart pub global activate flutter_distributor | |
flutter_distributor package --platform=linux --targets=appimage,zip | |
mv dist/*/*.appimage dist/clash_for_flutter-$VERSION-linux-arm64.AppImage | |
mv dist/*/*.zip dist/clash_for_flutter-$VERSION-linux-arm64.zip | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: dist/*arm64* | |
overwrite: true | |
build-macos: | |
runs-on: macos-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 | |
- name: Mkdir core | |
run: mkdir core | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
PROJECT_DIR=$(pwd) | |
pushd core | |
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-darwin-amd64.tar.gz -o libclash-amd64.tar.gz | |
tar -zxf libclash-amd64.tar.gz | |
mv build/*.dylib libclash-amd64.dylib | |
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-darwin-arm64.tar.gz -o libclash-arm64.tar.gz | |
tar -zxf libclash-arm64.tar.gz | |
mv build/*.dylib libclash-arm64.dylib | |
popd | |
mkdir -p $PROJECT_DIR/macos/Frameworks | |
cp build/libclash-amd64.dylib $PROJECT_DIR/macos/Frameworks/amd64-lib | |
cp build/libclash-arm64.dylib $PROJECT_DIR/macos/Frameworks/arm64-lib | |
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/*.dmg | |
overwrite: true | |
build-android: | |
runs-on: ubuntu-latest | |
needs: [ get-release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: "liberica" | |
java-version: "17" | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
- name: Mkdir core | |
run: mkdir core | |
- name: Build | |
env: | |
VERSION: ${{ needs.get-release.outputs.tag_name }} | |
run: | | |
pushd core | |
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-android-arm64.tar.gz -o libclash.tar.gz | |
tar -zxf libclash.tar.gz | |
mv build/*.aar libclash.aar | |
popd | |
mkdir -p android/app/libs | |
mv core/libclash.aar android/app/libs/libclash.aar | |
flutter build apk --release --target-platform android-arm64 | |
cd build/app/outputs/flutter-apk | |
mv app-release.apk clash_for_flutter-$VERSION-arm64.apk | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.get-release.outputs.upload_url }} | |
asset_path: build/app/outputs/flutter-apk/*.apk | |
overwrite: true |