From 84673ed4b074bbbff0e7b6492d76b760f9d784cc Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Fri, 22 Sep 2023 14:16:21 +0330 Subject: [PATCH] Change build setup --- .github/workflows/{ci.yml => build.yml} | 33 +--- .github/workflows/release.yml | 251 ------------------------ Makefile | 19 +- README.md | 80 ++++---- libcore | 2 +- 5 files changed, 58 insertions(+), 327 deletions(-) rename .github/workflows/{ci.yml => build.yml} (91%) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 91% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index db4d4d7d..3a91ca83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: CI & Build +name: Build on: push: branches: @@ -9,13 +9,15 @@ on: - '**.md' - 'docs/**' - '.github/**' - - '!.github/workflows/ci.yml' + - '!.github/workflows/build.yml' pull_request: branches: - main concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true +env: + CHANNEL: ${{ github.ref_type == 'tag' && endsWith(github.ref_name, 'dev') && 'dev' || github.ref_type != 'tag' && 'dev' || 'prod' }} jobs: build: permissions: write-all @@ -56,20 +58,6 @@ jobs: - name: checkout uses: actions/checkout@v3 - # - name: Cache Flutter dependencies - # uses: actions/cache@v3 - # with: - # path: | - # ~/.pub-cache - # ~/.gradle/caches - # ~/.gradle/wrapper - # ~/.npm - # ~/.cache - # ~/go/pkg/mod - # key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }} - # restore-keys: | - # ${{ runner.os }}-pub-cache- - - name: Setup Flutter uses: subosito/flutter-action@v2 with: @@ -118,8 +106,6 @@ jobs: make gen - name: Get Libs ${{ matrix.platform }} - env: - BRANCH: ${{ github.ref_type == 'tag' && 'RELEASE' || 'DEVELOP' }} run: | make ${{ matrix.platform }}-libs @@ -145,12 +131,12 @@ jobs: - name: Release ${{ matrix.platform }} env: - BRANCH: ${{ github.ref_type == 'tag' && 'RELEASE' || 'DEVELOP' }} SENTRY_DSN: ${{ secrets.SENTRY_DSN }} run: | make ${{ matrix.platform }}-release - name: Upload Debug Symbols + if: ${{ github.ref_type == 'tag' }} env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} @@ -215,7 +201,7 @@ jobs: upload-draft: permissions: write-all - if: ${{ github.ref_type=='branch' }} + if: ${{ github.ref_type == 'branch' }} needs: [build] runs-on: ubuntu-latest steps: @@ -238,8 +224,7 @@ jobs: - name: Create or Update Draft Release uses: softprops/action-gh-release@v1 - if: github.ref_type != 'tag' - #&& success() + if: ${{ github.ref_type != 'tag' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -250,7 +235,7 @@ jobs: upload-release: permissions: write-all - if: ${{ github.ref_type=='tag' }} + if: ${{ github.ref_type == 'tag' }} needs: [build] runs-on: ubuntu-latest steps: @@ -269,7 +254,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - prerelease: ${{ contains(github.ref_name,'dev') }} + prerelease: ${{ CHANNEL == 'dev' }} tag_name: ${{ github.ref_name }} files: ./out/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 94de53a8..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,251 +0,0 @@ -name: build - -on: - workflow_dispatch: - # release: - # types: [ published ] - # workflow_run: - # workflows: ["build"] - # types: - # - completed -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@v3 - - uses: thebritican/fetch-latest-release@v2.0.0 - id: get-release - build-windows: - runs-on: windows-latest - needs: [ get-release ] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "^1.20" - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.2' - 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 ../ - - dart pub global activate flutter_distributor - flutter_distributor package --platform=windows --targets=exe - - - uses: actions/upload-artifact@v3 - with: - name: android - path: dist/*/* - retention-days: 2 - - name: Upload - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ needs.get-release.outputs.upload_url }} - asset_path: dist/*/* - overwrite: true - - - build-android: - runs-on: ubuntu-latest - needs: [ get-release ] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4.0.1 - with: - go-version: "^1.20" - - name: Set up MinGW - uses: egor-tensin/setup-mingw@v2 - with: - platform: x64 - - - name: Setup Java - - uses: actions/setup-java@v3 - with: - distribution: "zulu" - java-version: 11 - - - name: Setup Android SDK - if: matrix.platform == 'android' - uses: android-actions/setup-android@v2 - - - name: Get Dependencies - run: | - flutter pub get - - - name: Generate - run: | - dart run build_runner build --delete-conflicting-outputs - dart run slang - - - - name: Generate Libs Android - run: | - make android-libs - - - name: Release Android - run: | - flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi - - - name: Copy to out - run: | - mkdir out - IFS=',' read -r -a EXT_ARRAY <<< "${{ matrix.targets }}" - - # Loop over extensions - for EXT in "${EXT_ARRAY[@]}"; do - # Find all files with this extension in SRC_DIR, and copy them to DST_DIR - find "." -type f -name "*.$EXT" -exec cp {} "out" \; - done - - - uses: actions/upload-artifact@v3 - with: - name: android - path: ./out - retention-days: 2 - - - name: Upload - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ needs.get-release.outputs.upload_url }} - asset_path: out/* - overwrite: true - - build-linux: - runs-on: ubuntu-20.04 - needs: [ get-release ] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "^1.20" - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.2' - 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 - - - uses: actions/upload-artifact@v3 - with: - name: linux - path: dist/*/* - retention-days: 2 - - - 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@v3 - - uses: actions/setup-go@v3 - with: - go-version: "^1.20" - - run: mkdir -p ~/image-cache - - id: image-cache - uses: actions/cache@v3 - with: - path: ~/image-cache - key: image-cache-xgo-v1.20 - - if: steps.image-cache.outputs.cache-hit != 'true' - run: | - docker pull techknowlogick/xgo:go-1.20.x - docker save -o ~/image-cache/xgo.tar techknowlogick/xgo:go-1.20.x - - if: steps.image-cache.outputs.cache-hit == 'true' - run: docker load -i ~/image-cache/xgo.tar - - 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 - retention-days: 2 - build-macos: - runs-on: macos-latest - needs: [ get-release, build-macos-arm64-lib ] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "^1.20" - - uses: actions/setup-node@v3 - with: - node-version: 16 - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.2' - channel: 'stable' - - name: Install appdmg - run: npm install -g appdmg - - name: Mkdir Frameworks - run: mkdir -p macos/Frameworks - - uses: actions/download-artifact@v3 - with: - name: macos-arm64-lib - path: macos/Frameworks - - name: Build - env: - VERSION: ${{ needs.get-release.outputs.tag_name }} - run: | - PROJECT_DIR=$(pwd) - - dart pub global activate flutter_distributor - - flutter_distributor package --platform=macos --targets=dmg - mv dist/$VERSION/*-macos.dmg dist/$VERSION/macos-arm64.dmg - - cd $PROJECT_DIR/core - go build -ldflags="-w -s" -buildmode=c-shared -o ./dist/libclash.dylib mapleafgo.cn/clash_for_flutter/core - cp -f ./dist/libclash.dylib $PROJECT_DIR/macos/Frameworks/libclash.dylib - cd $PROJECT_DIR - - flutter_distributor package --platform=macos --targets=dmg - mv dist/$VERSION/*-macos.dmg dist/$VERSION/macos-amd64.dmg - - - uses: actions/upload-artifact@v3 - with: - name: macos - path: dist/*/* - retention-days: 2 - - name: Upload - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ needs.get-release.outputs.upload_url }} - asset_path: dist/*/* - overwrite: true \ No newline at end of file diff --git a/Makefile b/Makefile index c945b0db..d1fad884 100644 --- a/Makefile +++ b/Makefile @@ -5,21 +5,19 @@ ANDROID_OUT=./android/app/libs DESKTOP_OUT=./libcore/bin GEO_ASSETS_DIR=./assets/core -# BRANCH=$(shell git branch --show-current) -VERSION=$(shell git describe --tags --abbrev=0 || echo "unknown version") - CORE_NAME=hiddify-libcore -ifeq ($(BRANCH),RELEASE) +ifeq ($(CHANNEL),prod) CORE_URL=https://github.com/hiddify/hiddify-next-core/releases/download/v$(core.version) else CORE_URL=https://github.com/hiddify/hiddify-next-core/releases/download/draft endif -ifeq ($(BRANCH),RELEASE) +ifeq ($(CHANNEL),prod) FLAVOR=prod else FLAVOR=dev endif + TARGET=lib/main_$(FLAVOR).dart BUILD_ARGS=--dart-define sentry_dsn=$(SENTRY_DSN) DISTRIBUTOR_ARGS=--skip-clean --build-target $(TARGET) --build-dart-define sentry_dsn=$(SENTRY_DSN) @@ -99,9 +97,7 @@ build-ios-libs: #not tested make -C libcore -f Makefile ios && mv $(BINDIR)/$(CORE_NAME)-ios.xcframework $(DESKTOP_OUT)/libcore.xcframework - - -release: ## Create a new tag for release. +release: # Create a new tag for release. @echo "previous version was $$(git describe --tags $$(git rev-list --tags --max-count=1))" @echo "WARNING: This operation will creates version tag and push to github" @bash -c '\ @@ -109,17 +105,16 @@ release: ## Create a new tag for release. echo $$TAG &&\ [[ "$$TAG" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(\.dev)?$$ ]] || { echo "Incorrect tag. e.g., 1.2.3 or 1.2.3.dev"; exit 1; } && \ IFS="." read -r -a VERSION_ARRAY <<< "$$TAG" && \ - BUILD_NUMBER=$$(( $${VERSION_ARRAY[0]} * 10000 + $${VERSION_ARRAY[1]} * 100 + $${VERSION_ARRAY[2]} )) && \ VERSION_STR="$${VERSION_ARRAY[0]}.$${VERSION_ARRAY[1]}.$${VERSION_ARRAY[2]}" && \ - echo "version: $${VERSION_STR}+$${BUILD_NUMBER}" && \ - sed -i "s/version: .*/version: $${VERSION_STR}+$${BUILD_NUMBER}/g" pubspec.yaml && \ + echo "version: $${VERSION_STR}" && \ + sed -i "s/version: .*/version: $${VERSION_STR}/g" pubspec.yaml && \ git tag $${TAG} > /dev/null && \ gitchangelog > changelog.md || { git tag -d $${TAG}; echo "Please run pip install git gitchangelog pystache mustache markdown"; exit 2; } && \ git tag -d $${TAG} > /dev/null && \ git add pubspec.yaml changelog.md && \ # ./update_translations.sh && \ # git add assets/translations/* && \ - git commit -m "release: version $${TAG} 🚀" && \ + git commit -m "release: version $${TAG}" && \ echo "creating git tag : v$${TAG}" && \ git tag v$${TAG} && \ git push -u origin HEAD --tags && \ diff --git a/README.md b/README.md index 95e1a841..b1c2be6a 100644 --- a/README.md +++ b/README.md @@ -2,57 +2,59 @@

