ci(release test):cache key to env
This commit is contained in:
11
.github/actions/setup-goreleaser/action.yml
vendored
11
.github/actions/setup-goreleaser/action.yml
vendored
@@ -1,5 +1,12 @@
|
||||
name: "Setup GoReleaser"
|
||||
description: "Setup GoReleaser environment"
|
||||
inputs:
|
||||
darwin-cache-key:
|
||||
description: "Darwin sysroot cache key"
|
||||
required: true
|
||||
linux-cache-key:
|
||||
description: "Linux sysroot cache key"
|
||||
required: true
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -12,13 +19,13 @@ runs:
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: .sysroot/darwin.tar.gz
|
||||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||||
key: ${{ inputs.darwin-cache-key }}
|
||||
- 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
|
||||
key: ${{ inputs.linux-cache-key }}
|
||||
- name: Populate Darwin sysroot
|
||||
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
|
||||
shell: bash
|
||||
|
||||
36
.github/workflows/release-build.yml
vendored
36
.github/workflows/release-build.yml
vendored
@@ -8,8 +8,25 @@ on:
|
||||
branches: ["**"]
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
darwin-cache-key: ${{ steps.cache-keys.outputs.darwin-key }}
|
||||
linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
- name: Calculate cache keys
|
||||
id: cache-keys
|
||||
run: |
|
||||
DARWIN_KEY="darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5"
|
||||
LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7"
|
||||
echo "darwin-key=$DARWIN_KEY" >> $GITHUB_OUTPUT
|
||||
echo "linux-key=$LINUX_KEY" >> $GITHUB_OUTPUT
|
||||
|
||||
populate-darwin-sysroot:
|
||||
runs-on: macos-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
@@ -18,7 +35,7 @@ jobs:
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: .sysroot/darwin.tar.gz
|
||||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||||
key: ${{ needs.setup.outputs.darwin-cache-key }}
|
||||
lookup-only: true
|
||||
- name: Populate Darwin sysroot
|
||||
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
|
||||
@@ -31,9 +48,10 @@ jobs:
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: .sysroot/darwin.tar.gz
|
||||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||||
key: ${{ needs.setup.outputs.darwin-cache-key }}
|
||||
populate-linux-sysroot:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
@@ -42,7 +60,7 @@ jobs:
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: .sysroot/linux.tar.gz
|
||||
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7
|
||||
key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||
lookup-only: true
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
@@ -60,15 +78,18 @@ jobs:
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: .sysroot/linux.tar.gz
|
||||
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7
|
||||
key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [populate-darwin-sysroot, populate-linux-sysroot]
|
||||
needs: [setup, populate-darwin-sysroot, populate-linux-sysroot]
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
- name: Set up Release
|
||||
uses: ./.github/actions/setup-goreleaser
|
||||
with:
|
||||
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
|
||||
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||
- name: Run GoReleaser (Build & Test)
|
||||
env:
|
||||
GITHUB_TOKEN: ${{github.token}}
|
||||
@@ -178,7 +199,7 @@ jobs:
|
||||
mod-version: ${{ matrix.go-mod-version }}
|
||||
|
||||
release:
|
||||
needs: [build, test-artifacts]
|
||||
needs: [setup, build, test-artifacts]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
@@ -188,6 +209,9 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Set up Release
|
||||
uses: ./.github/actions/setup-goreleaser
|
||||
with:
|
||||
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
|
||||
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||
- name: Run GoReleaser (Release)
|
||||
env:
|
||||
GITHUB_TOKEN: ${{github.token}}
|
||||
|
||||
Reference in New Issue
Block a user