From c2114a7f04f9b7ba04b60c506687b0809e8e2c11 Mon Sep 17 00:00:00 2001 From: JohanChane Date: Fri, 22 Mar 2024 10:30:15 +0800 Subject: [PATCH] Comment the code of update_profile_with_api. Delete unneccessary files. Update workflow files. --- .github/workflows/build_release.yml | 94 ++++++++++ Example/profiles/profile1.yaml | 46 +---- Example/templates/generic_tpl.yaml | 9 +- Example/templates/generic_tpl_with_all.yaml | 12 +- .../templates/generic_tpl_with_filter.yaml | 9 +- .../templates/generic_tpl_with_ruleset.yaml | 170 +++++++++++++++++ PKGBUILD | 44 ----- {Scoop => PkgManagers/Scoop}/clashtui.json | 0 clashtui/Cargo.lock | 21 +-- clashtui/Cargo.toml | 5 +- clashtui/api/src/clash.rs | 16 +- clashtui/api/src/lib.rs | 2 +- clashtui/build.rs | 31 +-- clashtui/src/app.rs | 4 +- clashtui/src/main.rs | 1 - clashtui/src/utils/tui.rs | 2 - clashtui/src/utils/tui/impl_profile.rs | 176 +++++++++--------- clashtui/src/utils/utils.rs | 2 - 18 files changed, 414 insertions(+), 230 deletions(-) create mode 100644 .github/workflows/build_release.yml create mode 100644 Example/templates/generic_tpl_with_ruleset.yaml delete mode 100644 PKGBUILD rename {Scoop => PkgManagers/Scoop}/clashtui.json (100%) diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 0000000..5742473 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,94 @@ +name: Build Release + +on: + push: + paths: + - 'clashtui/**' + +env: + CARGO_TERM_COLOR: always + +jobs: + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Mihomo + run: | + curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.1/mihomo-windows-amd64-v1.18.1.zip --output mihomo.zip + 7z x mihomo.zip + mihomo-windows-amd64.exe -d Example -f Example/basic_clash_config.yaml & + + - name: Cache Target + uses: actions/cache@v4 + with: + path: | + ./clashtui/target + ~/.cargo + key: ci-${{ runner.os }}-${{ hashFiles('./clashtui/Cargo.lock') }} + restore-keys: | + ci-${{ runner.os }}-${{ hashFiles('./clashtui/Cargo.lock') }} + ci-${{ runner.os }}- + + - name: Download Dependencies + run: cd clashtui && cargo fetch + + - name: Run tests + run: cd clashtui && cargo test --release --all + + - name: Build + run: cd clashtui && cargo build --release + + - name: Build Version + run: | + cd clashtui + cargo run --release -- -v >> version.txt + + - name: Pre Upload + run: | + mkdir artifacts + mv ./clashtui/target/release/clashtui.exe ./artifacts/clashtui.exe + mv ./clashtui/version.txt ./artifacts/version.txt + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Windows_Build + path: artifacts + retention-days: 5 + + release: + runs-on: ubuntu-latest + + needs: [build-windows] + + if: startsWith(github.ref, 'refs/tags/') + + permissions: + contents: write + + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ./artifacts + + - name: Get version + run: | + cd ./artifacts + echo CLASHTUI_VERSION="$(cat version.txt)" >> $GITHUB_ENV + + - name: Archive Release + run: | + cd ./artifacts + zip clashtui-windows-amd64-v${{ env.CLASHTUI_VERSION }}.zip -- clashtui.exe + + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + files: | + artifacts/clashtui-windows-amd64-v${{ env.CLASHTUI_VERSION }}.zip diff --git a/Example/profiles/profile1.yaml b/Example/profiles/profile1.yaml index 15fc9ed..70ccf1b 100644 --- a/Example/profiles/profile1.yaml +++ b/Example/profiles/profile1.yaml @@ -11,16 +11,19 @@ proxy-groups: - name: Entry type: select proxies: - - FilterFbAll -- name: FilterFbAll - type: fallback + - Auto-provider0 + - Select-provider0 +- name: Select-provider0 + type: select use: - provider0 - - provider1 - filter: (?i)美|us|unitedstates|united states|日本|jp|japan|韩|kr|korea|southkorea|south korea|新|sg|singapore +- name: Auto-provider0 <<: url: https://www.gstatic.com/generate_204 interval: 300 + type: url-test + use: + - provider0 - name: Entry-RuleMode type: select proxies: @@ -32,16 +35,6 @@ proxy-groups: - Entry - DIRECT proxy-providers: - provider1: - <<: - interval: 3600 - intehealth-check: - enable: true - url: https://www.gstatic.com/generate_204 - interval: 300 - type: http - url: https://www.example.com - path: proxy-providers/tpl/provider1.yaml provider0: <<: interval: 3600 @@ -50,7 +43,7 @@ proxy-providers: url: https://www.gstatic.com/generate_204 interval: 300 type: http - url: https://www.example.com + url: https://cdn.jsdelivr.net/gh/anaer/Sub@main/clash.yaml path: proxy-providers/tpl/provider0.yaml rule-anchor: ip: @@ -74,27 +67,6 @@ rule-providers: format: yaml rules: - RULE-SET,private,DIRECT -- DOMAIN-SUFFIX,cn.bing.com,DIRECT -- DOMAIN-SUFFIX,bing.com,Entry -- DOMAIN,aur.archlinux.org,Entry - GEOIP,lan,DIRECT,no-resolve - GEOSITE,biliintl,Entry -- GEOSITE,ehentai,Entry -- GEOSITE,github,Entry -- GEOSITE,twitter,Entry -- GEOSITE,youtube,Entry -- GEOSITE,google,Entry -- GEOSITE,telegram,Entry -- GEOSITE,netflix,Entry -- GEOSITE,bilibili,Entry-RuleMode -- GEOSITE,bahamut,Entry -- GEOSITE,spotify,Entry -- GEOSITE,geolocation-!cn,Entry -- GEOIP,google,Entry -- GEOIP,netflix,Entry -- GEOIP,telegram,Entry -- GEOIP,twitter,Entry -- GEOSITE,pixiv,Entry -- GEOSITE,CN,Entry-RuleMode -- GEOIP,CN,Entry-RuleMode - MATCH,Entry-LastMatch diff --git a/Example/templates/generic_tpl.yaml b/Example/templates/generic_tpl.yaml index 16b6a9f..af15bad 100644 --- a/Example/templates/generic_tpl.yaml +++ b/Example/templates/generic_tpl.yaml @@ -1,5 +1,6 @@ -pp: &pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} -delay_test: &delay_test {url: https://www.gstatic.com/generate_204, interval: 300} +proxy-anchor: + - delay_test: &pa_dt {url: https://www.gstatic.com/generate_204, interval: 300} + - proxy_provider: &pa_pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} proxy-groups: - name: "Entry" @@ -17,7 +18,7 @@ proxy-groups: tpl_param: providers: ["provider"] type: url-test - <<: *delay_test + <<: *pa_dt - name: "Entry-RuleMode" type: select @@ -35,7 +36,7 @@ proxy-providers: provider: tpl_param: type: http # type 字段要放在此处, 不能放入 pp。原因是要用于更新资源。 - <<: *pp + <<: *pa_pp rules: - GEOIP,lan,DIRECT,no-resolve diff --git a/Example/templates/generic_tpl_with_all.yaml b/Example/templates/generic_tpl_with_all.yaml index 118f160..56b9ae0 100644 --- a/Example/templates/generic_tpl_with_all.yaml +++ b/Example/templates/generic_tpl_with_all.yaml @@ -1,5 +1,7 @@ -pp: &pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} -delay_test: &delay_test {url: https://www.gstatic.com/generate_204, interval: 300} +proxy-anchor: + - delay_test: &pa_dt {url: https://www.gstatic.com/generate_204, interval: 300} + - proxy_provider: &pa_pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} + proxy-groups: - name: "Entry" @@ -24,13 +26,13 @@ proxy-groups: type: url-test proxies: - - <<: *delay_test + <<: *pa_dt - name: "Auto" tpl_param: providers: ["provider"] type: url-test - <<: *delay_test + <<: *pa_dt - name: "Entry-RuleMode" type: select @@ -48,7 +50,7 @@ proxy-providers: provider: tpl_param: type: http - <<: *pp + <<: *pa_pp rules: - GEOIP,lan,DIRECT,no-resolve diff --git a/Example/templates/generic_tpl_with_filter.yaml b/Example/templates/generic_tpl_with_filter.yaml index 2f42468..6204991 100644 --- a/Example/templates/generic_tpl_with_filter.yaml +++ b/Example/templates/generic_tpl_with_filter.yaml @@ -1,5 +1,6 @@ -pp: &pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} -delay_test: &delay_test {url: https://www.gstatic.com/generate_204, interval: 300} +proxy-anchor: + - delay_test: &pa_dt {url: https://www.gstatic.com/generate_204, interval: 300} + - proxy_provider: &pa_pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} proxy-groups: - name: "Entry" @@ -31,7 +32,7 @@ proxy-groups: tpl_param: providers: ["provider"] type: url-test - <<: *delay_test + <<: *pa_dt - name: "Entry-RuleMode" type: select @@ -49,7 +50,7 @@ proxy-providers: provider: # `provider` name is customizable. Generate proxy-providers which name is `provider`: provider0, provider1, ... tpl_param: type: http - <<: *pp + <<: *pa_pp rules: #- IN-TYPE,INNER,DIRECT # set inner type connection. e.g. update proxy-providers, rule-providers etc. diff --git a/Example/templates/generic_tpl_with_ruleset.yaml b/Example/templates/generic_tpl_with_ruleset.yaml new file mode 100644 index 0000000..cca1062 --- /dev/null +++ b/Example/templates/generic_tpl_with_ruleset.yaml @@ -0,0 +1,170 @@ +proxy-anchor: + - delay_test: &pa_dt {url: https://www.gstatic.com/generate_204, interval: 300} + - proxy_provider: &pa_pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} + +proxy-groups: + - name: "Entry" + type: select + proxies: + - + -