From 06811748a97686b925ef0249f166fe70dafb4666 Mon Sep 17 00:00:00 2001 From: bitxeno <137328844+bitxeno@users.noreply.github.com> Date: Sat, 22 Jun 2024 06:54:11 +0000 Subject: [PATCH] feat: add tvos17 support --- .github/workflows/beta.yml | 95 ---------- .github/workflows/build.yml | 19 +- .github/workflows/clean_package.yml | 8 +- .github/workflows/issue_close_inactive.yml | 6 +- .github/workflows/release-nightly.yml | 192 +++++++++++++++++++++ .github/workflows/release.yml | 163 ++++++++++++----- Dockerfile | 2 +- go.mod | 10 +- go.sum | 23 +-- internal/app/config.go | 2 +- internal/task/task.go | 52 ++++-- web/static/src/page/install/index.vue | 24 +-- web/static/yarn.lock | 10 -- web/web.go | 5 +- 14 files changed, 384 insertions(+), 227 deletions(-) delete mode 100644 .github/workflows/beta.yml create mode 100644 .github/workflows/release-nightly.yml diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml deleted file mode 100644 index 943cbc2..0000000 --- a/.github/workflows/beta.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Attention: -# - Need goto [Settings -> Actions -> general] -# - Set [workflow permissions] to "Read and write permissions" -name: "🚀 Beta" - -# on events -on: - workflow_dispatch: - -# jobs -jobs: - beta: - name: Generate beta builds - strategy: - matrix: - go_version: [1.18.x] - runs-on: ubuntu-latest - steps: - # step 1: checkout repository code - - name: Checkout the repository - uses: actions/checkout@v3 - - # step 2: setup build envirement - - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go_version }} - - uses: actions/setup-node@v2 - with: - node-version: "16" - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - # step 3: set workflow variables - - name: Initialize workflow variables - id: vars - run: | - echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT - echo "BUILDDATE=$(date '+%F-%T')" >> $GITHUB_OUTPUT - echo "COMMIT=$(git rev-parse --verify HEAD)" >> $GITHUB_OUTPUT - echo "APP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT - echo "REPO=$(echo 'github.com/${{ github.repository }}')" >> $GITHUB_OUTPUT - echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT - - if [ ! -z $DOCKER_TOKEN ]; then echo "HAS_DOCKER_TOKEN=${HAS_DOCKER_TOKEN}" >> $GITHUB_OUTPUT; fi - env: - DOCKER_TOKEN: "${{ secrets.DOCKER_TOKEN }}" - - # step 4: generate build files - - name: build frontend - run: cd ./view && npm install && npm run build - - name: Generate build files - uses: crazy-max/ghaction-xgo@v2 - with: - xgo_version: latest - go_version: ${{ matrix.go_version }} - dest: build - prefix: ${{steps.vars.outputs.APP_NAME}} - targets: linux/amd64,linux/arm64 - v: true - x: false - ldflags: -w -s -X ${{steps.vars.outputs.REPO}}/internal/version.Version=${{steps.vars.outputs.VERSION}} -X ${{steps.vars.outputs.REPO}}/internal/version.BuildDate=${{steps.vars.outputs.BUILDDATE}} -X ${{steps.vars.outputs.REPO}}/internal/version.Commit=${{steps.vars.outputs.COMMIT}} -X ${{steps.vars.outputs.REPO}}/internal/mode.Mode=production - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{steps.vars.outputs.APP_NAME}} - path: build - - # step 7.2: push to GitHub Container Registry - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }} - - name: Build and push Docker images to ghci - uses: docker/build-push-action@v4 - with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ghcr.io/${{ github.repository }}:beta - labels: ${{ steps.meta.outputs.labels }} - build-args: | - APP_NAME=${{steps.vars.outputs.APP_NAME}} - VERSION=${{steps.vars.outputs.VERSION}} - BUILDDATE=${{steps.vars.outputs.BUILDDATE}} - COMMIT=${{steps.vars.outputs.COMMIT}} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7635c92..d66197c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,22 +11,23 @@ jobs: build: strategy: matrix: - go_version: [1.18.x] + go_version: [1.21.x] runs-on: ubuntu-latest steps: - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go_version }} - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: - node-version: "16" - - uses: actions/checkout@v3 + node-version: "20" + - uses: actions/checkout@v4 - name: build frontend - run: cd ./view && npm install && npm run build - - uses: golangci/golangci-lint-action@v3 + run: cd ./web/static && npm install && npm run build + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 with: - version: v1.53.2 - args: --out-format=colored-line-number --timeout=5m + version: v1.58 + args: --timeout=5m - run: go mod download - # - run: go test -coverprofile=coverage.txt -covermode=atomic ./... + - run: go test -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/.github/workflows/clean_package.yml b/.github/workflows/clean_package.yml index c3d4c71..509dba6 100644 --- a/.github/workflows/clean_package.yml +++ b/.github/workflows/clean_package.yml @@ -5,8 +5,8 @@ name: "🗑️ Clean Package" # Controls when the workflow will run on: - schedule: - - cron: "0 0 1 * *" # the first day of the month + # schedule: + # - cron: "0 0 * * 1" # the first day of the week # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -28,8 +28,8 @@ jobs: uses: snok/container-retention-policy@v2 with: image-names: ${{steps.vars.outputs.APP_NAME}} - cut-off: A week ago UTC + cut-off: A month ago UTC keep-at-least: 10 - skip-tags: latest + skip-tags: latest, beta, alpha, main, master account-type: personal token: ${{ secrets.PAT }} diff --git a/.github/workflows/issue_close_inactive.yml b/.github/workflows/issue_close_inactive.yml index 4bb86ce..41767f4 100644 --- a/.github/workflows/issue_close_inactive.yml +++ b/.github/workflows/issue_close_inactive.yml @@ -1,8 +1,8 @@ name: "🚫 Close Inactive" on: - schedule: - - cron: "0 0 * * 1" + # schedule: + # - cron: "0 0 * * 1" # the first day of the week workflow_dispatch: jobs: @@ -20,4 +20,4 @@ jobs: days-before-stale: 30 days-before-close: 0 days-before-pr-stale: -1 - days-before-pr-close: -1 \ No newline at end of file + days-before-pr-close: -1 diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml new file mode 100644 index 0000000..6f9fd34 --- /dev/null +++ b/.github/workflows/release-nightly.yml @@ -0,0 +1,192 @@ +name: "🚀 Release Nightly" + +# on events +on: + # schedule: + # - cron: '0 0 * * *' # runs daily at 00:00 + workflow_dispatch: + # push: + # branches: [main, master, release/v*] + +# jobs +jobs: + check: + name: Check has new commits today + permissions: + contents: write + runs-on: ubuntu-latest + outputs: + new_commit_count: ${{steps.commit_check.outputs.new_commit_count}} + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Check for new commits + id: commit_check + run: echo "new_commit_count=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_OUTPUT + + build: + name: Generate cross-platform builds + if: ${{needs.check.outputs.new_commit_count > 0}} + needs: [check] + permissions: + contents: write + strategy: + matrix: + go_version: [1.21.x] + runs-on: ubuntu-latest + outputs: + VERSION: ${{steps.vars.outputs.VERSION}} + BUILDDATE: ${{steps.vars.outputs.BUILDDATE}} + COMMIT: ${{steps.vars.outputs.COMMIT}} + APP_NAME: ${{steps.vars.outputs.APP_NAME}} + PUSH_DOCKERHUB: ${{steps.vars.outputs.PUSH_DOCKERHUB}} + steps: + # step 1: checkout repository code + - name: Checkout the repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # step 2: setup build envirement + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go_version }} + - uses: actions/setup-node@v4 + with: + node-version: "20" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # step 3: set workflow variables + - id: metadata + uses: ahmadnassri/action-metadata@v2 + - name: Initialize workflow environments variables + id: vars + run: | + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT + echo "BUILDDATE=$(date '+%F-%T')" >> $GITHUB_OUTPUT + echo "COMMIT=$(git rev-parse --verify HEAD)" >> $GITHUB_OUTPUT + echo "APP_NAME=${{ steps.metadata.outputs.repository_name }}" >> $GITHUB_OUTPUT + echo "REPO=$(echo 'github.com/${{ github.repository }}')" >> $GITHUB_OUTPUT + echo "BRANCH=${{ steps.metadata.outputs.repository_default_branch }}" >> $GITHUB_OUTPUT + + if [ ! -z $DOCKER_TOKEN ]; then echo "PUSH_DOCKERHUB=1" >> $GITHUB_OUTPUT; fi + env: + DOCKER_TOKEN: "${{ secrets.DOCKER_TOKEN }}" + + # step 4: generate build files + - name: build frontend + run: cd ./web/static && npm install && npm run build + - name: Generate build files + uses: crazy-max/ghaction-xgo@v2 + env: + CGO_ENABLED: "0" + with: + xgo_version: latest + go_version: ${{ matrix.go_version }} + dest: build + prefix: ${{steps.vars.outputs.APP_NAME}} + targets: windows/386,windows/amd64,linux/386,linux/amd64,darwin/386,darwin/amd64,linux/386,linux/arm64 + v: true + x: false + ldflags: -w -s -X ${{steps.vars.outputs.REPO}}/internal/app/build.Version=${{steps.vars.outputs.VERSION}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.BuildDate=${{steps.vars.outputs.BUILDDATE}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Commit=${{steps.vars.outputs.COMMIT}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Mode=production + + # step 5: Upload binary to artifact + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{steps.vars.outputs.APP_NAME}} + path: build + retention-days: 1 + + dockerhub: + name: Push to DockerHub + if: ${{needs.build.outputs.PUSH_DOCKERHUB}} + needs: [build] + permissions: + contents: read + packages: write + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.APP_NAME}} + path: build + - name: Login to DockerHub + if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} + - name: Build and push Docker images to DockerHub + if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} + uses: docker/build-push-action@v5 + with: + context: . + push: true + provenance: false + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + APP_NAME=${{needs.build.outputs.APP_NAME}} + VERSION=${{needs.build.outputs.VERSION}} + BUILDDATE=${{needs.build.outputs.BUILDDATE}} + COMMIT=${{needs.build.outputs.COMMIT}} + + ghcr: + name: Push to GitHub Container Registry + needs: [build] + permissions: + contents: read + packages: write + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.APP_NAME}} + path: build + - name: Display structure of downloaded files + run: ls -R + working-directory: build + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + - name: Build and push Docker images to ghci + uses: docker/build-push-action@v5 + with: + context: . + push: true + provenance: false + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + APP_NAME=${{needs.build.outputs.APP_NAME}} + VERSION=${{needs.build.outputs.VERSION}} + BUILDDATE=${{needs.build.outputs.BUILDDATE}} + COMMIT=${{needs.build.outputs.COMMIT}} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 72b6e0f..e7a03e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,3 @@ -# Attention: -# - Need goto [Settings -> Actions -> general] -# - Set [workflow permissions] to "Read and write permissions" name: "🚀 Release" # on events @@ -10,17 +7,24 @@ on: # jobs jobs: - # generate build cross-platform build files - release: + build: name: Generate cross-platform builds + permissions: + contents: write strategy: matrix: - go_version: [1.18.x] + go_version: [1.21.x] runs-on: ubuntu-latest + outputs: + VERSION: ${{steps.vars.outputs.VERSION}} + BUILDDATE: ${{steps.vars.outputs.BUILDDATE}} + COMMIT: ${{steps.vars.outputs.COMMIT}} + APP_NAME: ${{steps.vars.outputs.APP_NAME}} + PUSH_DOCKERHUB: ${{steps.vars.outputs.PUSH_DOCKERHUB}} steps: # step 1: checkout repository code - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,63 +32,88 @@ jobs: - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go_version }} - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "20" - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 # step 3: set workflow variables - - name: Initialize workflow variables + - id: metadata + uses: ahmadnassri/action-metadata@v2 + - name: Initialize workflow environments variables id: vars run: | - echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT echo "BUILDDATE=$(date '+%F-%T')" >> $GITHUB_OUTPUT echo "COMMIT=$(git rev-parse --verify HEAD)" >> $GITHUB_OUTPUT - echo "APP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT + echo "APP_NAME=${{ steps.metadata.outputs.repository_name }}" >> $GITHUB_OUTPUT echo "REPO=$(echo 'github.com/${{ github.repository }}')" >> $GITHUB_OUTPUT - echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT + echo "BRANCH=${{ steps.metadata.outputs.repository_default_branch }}" >> $GITHUB_OUTPUT - if [ ! -z $DOCKER_TOKEN ]; then echo "HAS_DOCKER_TOKEN=${HAS_DOCKER_TOKEN}" >> $GITHUB_OUTPUT; fi + if [ ! -z $DOCKER_TOKEN ]; then echo "PUSH_DOCKERHUB=1" >> $GITHUB_OUTPUT; fi env: DOCKER_TOKEN: "${{ secrets.DOCKER_TOKEN }}" # step 4: generate build files - name: build frontend - run: cd ./view && npm install && npm run build + run: cd ./web/static && npm install && npm run build - name: Generate build files uses: crazy-max/ghaction-xgo@v2 + env: + CGO_ENABLED: "0" with: xgo_version: latest go_version: ${{ matrix.go_version }} dest: build prefix: ${{steps.vars.outputs.APP_NAME}} - targets: linux/amd64,linux/arm64 + targets: windows/386,windows/amd64,linux/386,linux/amd64,darwin/386,darwin/amd64,linux/386,linux/arm64 v: true x: false - ldflags: -w -s -X ${{steps.vars.outputs.REPO}}/internal/version.Version=${{steps.vars.outputs.VERSION}} -X ${{steps.vars.outputs.REPO}}/internal/version.BuildDate=${{steps.vars.outputs.BUILDDATE}} -X ${{steps.vars.outputs.REPO}}/internal/version.Commit=${{steps.vars.outputs.COMMIT}} -X ${{steps.vars.outputs.REPO}}/internal/mode.Mode=production + ldflags: -w -s -X ${{steps.vars.outputs.REPO}}/internal/app/build.Version=${{steps.vars.outputs.VERSION}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.BuildDate=${{steps.vars.outputs.BUILDDATE}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Commit=${{steps.vars.outputs.COMMIT}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Mode=production - # step 5: compress build files - - name: Compress build files - run: cd ./build && for i in *; do tar -czf $i.tar.gz $i; done && cd .. + # step 5: Upload binary to artifact + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{steps.vars.outputs.APP_NAME}} + path: build + retention-days: 1 - # step 6: Upload binary to GitHub Release + # step 6: Generate Changelog - name: Generate Changelog id: changelog uses: bitxeno/changelogithub-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} + # output-file: ./docs/CHANGELOG.md types: | feat fix perf refactor - tweak + chore + docs + # build + # test + # style + # ci + # - name: Git commit changelog + # uses: EndBug/add-and-commit@v9 + # with: + # default_author: github_actions + # add: "docs/" + # message: "docs: release notes for ${{ github.ref_name }}" + # push: "origin HEAD:${{ steps.vars.outputs.BRANCH }}" + + # step 7: Upload binary to GitHub Release + - name: Compress build files + run: cd ./build && for i in *; do tar -czf $i.tar.gz $i; done && cd .. - name: Upload binary to GitHub Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 if: "startsWith(github.ref, 'refs/tags/')" with: files: | @@ -93,28 +122,67 @@ jobs: body: ${{ steps.changelog.outputs.changelog }} fail_on_unmatched_files: true - # step 7.1: push to DockerHub + dockerhub: + name: Push to DockerHub + if: ${{needs.build.outputs.PUSH_DOCKERHUB}} + needs: [build] + permissions: + contents: read + packages: write + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.APP_NAME}} + path: build - name: Login to DockerHub - if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN == 'true' }} - uses: docker/login-action@v1 + if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} - name: Build and push Docker images to DockerHub - if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN == 'true' }} - uses: docker/build-push-action@v2 + if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} + uses: docker/build-push-action@v5 with: context: . push: true + provenance: false platforms: linux/amd64,linux/arm64 - tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} build-args: | - APP_NAME=${{steps.vars.outputs.APP_NAME}} - VERSION=${{steps.vars.outputs.VERSION}} - BUILDDATE=${{steps.vars.outputs.BUILDDATE}} - COMMIT=${{steps.vars.outputs.COMMIT}} + APP_NAME=${{needs.build.outputs.APP_NAME}} + VERSION=${{needs.build.outputs.VERSION}} + BUILDDATE=${{needs.build.outputs.BUILDDATE}} + COMMIT=${{needs.build.outputs.COMMIT}} - # step 7.2: push to GitHub Container Registry + ghcr: + name: Push to GitHub Container Registry + needs: [build] + permissions: + contents: read + packages: write + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.APP_NAME}} + path: build + - name: Display structure of downloaded files + run: ls -R + working-directory: build - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -123,19 +191,34 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} - name: Build and push Docker images to ghci - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true + provenance: false platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - APP_NAME=${{steps.vars.outputs.APP_NAME}} - VERSION=${{steps.vars.outputs.VERSION}} - BUILDDATE=${{steps.vars.outputs.BUILDDATE}} - COMMIT=${{steps.vars.outputs.COMMIT}} + APP_NAME=${{needs.build.outputs.APP_NAME}} + VERSION=${{needs.build.outputs.VERSION}} + BUILDDATE=${{needs.build.outputs.BUILDDATE}} + COMMIT=${{needs.build.outputs.COMMIT}} + + clean: + name: Delete temp artifacts + # ignore dockerhub job skipped + if: always() && (needs.dockerhub.result == 'success' || needs.dockerhub.result == 'skipped') && (needs.ghcr.result == 'success') + needs: [build, dockerhub, ghcr] + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: geekyeggo/delete-artifact@v5 + with: + name: ${{needs.build.outputs.APP_NAME}} + failOnError: false diff --git a/Dockerfile b/Dockerfile index 75e21dd..8af30ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN case ${TARGETARCH} in \ "arm64") PKG_ARCH=aarch64 ;; \ esac \ && cd /tmp \ - && wget https://github.com/bitxeno/usbmuxd2/releases/download/v0.0.2/usbmuxd2-ubuntu-${PKG_ARCH}.tar.gz \ + && wget https://github.com/bitxeno/usbmuxd2/releases/download/v0.0.3/usbmuxd2-ubuntu-${PKG_ARCH}.tar.gz \ && tar zxf usbmuxd2-ubuntu-${PKG_ARCH}.tar.gz \ && dpkg -i ./libusb_1.0.26-1_${PKG_ARCH}.deb \ && dpkg -i ./libgeneral_1.0.0-1_${PKG_ARCH}.deb \ diff --git a/go.mod b/go.mod index d27256b..c6e3368 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,6 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.29.1 github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a - github.com/shirou/gopsutil/v4 v4.24.5 github.com/silenceper/wechat/v2 v2.1.5 github.com/urfave/cli/v2 v2.3.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 @@ -47,16 +46,15 @@ require ( github.com/fasthttp/websocket v1.5.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/glebarez/go-sqlite v1.21.2 // indirect - github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-redis/redis/v8 v8.11.6-0.20220405070650-99c79f7041fc // indirect github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/iamacarpet/go-winpty v1.0.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/kr/pretty v0.3.0 // indirect - github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect @@ -69,22 +67,18 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/philhofer/fwd v1.1.2 // indirect - github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/satori/go.uuid v1.2.0 // indirect github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect - github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/technoweenie/multipartstreamer v1.0.1 // indirect github.com/tinylib/msgp v1.1.8 // indirect - github.com/tklauser/go-sysconf v0.3.12 // indirect - github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.47.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - github.com/yusufpapurcu/wmi v1.2.4 // indirect golang.org/x/crypto v0.10.0 // indirect golang.org/x/net v0.11.0 // indirect golang.org/x/sync v0.3.0 // indirect diff --git a/go.sum b/go.sum index d0a01c7..190ad24 100644 --- a/go.sum +++ b/go.sum @@ -146,8 +146,6 @@ github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= -github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-redis/redis/v8 v8.11.6-0.20220405070650-99c79f7041fc h1:jZY+lpZB92nvBo2f31oPC/ivGll6NcsnEOORm8Fkr4M= github.com/go-redis/redis/v8 v8.11.6-0.20220405070650-99c79f7041fc/go.mod h1:25mL1NKxbJhB63ihiK8MnNeTRd+xAizd6bOdydrTLUQ= @@ -202,6 +200,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= @@ -328,8 +327,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= -github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= -github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 h1:EnfXoSqDfSNJv0VBNqY/88RNnhSGYkrHaO0mmFGbVsc= github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -450,8 +447,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= -github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= @@ -511,11 +506,6 @@ github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJv github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1AvpV+7XmhI4r39LGNzwUL4YpMuL5vk= github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= -github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= -github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= -github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= -github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shogo82148/androidbinary v1.0.2/go.mod h1:c3BBft4TLXkvqry+EEN8z9ZtyY09r7jLMvFB/L/KrfI= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/silenceper/wechat/v2 v2.1.5 h1:eIlv61v2bAFBG9ZE75zuRC0ALHEZEUq8JlJ9tfKvatg= @@ -547,6 +537,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= @@ -555,10 +546,6 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -577,8 +564,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 h1:5mLPGnFdSsevFRFc9q3yYbBkB6tsm4aCwwQV/j1JQAQ= github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= -github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= @@ -691,7 +676,6 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -709,7 +693,6 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -729,8 +712,6 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/internal/app/config.go b/internal/app/config.go index 8232cfb..e822397 100644 --- a/internal/app/config.go +++ b/internal/app/config.go @@ -30,7 +30,7 @@ type Configuration struct { Server struct { ListenAddr string `koanf:"listen_addr" default:"0.0.0.0"` - Port int `koanf:"port" default:"9000"` + Port int `koanf:"port" default:"9400"` DataDir string `koanf:"data_dir"` } `koanf:"app" json:"app"` diff --git a/internal/task/task.go b/internal/task/task.go index a3ed3b3..38ef677 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -14,7 +14,6 @@ import ( "github.com/bitxeno/atvloadly/internal/app" "github.com/bitxeno/atvloadly/internal/log" - "github.com/bitxeno/atvloadly/internal/manager" "github.com/bitxeno/atvloadly/internal/model" "github.com/bitxeno/atvloadly/internal/notify" "github.com/bitxeno/atvloadly/internal/service" @@ -175,18 +174,18 @@ func (t *Task) runInternal(v model.InstalledApp) error { } // 检查developer disk image是否已mounted - imageInfo, err := manager.GetDeviceMountImageInfo(v.UDID) - if err != nil { - log.Err(err).Msg("Check DeveloperDiskImage mounted error: ") - return err - } - - if !imageInfo.ImageMounted { - log.Error("DeveloperDiskImage not mounted.") - return err - } - - cmd := exec.Command("sideloader", "install", "--quiet", "--udid", v.UDID, "-a", v.Account, "-p", v.Password, v.IpaPath) + // imageInfo, err := manager.GetDeviceMountImageInfo(v.UDID) + // if err != nil { + // log.Err(err).Msg("Check DeveloperDiskImage mounted error: ") + // return err + // } + + // if !imageInfo.ImageMounted { + // log.Error("DeveloperDiskImage not mounted.") + // return err + // } + + cmd := exec.Command("sideloader", "install", "--quiet", "--nocolor", "--udid", v.UDID, "-a", v.Account, "-p", v.Password, v.IpaPath) cmd.Dir = app.Config.Server.DataDir cmd.Env = []string{"SIDELOADER_CONFIG_DIR=" + app.SideloaderDataDir()} stdin, err := cmd.StdinPipe() @@ -199,21 +198,36 @@ func (t *Task) runInternal(v model.InstalledApp) error { log.Err(err).Msg("Error obtaining stdout: ") return err } + stderr, err := cmd.StderrPipe() + if err != nil { + log.Err(err).Msg("Error obtaining stdout: ") + return err + } var output strings.Builder reader := bufio.NewReader(stdout) + readerErr := bufio.NewReader(stderr) go func(reader io.Reader) { defer stdin.Close() scanner := bufio.NewScanner(reader) for scanner.Scan() { lineText := scanner.Text() + _, _ = output.WriteString(lineText) + _, _ = output.WriteString("\n") - // 忽略 Signing 消息,日志太多 - if strings.Contains(lineText, "Signing Progress") { - continue + // 处理中途需要输入才能继续的,如 Installing AltStore with Multiple AltServers Not Supported 消息 + if strings.Contains(lineText, "Press any key to continue") { + _, _ = stdin.Write([]byte("\n")) } + } + }(reader) + go func(reader io.Reader) { + defer stdin.Close() + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + lineText := scanner.Text() _, _ = output.WriteString(lineText) _, _ = output.WriteString("\n") @@ -222,14 +236,18 @@ func (t *Task) runInternal(v model.InstalledApp) error { _, _ = stdin.Write([]byte("\n")) } } - }(reader) + }(readerErr) if err := cmd.Start(); nil != err { + data := []byte(output.String()) + t.writeLog(v, data) log.Err(err).Msg("执行安装脚本出错") return err } err = cmd.Wait() if err != nil { + data := []byte(output.String()) + t.writeLog(v, data) log.Err(err).Msg("执行安装脚本出错") return err } diff --git a/web/static/src/page/install/index.vue b/web/static/src/page/install/index.vue index 5c28aaa..a6905c6 100644 --- a/web/static/src/page/install/index.vue +++ b/web/static/src/page/install/index.vue @@ -183,18 +183,7 @@ export default { _this.log.output = ""; _this.log.show = true; - // 挂载DeveloperDiskImage - _this.log.output += "Prepare to mount DeveloperDiskImage...\n"; - let data = await api.mountDeviceImageAsync(_this.id); - if (data != "success") { - _this.log.output += data; - _this.cmd.output = ""; - _this.loading = false; - toast.error(this.$t("install.toast.install_failed")); - return; - } - _this.log.output += "DeveloperDiskImage has mounted.\n"; - + let formData = new FormData(); for (let i = 0; i < _this.files.length; i++) { let file = _this.files[i]; @@ -207,7 +196,7 @@ export default { let ipa = res.data[0]; _this.ipa = ipa; _this.websocketsend( - `sideloader --udid ${_this.device.udid} -a '${_this.form.account}' -p '${_this.form.password}' '${ipa.path}'` + `sideloader install --nocolor --udid ${_this.device.udid} -a '${_this.form.account}' -p '${_this.form.password}' '${ipa.path}'` ); }) .catch((error) => { @@ -281,16 +270,17 @@ export default { ); _this.cmd.line = _this.cmd.line.replace(_this.form.password, "******"); - // if ( - // _this.cmd.line.indexOf("slideloader") === -1 - // ) { + // ignore slideloader command output + if ( + _this.cmd.line.indexOf("sideloader") === -1 + ) { _this.log.output += _this.cmd.line; // The textbox follows the scroll to the bottom _this.$nextTick(() => { const textarea = document.querySelector("#log"); textarea.scrollTop = textarea.scrollHeight; }); - // } + } _this.cmd.line = ""; } diff --git a/web/static/yarn.lock b/web/static/yarn.lock index d5269be..3478a1b 100644 --- a/web/static/yarn.lock +++ b/web/static/yarn.lock @@ -513,11 +513,6 @@ entities@^4.2.0: resolved "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz" integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== -esbuild-darwin-64@0.14.54: - version "0.14.54" - resolved "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz" - integrity sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug== - esbuild@^0.14.27: version "0.14.54" resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz" @@ -609,11 +604,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" diff --git a/web/web.go b/web/web.go index 657b4bb..ca1c175 100644 --- a/web/web.go +++ b/web/web.go @@ -2,6 +2,7 @@ package web import ( "fmt" + "math" "github.com/bitxeno/atvloadly/internal/app" "github.com/bitxeno/atvloadly/internal/log" @@ -10,7 +11,9 @@ import ( ) func Run(addr string, port int) error { - server := fiber.New() + server := fiber.New(fiber.Config{ + BodyLimit: math.MaxInt, + }) route(server) // set fiber web server access log