-

Hiddify Multi-platform Proxy Client

-

⚠️ Hiddify Next is still in early development phase ⚠️

-

Windows, Android, Linux and macOS are supported (PR for iOS welcome)

+

Multi-platform, Sing-box (universal proxy toolchain) client

-## Download Hiddify Next Pre-Release -- Android: [Universal](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-android-universal.apk) - [Arm64](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-android-arm64.apk) - [Arm7](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-android-arm7.apk) - [x86_64](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-android-x86_64.apk) -- Windows: [x64 Setup](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-windows-x64-setup.exe) - [x64 Portable](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-windows-x64-portable.zip) -- Linux: [x64 AppImage](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-linux-x64.AppImage.zip) -- macOS: [Universal (x64, M1, M2)](https://github.com/hiddify/hiddify-next/releases/download/draft/hiddify-macos-universal.dmg) +## Features +- Multi-platform support: Android, Windows, Linux and macOS (PRs for iOS are welcome) +- Easy to use with a simple UI +- Sing-box, Clash, Clash meta, V2ray configs supported -## Support -- V2Ray Subscription link (e.g., vless:// vmess:// ss:// trojan:// tuic://) -- Clash / Clash Meta link -- Singbox Config +## Download + +For latest releases (including pre-releases), visit [releases page](https://github.com/hiddify/hiddify-next/releases) + +- Android: [Universal](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-android-universal.apk) - [Arm64](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-android-arm64.apk) - [Arm7](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-android-arm7.apk) - [x86_64](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-android-x86_64.apk) + +- Windows: [x64 Setup](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-windows-x64-setup.exe) - [x64 Portable](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-windows-x64-portable.zip) + +- Linux: [x64 AppImage](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-linux-x64.AppImage.zip) + +- macOS: [Universal (x64, M series)](https://github.com/hiddify/hiddify-next/releases/latest/download/hiddify-macos-universal.dmg) ## Build from source Hiddify Next relies on [core library](https://github.com/hiddify/hiddify-next-core) made with GO. if you're interested in building/contributing to that as well follow instructions there. ### requirements: - - Flutter v3.13+ - - Make - - Android SDK - - - - - This project uses [flutter_distributor](https://github.com/leanflutter/flutter_distributor) for packaging. +- Flutter v3.13+ +- Make +- Android SDK - ```shell - # fetch dependencies and build generated files - $ make get gen +This project uses [flutter_distributor](https://github.com/leanflutter/flutter_distributor) for packaging. - # fetch geo assets - $ make get-geo-assets +```shell +# fetch dependencies and build generated files +$ make get translate gen - for platform in [windows linux macos android]: - # fetch native libraries for respective platforms, follow core lib instructions for building - $ make $platform-libs - $ make release-$platform - - # example: - $ make windows-libs - $ make windows-release - ``` +# fetch geo assets +$ make get-geo-assets + +for platform in [windows linux macos android]: + # fetch native libraries for respective platforms, follow core lib instructions for building + $ make $platform-libs + $ make release-$platform + +# example: + $ make windows-libs + $ make windows-release +``` ## Acknowledgements - - [Singbox](https://github.com/SagerNet/sing-box) - - [Clash](https://github.com/Dreamacro/clash) - - [Clash Meta](https://github.com/MetaCubeX/Clash.Meta) - - [FClash](https://github.com/Fclash/Fclash) - - [Others](./pubspec.yaml) + +- [Singbox](https://github.com/SagerNet/sing-box) +- [Clash](https://github.com/Dreamacro/clash) +- [Clash Meta](https://github.com/MetaCubeX/Clash.Meta) +- [FClash](https://github.com/Fclash/Fclash) +- [Others](./pubspec.yaml) diff --git a/libcore b/libcore index 1b31bd7a..00bc20b8 160000 --- a/libcore +++ b/libcore @@ -1 +1 @@ -Subproject commit 1b31bd7a4bf71f6d2373fb2dfd0e0395492c4c7b +Subproject commit 00bc20b86a51911988c8ffb76f97d5649f356936