ci(release test):use cache .sysroot both for test & release

This commit is contained in:
luoliwoshang
2025-09-03 19:11:30 +08:00
parent 5e32a15146
commit da319e2a7c

View File

@@ -13,33 +13,46 @@ jobs:
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Restore Darwin sysroot cache - name: Check sysroot cache
id: cache-darwin-sysroot id: cache-darwin-sysroot
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
path: .sysroot/darwin.tar.gz path: .sysroot/darwin
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }} key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1
lookup-only: true
- name: Populate Darwin sysroot - name: Populate Darwin sysroot
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
run: bash .github/workflows/populate_darwin_sysroot.sh run: bash .github/workflows/populate_darwin_sysroot.sh
- name: Create Darwin sysroot tarball
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin
- name: Save Darwin sysroot cache - name: Save Darwin sysroot cache
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
uses: actions/cache/save@v4 uses: actions/cache/save@v4
with: with:
path: .sysroot/darwin.tar.gz path: .sysroot/darwin
key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }}
- name: Upload Darwin sysroot tarball populate-linux-sysroot:
uses: actions/upload-artifact@v4 runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Check sysroot cache
id: cache-linux-sysroot
uses: actions/cache/restore@v4
with: with:
name: darwin-sysroot-tarball path: .sysroot/linux
path: .sysroot/darwin.tar.gz key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1
compression-level: 0 lookup-only: true
- name: Populate Linux sysroot
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
run: bash .github/workflows/populate_linux_sysroot.sh
- name: Save Linux sysroot cache
uses: actions/cache/save@v4
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
with:
path: .sysroot/linux
key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }}
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: populate-darwin-sysroot needs: [populate-darwin-sysroot, populate-linux-sysroot]
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v5 uses: actions/checkout@v5
@@ -53,28 +66,18 @@ jobs:
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with: with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 image: tonistiigi/binfmt:qemu-v7.0.0-28
- name: Download Darwin sysroot tarball - name: Restore Macos sysroot cache
uses: actions/download-artifact@v5 id: cache-macos-sysroot
uses: actions/cache/restore@v4
with: with:
name: darwin-sysroot-tarball path: .sysroot/darwin
path: .sysroot key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1
- name: Populate Darwin sysroot
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
- name: Restore Linux sysroot cache - name: Restore Linux sysroot cache
id: cache-linux-sysroot id: cache-linux-sysroot
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
path: .sysroot path: .sysroot/linux
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }} key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1
- name: Populate Linux sysroot
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
run: bash .github/workflows/populate_linux_sysroot.sh
- name: Save Linux sysroot cache
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .sysroot
key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }}
- name: Run GoReleaser (Build & Test) - name: Run GoReleaser (Build & Test)
env: env:
GITHUB_TOKEN: ${{github.token}} GITHUB_TOKEN: ${{github.token}}
@@ -200,15 +203,18 @@ jobs:
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with: with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 image: tonistiigi/binfmt:qemu-v7.0.0-28
- name: Download Darwin sysroot tarball - name: Restore Macos sysroot cache
uses: actions/download-artifact@v5 id: cache-macos-sysroot
uses: actions/cache/restore@v4
with: with:
name: darwin-sysroot-tarball path: .sysroot/darwin
path: .sysroot key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1
- name: Populate Darwin sysroot - name: Restore Linux sysroot cache
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot id: cache-linux-sysroot
- name: Populate Linux sysroot uses: actions/cache/restore@v4
run: bash .github/workflows/populate_linux_sysroot.sh with:
path: .sysroot/linux
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1
- name: Run GoReleaser (Release) - name: Run GoReleaser (Release)
env: env:
GITHUB_TOKEN: ${{github.token}} GITHUB_TOKEN: ${{github.token}}