From 9d7664373ee7657bfc4c0f69f29c107f3189ad72 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 14:32:05 +0800 Subject: [PATCH] ci(release test):setup releaser --- .github/actions/setup-goreleaser/action.yml | 30 +++++++++ .github/workflows/release-build.yml | 69 ++------------------- 2 files changed, 34 insertions(+), 65 deletions(-) create mode 100644 .github/actions/setup-goreleaser/action.yml diff --git a/.github/actions/setup-goreleaser/action.yml b/.github/actions/setup-goreleaser/action.yml new file mode 100644 index 00000000..1748c12e --- /dev/null +++ b/.github/actions/setup-goreleaser/action.yml @@ -0,0 +1,30 @@ +name: "Setup GoReleaser" +description: "Setup GoReleaser environment" +runs: + using: "composite" + steps: + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.x + - name: Restore Darwin sysroot cache + id: cache-darwin-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + - name: Populate Darwin sysroot + run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + shell: bash + - name: Populate Linux sysroot + run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot + shell: bash + - name: Check file + run: tree .sysroot + shell: bash diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 01c7c0be..c9a6603c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -53,26 +53,6 @@ jobs: - name: Create Linux sysroot tarball if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' run: tar -czvf .sysroot/linux.tar.gz -C .sysroot linux - - name: Verify Linux sysroot contents - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - run: | - echo "验证 AMD64 sysroot..." - if [ ! -d ".sysroot/linux/amd64/usr/include/llvm-19" ]; then - echo "错误:AMD64 sysroot 缺少 LLVM 头文件" - exit 1 - fi - - echo "验证 ARM64 sysroot..." - if [ ! -d ".sysroot/linux/arm64/usr/include/llvm-19" ]; then - echo "错误:ARM64 sysroot 缺少 LLVM 头文件" - exit 1 - fi - - echo "检查关键文件..." - ls -la .sysroot/linux/amd64/usr/include/llvm-c/Core.h || echo "AMD64 Core.h 缺失" - ls -la .sysroot/linux/arm64/usr/include/llvm-c/Core.h || echo "ARM64 Core.h 缺失" - - echo "sysroot 验证通过!" - name: Save Linux sysroot cache if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 @@ -85,34 +65,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Restore Darwin sysroot cache - id: cache-darwin-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 - - name: Restore Linux sysroot cache - id: cache-linux-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot - - name: Check file - run: tree .sysroot + - name: Set up Release + uses: ./.github/actions/setup-goreleaser - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} @@ -230,23 +184,8 @@ jobs: uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Download Darwin sysroot tarball - uses: actions/download-artifact@v5 - with: - name: darwin-sysroot-tarball - path: .sysroot - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: bash .github/workflows/populate_linux_sysroot.sh + - name: Set up Release + uses: ./.github/actions/setup-goreleaser - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}}