Enhance release workflow with caching steps

Added caching for Go installation and GF CLI in the release workflow.
This commit is contained in:
乔焰阳
2025-11-06 16:03:04 +08:00
committed by GitHub
parent 69b4380e38
commit 7b16777411

View File

@@ -23,15 +23,42 @@ jobs:
- name: Checkout
uses: actions/checkout@v4 # 使用最新稳定的v4版本
- name: Cache Go installation
uses: actions/cache@v4
id: cache-go
with:
path: |
~/.go
/usr/local/go
key: go-installation-${{ runner.os }}-${{ hashFiles('.github/workflows/release.yml') }}
restore-keys: |
go-installation-${{ runner.os }}-
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable' # 使用最新稳定版本的Go无需手动更新版本号
cache: true # 启用Go模块缓存
cache-dependency-path: go.sum # 使用go.sum作为缓存键的一部分
- name: Cache GF CLI
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/gf
key: gf-cli-${{ hashFiles('**/go.mod') }}
restore-keys: gf-cli-
- name: Install gf CLI
run: |
curl -L -o gf https://github.com/gogf/gf/releases/latest/download/gf_linux_amd64
chmod +x gf
# 如果缓存中已有gf CLI直接复制到bin目录否则下载
if [ -f "${{ github.workspace }}/gf" ]; then
echo "Using cached GF CLI"
chmod +x "${{ github.workspace }}/gf"
else
echo "Downloading GF CLI"
curl -L -o gf https://github.com/gogf/gf/releases/latest/download/gf_linux_amd64
chmod +x gf
fi
mkdir -p "$HOME/bin"
mv gf "$HOME/bin/gf"
echo "$HOME/bin" >> $GITHUB_PATH