mirror of
https://github.com/ayflying/p2p.git
synced 2026-03-05 01:39:23 +00:00
Enhance release workflow with caching steps
Added caching for Go installation and GF CLI in the release workflow.
This commit is contained in:
27
.github/workflows/release.yml
vendored
27
.github/workflows/release.yml
vendored
@@ -23,15 +23,42 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4 # 使用最新稳定的v4版本
|
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
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 'stable' # 使用最新稳定版本的Go,无需手动更新版本号
|
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
|
- name: Install gf CLI
|
||||||
run: |
|
run: |
|
||||||
|
# 如果缓存中已有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
|
curl -L -o gf https://github.com/gogf/gf/releases/latest/download/gf_linux_amd64
|
||||||
chmod +x gf
|
chmod +x gf
|
||||||
|
fi
|
||||||
mkdir -p "$HOME/bin"
|
mkdir -p "$HOME/bin"
|
||||||
mv gf "$HOME/bin/gf"
|
mv gf "$HOME/bin/gf"
|
||||||
echo "$HOME/bin" >> $GITHUB_PATH
|
echo "$HOME/bin" >> $GITHUB_PATH
|
||||||
|
|||||||
Reference in New Issue
Block a user