From c2acddf75955665637745a98bfa6b4e0a223f180 Mon Sep 17 00:00:00 2001 From: Jackhr-arch <63526062+Jackhr-arch@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:11:08 +0000 Subject: [PATCH] fix artifacts build --- .github/workflows/CI.yml | 19 +++++++------------ Makefile.toml | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5f9d9dd..b4f738b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,7 @@ jobs: with: fetch-depth: 0 - - name: Cache Target + - name: Cache if: ${{ ! startsWith(github.ref, 'refs/tags/') }} uses: actions/cache@v4 with: @@ -32,21 +32,24 @@ jobs: ci-${{ runner.os }}-${{ hashFiles('./Cargo.lock') }} ci-${{ runner.os }}- - - name: Download Dependencies + - name: Test run: | cargo install --debug cargo-make cargo make ci + - name: Build + run: cargo make upx + - name: upload artifacts uses: actions/upload-artifact@v4 with: - name: artifacts + name: Artifacts-${{ runner.os }} path: artifacts retention-days: 5 release: - if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') needs: build @@ -60,14 +63,6 @@ jobs: merge-multiple: true path: ./artifacts - - name: UPX compress - run: | - chmod +x ./artifacts/* - curl -OL https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-amd64_linux.tar.xz - tar -xf upx-4.2.4-amd64_linux.tar.xz - cp ./upx-4.2.4-amd64_linux/upx . - ./upx ./artifacts/* - - name: Create Release uses: softprops/action-gh-release@v2 with: diff --git a/Makefile.toml b/Makefile.toml index 979ebe3..484a150 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,14 +1,21 @@ [env] # use for build arm64 in docker -CROSS_CONTAINER_IN_CONTAINER = true +# CROSS_CONTAINER_IN_CONTAINER = true [tasks.ci] dependencies = ["setup_mihomo", "ci-flow"] script = ["rm mihomo", "rm Doc/clash_test/cache.db"] +[tasks.ci.windows] +# ignore this shit +dependencies = [] +script = "" + [tasks.setup_mihomo.windows] +script_runner = "pwsh" +script_extension = "ps1" script = ''' curl --output mihomo.zip -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.4/mihomo-windows-amd64-v1.18.4.zip 7z x mihomo.zip @@ -43,7 +50,9 @@ script = ''' ''' [tasks.clear-artifacts] +private = true script_runner = "@shell" +ignore_errors = true script = ["rm -r artifacts"] [tasks.build_deb] @@ -63,3 +72,28 @@ script = ''' cargo build --bin clashtui --all-features cargo build --bin clashtui --all-features --release ''' + + +[tasks.upx.linux] +dependencies = ["release"] +script = ''' + chmod +x artifacts/* + curl -OL https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-amd64_linux.tar.xz + tar -xf upx-4.2.4-amd64_linux.tar.xz + rm upx-4.2.4-amd64_linux.tar.xz + cp ./upx-4.2.4-amd64_linux/upx . + rm -r ./upx-4.2.4-amd64_linux + ./upx artifacts/*.release artifacts/*.debug + rm upx +''' + +[tasks.upx.windows] +dependencies = ["release"] +script = ''' + curl -OL https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip + tar -xf upx-4.2.4-win64.zip + cp ./upx-4.2.4-win64/upx.exe . + rm -r ./upx-4.2.4-win64 + ./upx.exe artifacts/*.exe + rm upx.exe +'''