修改内核压缩方式

This commit is contained in:
juewuy
2024-01-30 18:47:02 +08:00
parent 744270cbee
commit 0cadd027ec
2 changed files with 218 additions and 65 deletions

View File

@@ -1,63 +1,194 @@
name: Update Meta Core name: Build meta Core for ShellCrash
on:
workflow_dispatch: on:
inputs: workflow_dispatch:
tag: inputs:
description: 'tag of Clash Meta, such as Prerelease-Alpha, Prerelease-Beta, v1.11.1' tag1:
required: true description: 'project name of meta, such as MetaCubeX/mihomo'
type: string required: true
env: type: string
download_tag: ${{ github.event.inputs.tag }} tag2:
download_version: '' description: 'tag or branches of meta, such as v1.18.0 or Alpha'
download_url: https://github.com/MetaCubeX/mihomo/releases/download required: true
jobs: type: string
Update: tag3:
runs-on: ubuntu-latest description: 'a new prerelease name (such as clash.meta.alpha) or only upload-artifact'
steps: required: false
- name: Clone Repository type: string
uses: actions/checkout@main tag4:
- name: Init Dependencies description: 'git push as crashcore (such as meta) or only upload-artifact'
run: | required: false
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz type: string
wget https://github.com/upx/upx/releases/download/v3.93/upx-3.93-amd64_linux.tar.xz tag5:
tar xf upx-3.96-amd64_linux.tar.xz description: 'build tags'
tar xf upx-3.93-amd64_linux.tar.xz required: false
- name: Download Core type: string
run: |
if [ "${download_tag}" = "Prerelease-Alpha" ] || [ "${download_tag}" = "Prerelease-Beta" ];then jobs:
download_version=$(curl -sL https://api.github.com/repos/MetaCubeX/mihomo/releases/tags/${download_tag} | grep linux-arm64 | head -n 1 | sed 's_.gz.*__;s_.*arm64-__') go:
else runs-on: ubuntu-latest
download_version=${download_tag} outputs:
fi version: ${{steps.go.outputs.version}}
echo "download_version=${download_version}" >> ${GITHUB_ENV} steps:
archs=(amd64-compatible armv5 armv7 arm64 mips-softfloat mipsle-hardfloat mipsle-softfloat) - name: get latest go version
new_name=(amd64 armv5 armv7 armv8 mips-softfloat mipsle-hardfloat mipsle-softfloat) id: go
mkdir tmp run: |
for((i=0;i<7;i++));do echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT
wget "${download_url}/${download_tag}/mihomo-linux-${archs[i]}-${download_version}.gz" -O - | gunzip -c > ./tmp/clash-linux-${new_name[i]}
chmod +x ./tmp/clash-linux-${new_name[i]} meta:
if [ "${archs[i]}" != "armv5" ];then runs-on: ubuntu-latest
if [[ ${archs[i]} = mips* ]];then needs: go
./upx-3.93-amd64_linux/upx ./tmp/clash-linux-${new_name[i]} env:
else REPO: ${{ github.event.inputs.tag1 }}
./upx-3.96-amd64_linux/upx ./tmp/clash-linux-${new_name[i]} TAGS: ${{ github.event.inputs.tag5 }}
fi outputs:
fi version: ${{steps.meta.outputs.version}}
done tags: ${{steps.meta.outputs.tags}}
rm -fr upx* steps:
- name: Update
run: | - name: setup go
rm -fr ./bin/meta/* uses: actions/setup-go@v4.1.0
cp ./tmp/* ./bin/meta/ with:
rm -fr ./tmp go-version: ${{needs.go.outputs.version}}
sed -i "s/meta_v=.*/meta_v=$(./bin/meta/clash-linux-amd64 -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')/" bin/version
- name: Commit and push - name: get meta version
run: | id: meta
git config --global user.email "juewuy@gmail.com" && git config --global user.name "Bot" run: |
git add . && git commit -m "更新Meta内核至${download_version}" || exit 0 version=${{ github.event.inputs.tag2 }}
git push echo version=$version >> $GITHUB_OUTPUT
- name: Cleanup Workflow if [ -z "$TAGS" ];then
uses: Mattraks/delete-workflow-runs@main echo tags='' >> $GITHUB_OUTPUT
with: else
retain_days: 1 echo tags=$TAGS >> $GITHUB_OUTPUT
keep_minimum_runs: 2 fi
cross:
strategy:
matrix:
include:
# linux
- name: linux-amd64
goos: linux
goarch: amd64
goamd64: v1
- name: linux-386
goos: linux
goarch: 386
- name: linux-arm64
goos: linux
goarch: arm64
- name: linux-armv5
goos: linux
goarch: arm
goarm: 5
- name: linux-armv7
goos: linux
goarch: arm
goarm: 7
- name: linux-mips-softfloat
goos: linux
goarch: mips
gomips: softfloat
- name: linux-mipsel-softfloat
goos: linux
goarch: mipsle
gomips: softfloat
- name: linux-mipsel-hardfloat
goos: linux
goarch: mipsle
gomips: hardfloat
fail-fast: false
runs-on: ubuntu-latest
needs: meta
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOAMD64: ${{ matrix.goamd64 }}
GOARM: ${{ matrix.goarm }}
GOMIPS: ${{ matrix.gomips }}
CGO_ENABLED: 0
TAGS: ${{needs.meta.outputs.tags}}
VERSION: ${{needs.meta.outputs.version}}
steps:
- name: Checkout meta
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
repository: ${{ github.event.inputs.tag1 }}
ref: ${{ github.event.inputs.tag2 }}
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go.outputs.version }}
- name: Set ENV
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
echo "BUILDTIME=$(date)" >> $GITHUB_ENV
shell: bash
- name: build core
id: build
run: go build -v -trimpath -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -s -w -buildid=" -tags "${TAGS}" -o meta
- name: Upload file to workspace
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: meta
push_to_git:
needs:
- cross
- meta
runs-on: ubuntu-latest
env:
RELEASE: ${{ github.event.inputs.tag3 }}
PUSHDIR: ${{ github.event.inputs.tag4 }}
VERSION: ${{needs.meta.outputs.version}}
steps:
- name: Download file from workspace
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Zip core by tar
run: |
for arch in amd64 armv5 armv7 arm64 mips-softfloat mipsel-hardfloat mipsel-softfloat;do
mv -f ./tmp/linux-${arch}/meta ./tmp/CrashCore
chmod +x ./tmp/CrashCore
tar --no-same-owner -zcvf ./tmp/clash-linux-${arch}.tar.gz -C ./tmp CrashCore
done
- name: Commit and push
if: ${{ env.PUSHDIR != '' }}
run: |
crashcore='meta'
mkdir -p ./bin/${crashcore}
rm -fr ./bin/${crashcore}/*
mv -f ./tmp/clash-linux-*.tar.gz ./bin/${crashcore}/
rm -fr ./tmp
sed -i "s/${crashcore}_v=.*/${crashcore}_v=${VERSION}/" ./bin/version
git config --global user.email "juewuy@gmail.com" && git config --global user.name "Bot"
git add . && git commit -m "更新${crashcore}内核至${VERSION}" || exit 0
git push
- name: Create Release and Upload Release Asset
if: ${{ env.RELEASE != '' && env.PUSHDIR == '' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag3 }}
name: ${{ github.event.inputs.tag3 }}
body: "The ${{env.VERSION}} version of ${{ github.event.inputs.tag1 }} \n这是${{ github.event.inputs.tag1 }}的${{env.VERSION}}版本内核文件\nhttps://github.com/${{ github.event.inputs.tag1 }}/releases \nOnly support for ShellCrash\n仅适配ShellCrash项目"
draft: false
prerelease: true
files: |
./tmp/clash*.tar.gz
- name: Cleanup Workflow
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 2

