Merge branch 'dev' into core_zip

# Conflicts:
#	.github/workflows/update_meta_core_test.yaml
This commit is contained in:
juewuy
2024-01-29 18:46:38 +08:00

View File

@@ -1,184 +1,179 @@
name: Test meta Core for ShellCrash name: Test meta Core for ShellCrash
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag1: tag1:
description: 'project name of meta, such as MetaCubeX/mihomo' description: 'project name of meta, such as MetaCubeX/mihomo'
required: true required: true
type: string type: string
tag2: tag2:
description: 'tag or branches of meta, such as v1.18.0 or Alpha' description: 'tag or branches of meta, such as v1.18.0 or Alpha'
required: true required: true
type: string type: string
tag3: tag3:
description: 'a new prerelease name or not, if value=0, then only upload-artifact' description: 'a new prerelease name or not, if value=0, then only upload-artifact'
required: false required: false
type: string type: string
tag4: tag4:
description: 'build tags' description: 'build tags'
required: false required: false
type: string type: string
jobs: jobs:
go: go:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
version: ${{steps.go.outputs.version}} version: ${{steps.go.outputs.version}}
steps: steps:
- name: get latest go version - name: get latest go version
id: go id: go
run: | run: |
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 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
meta: meta:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: go needs: go
env: env:
REPO: ${{ github.event.inputs.tag1 }} REPO: ${{ github.event.inputs.tag1 }}
TAGS: ${{ github.event.inputs.tag4 }} TAGS: ${{ github.event.inputs.tag4 }}
outputs: outputs:
version: ${{steps.meta.outputs.version}} version: ${{steps.meta.outputs.version}}
tags: ${{steps.meta.outputs.tags}} tags: ${{steps.meta.outputs.tags}}
steps: steps:
- uses: actions/checkout@v4.1.1
with: - name: setup go
repository: ${{ github.event.inputs.tag1 }} uses: actions/setup-go@v4.1.0
ref: ${{ github.event.inputs.tag2 }} with:
fetch-depth: 0 go-version: ${{needs.go.outputs.version}}
- name: setup go - name: get meta version
uses: actions/setup-go@v4.1.0 id: meta
with: run: |
go-version: ${{needs.go.outputs.version}} version=${{ github.event.inputs.tag2 }}
echo version=$version >> $GITHUB_OUTPUT
- name: get meta version if [ -z "$TAGS" ];then
id: meta echo tags='' >> $GITHUB_OUTPUT
run: | else
version=${{ github.event.inputs.tag2 }} echo tags=$TAGS >> $GITHUB_OUTPUT
echo version=$version >> $GITHUB_OUTPUT fi
if [ -z "$TAGS" ];then
echo tags='' >> $GITHUB_OUTPUT cross:
else strategy:
echo tags=$TAGS >> $GITHUB_OUTPUT matrix:
fi include:
# linux
cross: - name: linux-amd64
strategy: goos: linux
matrix: goarch: amd64
include: goamd64: v1
# linux # - name: linux-386
- name: linux-amd64 # goos: linux
goos: linux # goarch: 386
goarch: amd64 # - name: linux-arm64
goamd64: v1 # goos: linux
# - name: linux-386 # goarch: arm64
# goos: linux # - name: linux-armv5
# goarch: 386 # goos: linux
# - name: linux-arm64 # goarch: arm
# goos: linux # goarm: 5
# goarch: arm64 # - name: linux-armv7
# - name: linux-armv5 # goos: linux
# goos: linux # goarch: arm
# goarch: arm # goarm: 7
# goarm: 5 # - name: linux-mips-softfloat
# - name: linux-armv7 # goos: linux
# goos: linux # goarch: mips
# goarch: arm # gomips: softfloat
# goarm: 7 # - name: linux-mipsel-softfloat
# - name: linux-mips-softfloat # goos: linux
# goos: linux # goarch: mipsle
# goarch: mips # gomips: softfloat
# gomips: softfloat # - name: linux-mipsel-hardfloat
# - name: linux-mipsel-softfloat # goos: linux
# goos: linux # goarch: mipsle
# goarch: mipsle # gomips: hardfloat
# gomips: softfloat
# - name: linux-mipsel-hardfloat fail-fast: false
# goos: linux runs-on: ubuntu-latest
# goarch: mipsle needs: meta
# gomips: hardfloat env:
GOOS: ${{ matrix.goos }}
fail-fast: false GOARCH: ${{ matrix.goarch }}
runs-on: ubuntu-latest GOAMD64: ${{ matrix.goamd64 }}
needs: meta GOARM: ${{ matrix.goarm }}
env: GOMIPS: ${{ matrix.gomips }}
GOOS: ${{ matrix.goos }} CGO_ENABLED: 0
GOARCH: ${{ matrix.goarch }} TAGS: ${{needs.meta.outputs.tags}}
GOAMD64: ${{ matrix.goamd64 }} VERSION: ${{needs.meta.outputs.version}}
GOARM: ${{ matrix.goarm }} steps:
GOMIPS: ${{ matrix.gomips }} - name: Checkout meta
CGO_ENABLED: 0 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
TAGS: ${{needs.meta.outputs.tags}} with:
VERSION: ${{needs.meta.outputs.version}} repository: ${{ github.event.inputs.tag1 }}
steps: ref: ${{ github.event.inputs.tag2 }}
- name: Checkout meta fetch-depth: 1
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with: - name: Setup Go
repository: ${{ github.event.inputs.tag1 }} uses: actions/setup-go@v5
ref: ${{ github.event.inputs.tag2 }} with:
fetch-depth: 1 go-version: ${{ steps.go.outputs.version }}
- name: Setup Go - name: build core
uses: actions/setup-go@v5 id: build
with: run: go build -v -trimpath -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -s -w -buildid=" -tags "${TAGS}" -o meta
go-version: ${{ steps.go.outputs.version }}
- name: Upload file to workspace
- name: build core uses: actions/upload-artifact@v4
id: build with:
run: go build -v -trimpath -ldflags "-X 'github.com/sagernet/meta/constant.Version=${VERSION}' -s -w -buildid=" -tags "${TAGS}" name: ${{ matrix.name }}
path: meta
- name: Upload file to workspace
uses: actions/upload-artifact@v4 push_prerelease:
with: needs:
name: ${{ matrix.name }} - cross
path: meta - meta
runs-on: ubuntu-latest
push_prerelease: env:
needs: RELEASE: ${{ github.event.inputs.tag3 }}
- cross VERSION: ${{needs.meta.outputs.version}}
- meta steps:
runs-on: ubuntu-latest - name: Download file from workspace
env: uses: actions/download-artifact@v4
RELEASE: ${{ github.event.inputs.tag3 }} with:
VERSION: ${{needs.meta.outputs.version}} path: ./tmp
steps:
- name: Download file from workspace - name: Zip core by tar
uses: actions/download-artifact@v4 run: |
with: for arch in amd64 armv5 armv7 arm64 mips-softfloat mipsel-hardfloat mipsel-softfloat;do
path: ./tmp mv -f ./tmp/linux-${arch}/meta ./tmp/CrashCore
chmod +x ./tmp/CrashCore
- name: Zip core by tar tar --no-same-owner -zcvf ./tmp/meta-linux-${arch}.tar.gz -C ./tmp CrashCore
run: | done
for arch in amd64 armv5 armv7 arm64 mips-softfloat mipsel-hardfloat mipsel-softfloat;do
mv -f ./tmp/linux-${arch}/meta ./tmp/CrashCore - name: Create Release and Upload Release Asset
chmod +x ./tmp/CrashCore if: ${{ env.RELEASE != '0' }}
tar --no-same-owner -zcvf ./tmp/meta-linux-${arch}.tar.gz -C ./tmp CrashCore uses: softprops/action-gh-release@v1
done with:
tag_name: meta_core${{ github.event.inputs.tag3 }}
- name: Create Release and Upload Release Asset name: meta_core${{ github.event.inputs.tag3 }}
if: ${{ env.RELEASE != '0' }} 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项目使用"
uses: softprops/action-gh-release@v1 draft: false
with: prerelease: true
tag_name: meta_core${{ github.event.inputs.tag3 }} files: |
name: meta_core${{ github.event.inputs.tag3 }} ./tmp/meta*
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 - name: upload artifact
prerelease: true if: ${{ env.RELEASE == '0' }}
files: | uses: actions/upload-artifact@v4.1.0
./tmp/meta* with:
name: meta-${{env.VERSION}}-${{matrix.jobs.output}}
- name: upload artifact path: |
if: ${{ env.RELEASE == '0' }} ./tmp/meta*
uses: actions/upload-artifact@v4.1.0 compression-level: 9
with:
name: meta-${{env.VERSION}}-${{matrix.jobs.output}} - name: Cleanup Workflow
path: | uses: Mattraks/delete-workflow-runs@main
./tmp/meta* with:
compression-level: 9 retain_days: 1
keep_minimum_runs: 2
- name: Cleanup Workflow
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 2