Update mihomo #516
This file contains hidden or 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: Update mihomo | |
| on: | |
| workflow_dispatch: # 保留手动触发 | |
| schedule: | |
| - cron: "30 21 * * *" # 保留定时任务 | |
| push: | |
| branches: | |
| - latest # 仅监控latest分支 | |
| paths: | |
| - ".github/workflows/mihomo.yaml" # | |
| jobs: | |
| go: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.go.outputs.version }} | |
| steps: | |
| - name: Get `Go` latest version | |
| id: go | |
| run: | | |
| echo version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r 'map(.version) | sort_by(split(".") | map(tonumber)) | last') >> $GITHUB_OUTPUT | |
| meta: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| meta_version: ${{ steps.meta.outputs.meta_version }} | |
| meta_tags: ${{ steps.meta.outputs.meta_tags }} | |
| meta_time: ${{ steps.meta.outputs.meta_time}} | |
| steps: | |
| - name: Get `mihomo Meta` version and time | |
| id: meta | |
| run: | | |
| meta_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases/latest | jq -r '.tag_name') | |
| echo "meta_version=$meta_version" >> $GITHUB_OUTPUT | |
| echo meta_tags=with_gvisor >> $GITHUB_OUTPUT | |
| meta_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d') | |
| echo "meta_time=$meta_time" >> $GITHUB_OUTPUT | |
| meta_cross: | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux | |
| - { name: linux-amd64, goos: linux, goarch: amd64, goamd64: v1 } | |
| - { name: linux-amd64-v3, goos: linux, goarch: amd64, goamd64: v3 } | |
| - { name: linux-armv5, goos: linux, goarch: arm, goarm: 5 } | |
| - { name: linux-armv6, goos: linux, goarch: arm, goarm: 6 } | |
| - { name: linux-armv7, goos: linux, goarch: arm, goarm: 7 } | |
| - { name: linux-arm64, goos: linux, goarch: arm64 } | |
| - { name: linux-mips-softfloat, goos: linux, goarch: mips, gomips: softfloat } | |
| - { name: linux-mipsle-softfloat, goos: linux, goarch: mipsle, gomips: softfloat } | |
| - { name: linux-mipsle-hardfloat, goos: linux, goarch: mipsle, gomips: hardfloat } | |
| # Windows | |
| - { name: windows-amd64, goos: windows, goarch: amd64, goamd64: v1 } | |
| - { name: windows-amd64-v3, goos: windows, goarch: amd64, goamd64: v3 } | |
| - { name: windows-arm64, goos: windows, goarch: arm64 } | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| needs: | |
| - go | |
| - meta | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| GOAMD64: ${{ matrix.goamd64 }} | |
| GOARM: ${{ matrix.goarm }} | |
| GOMIPS: ${{ matrix.gomips }} | |
| CGO_ENABLED: 0 | |
| meta_TAGS: ${{ needs.meta.outputs.meta_tags }} | |
| meta_VERSION: ${{ needs.meta.outputs.meta_version }} | |
| steps: | |
| - name: Checkout `Meta` | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: MetaCubeX/mihomo | |
| ref: Meta | |
| - name: Setup `Go` | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ needs.go.outputs.version }} | |
| - name: Set ENV | |
| run: | | |
| sudo timedatectl set-timezone "Asia/Shanghai" | |
| echo "BUILDTIME=$(date)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Build `mihomo Meta` core | |
| id: build | |
| run: go build -v -trimpath -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${meta_VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -s -w -buildid=" -tags "${meta_TAGS}" -o meta | |
| - name: Upload files to workspace | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mihomo-meta-${{ matrix.name }} | |
| path: meta* | |
| compression-level: 9 | |
| alpha: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| alpha_version: ${{ steps.alpha.outputs.alpha_version }} | |
| alpha_tags: ${{ steps.alpha.outputs.alpha_tags }} | |
| alpha_time: ${{ steps.alpha.outputs.alpha_time }} | |
| steps: | |
| - name: Get `mihomo Alpha` version and time | |
| id: alpha | |
| run: | | |
| alpha_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0].assets[].name' | head -n 1 | sed 's/.*-\(alpha-[^-]*\)\..*/\1/') | |
| echo "alpha_version=$alpha_version" >> $GITHUB_OUTPUT | |
| echo alpha_tags=with_gvisor >> $GITHUB_OUTPUT | |
| alpha_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0].created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d') | |
| echo "alpha_time=$alpha_time" >> $GITHUB_OUTPUT | |
| alpha_cross: | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux | |
| - { name: linux-amd64, goos: linux, goarch: amd64, goamd64: v1 } | |
| - { name: linux-amd64-v3, goos: linux, goarch: amd64, goamd64: v3 } | |
| - { name: linux-armv5, goos: linux, goarch: arm, goarm: 5 } | |
| - { name: linux-armv6, goos: linux, goarch: arm, goarm: 6 } | |
| - { name: linux-armv7, goos: linux, goarch: arm, goarm: 7 } | |
| - { name: linux-arm64, goos: linux, goarch: arm64 } | |
| - { name: linux-mips-softfloat, goos: linux, goarch: mips, gomips: softfloat } | |
| - { name: linux-mipsle-softfloat, goos: linux, goarch: mipsle, gomips: softfloat } | |
| - { name: linux-mipsle-hardfloat, goos: linux, goarch: mipsle, gomips: hardfloat } | |
| # Windows | |
| - { name: windows-amd64, goos: windows, goarch: amd64, goamd64: v1 } | |
| - { name: windows-amd64-v3, goos: windows, goarch: amd64, goamd64: v3 } | |
| - { name: windows-arm64, goos: windows, goarch: arm64 } | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| needs: | |
| - go | |
| - alpha | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| GOAMD64: ${{ matrix.goamd64 }} | |
| GOARM: ${{ matrix.goarm }} | |
| GOMIPS: ${{ matrix.gomips }} | |
| CGO_ENABLED: 0 | |
| alpha_TAGS: ${{ needs.alpha.outputs.alpha_tags }} | |
| alpha_VERSION: ${{ needs.alpha.outputs.alpha_version }} | |
| steps: | |
| - name: Checkout `Alpha` | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: MetaCubeX/mihomo | |
| ref: Alpha | |
| - name: Setup `Go` | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ needs.go.outputs.version }} | |
| - name: Set ENV | |
| run: | | |
| sudo timedatectl set-timezone "Asia/Shanghai" | |
| echo "BUILDTIME=$(date)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Build `mihomo Alpha` core | |
| id: build | |
| run: go build -v -trimpath -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${alpha_VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -s -w -buildid=" -tags "${alpha_TAGS}" -o meta | |
| - name: Upload files to workspace | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mihomo-alpha-${{ matrix.name }} | |
| path: meta* | |
| compression-level: 9 | |
| push_mihomo: | |
| needs: | |
| - meta_cross | |
| - meta | |
| - alpha_cross | |
| - alpha | |
| runs-on: ubuntu-latest | |
| env: | |
| meta_VERSION: ${{ needs.meta.outputs.meta_version }} | |
| meta_TIME: ${{ needs.meta.outputs.meta_time }} | |
| alpha_VERSION: ${{ needs.alpha.outputs.alpha_version }} | |
| alpha_TIME: ${{ needs.alpha.outputs.alpha_time }} | |
| steps: | |
| - name: Clone Repository | |
| uses: actions/checkout@main | |
| - name: Download files from workspace | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./tmp-mihomo/ | |
| - name: Zip `mihomo` cores by `tar` | |
| run: | | |
| mkdir -p ./tmp-mihomo/compress/ | |
| archs=(amd64 armv5 armv6 armv7 arm64 mips-softfloat mipsle-hardfloat mipsle-softfloat) | |
| new_name=(amd64 armv5 armv6 armv7 arm64 mips-softfloat mipsle-hardfloat mipsle-softfloat) | |
| # `Meta` cores | |
| for ((i = 0; i < 8; i++)); do | |
| mv -f "./tmp-mihomo/mihomo-meta-linux-${archs[i]}/meta" ./tmp-mihomo/mihomo | |
| chmod +x ./tmp-mihomo/mihomo | |
| tar --no-same-owner -czf "./tmp-mihomo/compress/mihomo-meta-linux-${new_name[i]}.tar.gz" -C ./tmp-mihomo/ ./mihomo | |
| done | |
| # `Alpha` cores | |
| for ((i = 0; i < 8; i++)); do | |
| mv -f "./tmp-mihomo/mihomo-alpha-linux-${archs[i]}/meta" ./tmp-mihomo/mihomo | |
| chmod +x ./tmp-mihomo/mihomo | |
| tar --no-same-owner -czf "./tmp-mihomo/compress/mihomo-alpha-linux-${new_name[i]}.tar.gz" -C ./tmp-mihomo/ ./mihomo | |
| done | |
| - name: Move `mihomo` cores | |
| run: | | |
| mkdir -p ./mihomo/ | |
| mv -f ./tmp-mihomo/compress/* ./mihomo/ | |
| # `Meta` cores for Windows | |
| mv -f ./tmp-mihomo/mihomo-meta-windows-amd64/meta ./mihomo/mihomo-meta-windows-amd64.exe | |
| mv -f ./tmp-mihomo/mihomo-meta-windows-amd64-v3/meta ./mihomo/mihomo-meta-windows-amd64v3.exe | |
| mv -f ./tmp-mihomo/mihomo-meta-windows-arm64/meta ./mihomo/mihomo-meta-windows-arm64.exe | |
| # `Alpha` cores for Windows | |
| mv -f ./tmp-mihomo/mihomo-alpha-windows-amd64/meta ./mihomo/mihomo-alpha-windows-amd64.exe | |
| mv -f ./tmp-mihomo/mihomo-alpha-windows-amd64-v3/meta ./mihomo/mihomo-alpha-windows-amd64v3.exe | |
| mv -f ./tmp-mihomo/mihomo-alpha-windows-arm64/meta ./mihomo/mihomo-alpha-windows-arm64.exe | |
| rm -rf ./tmp* | |
| - name: Release and upload `mihomo` assets | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| release_name: mihomo | |
| tag: mihomo | |
| overwrite: true | |
| body: | | |
| 更新 [mihomo Meta 版](https://github.com/MetaCubeX/mihomo/tree/Meta)至 ${{ env.meta_VERSION }},发布于 ${{ env.meta_TIME }} | |
| 更新 [mihomo Alpha 版](https://github.com/MetaCubeX/mihomo/tree/Alpha)至 ${{ env.alpha_VERSION }},发布于 ${{ env.alpha_TIME }} | |
| file_glob: true | |
| file: ./mihomo/* |