View File

@@ -12,6 +12,14 @@ on:
required: true required: true
type: string type: string
tag3: tag3:
description: 'a new prerelease name (such as singbox_core_178) or only upload-artifact'
required: false
type: string
tag4:
description: 'git push as crashcore (such as singbox or singboxp) or only upload-artifact'
required: false
type: string
tag5:
description: 'build tags' description: 'build tags'
required: false required: false
type: string type: string
@@ -31,7 +39,7 @@ jobs:
needs: go needs: go
env: env:
REPO: ${{ github.event.inputs.tag1 }} REPO: ${{ github.event.inputs.tag1 }}
TAGS: ${{ github.event.inputs.tag3 }} TAGS: ${{ github.event.inputs.tag5 }}
outputs: outputs:
version: ${{steps.sing-box.outputs.version}} version: ${{steps.sing-box.outputs.version}}
tags: ${{steps.sing-box.outputs.tags}} tags: ${{steps.sing-box.outputs.tags}}
@@ -135,12 +143,14 @@ jobs:
name: ${{ matrix.name }} name: ${{ matrix.name }}
path: sing-box path: sing-box
push_to_bin: push_to_git:
needs: needs:
- cross - cross
- sing-box - sing-box
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
RELEASE: ${{ github.event.inputs.tag3 }}
PUSHDIR: ${{ github.event.inputs.tag4 }}
VERSION: ${{needs.sing-box.outputs.version}} VERSION: ${{needs.sing-box.outputs.version}}
steps: steps:
- name: Checkout ShellCrash - name: Checkout ShellCrash
@@ -175,6 +185,18 @@ jobs:
git add . && git commit -m "更新${crashcore}内核至${VERSION}" || exit 0 git add . && git commit -m "更新${crashcore}内核至${VERSION}" || exit 0
git push git push
- name: Create Release and Upload Release Asset
if: ${{ env.RELEASE != '' && env.PUSHDIR == '' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag3 }}
name: ${{ github.event.inputs.tag3 }}
body: "The ${{env.VERSION}} version of ${{ github.event.inputs.tag1 }} \n这是${{ github.event.inputs.tag1 }}的${{env.VERSION}}版本内核文件\nhttps://github.com/${{ github.event.inputs.tag1 }}/releases \nOnly support for ShellCrash\n仅适配ShellCrash项目"
draft: false
prerelease: true
files: |
./tmp/singbox*.tar.gz
- name: Cleanup Workflow - name: Cleanup Workflow
uses: Mattraks/delete-workflow-runs@main uses: Mattraks/delete-workflow-runs@main
with: with: