5 Commits

Author SHA1 Message Date
乔焰阳
7b16777411 Enhance release workflow with caching steps
Added caching for Go installation and GF CLI in the release workflow.
2025-11-06 16:03:04 +08:00
乔焰阳
69b4380e38 Refactor release workflow and update actions
Updated GitHub Actions workflow to remove container configuration and use the latest versions of actions.
2025-11-06 15:58:28 +08:00
乔焰阳
e856543529 Simplify release workflow by removing setup-go step
Removed setup-go step as Go environment is provided by the container image.
2025-11-06 15:50:06 +08:00
乔焰阳
4bed53dc16 Downgrade GitHub actions to v3 2025-11-04 16:12:48 +08:00
14f98a6009 去掉测试代码 2025-11-03 20:51:34 +08:00
2 changed files with 44 additions and 10 deletions

View File

@@ -14,20 +14,51 @@ permissions:
jobs:
build:
# runs-on指定了运行作业的虚拟机环境类型
# 即使使用containerruns-on仍然是必要的配置
runs-on: ubuntu-latest
# 移除容器配置以避免Docker Hub拉取超时问题
# 直接在GitHub托管的runner环境中执行任务
steps:
- name: Checkout
uses: actions/checkout@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
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
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: |
# 如果缓存中已有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
@@ -39,7 +70,8 @@ jobs:
run: gf build -ew -v "${{ github.ref_name }}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
# 使用main分支以获取最新版本的action无需手动更新版本号
uses: actions/upload-artifact@main
with:
name: p2p-${{ github.ref_name }}
path: |
@@ -47,13 +79,18 @@ jobs:
release:
needs: build
# runs-on指定了运行作业的虚拟机环境类型
# 即使使用containerruns-on仍然是必要的配置
runs-on: ubuntu-latest
# 移除容器配置以避免Docker Hub拉取超时问题
# 直接在GitHub托管的runner环境中执行任务
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
# 使用main分支以获取最新版本的action无需手动更新版本号
uses: actions/download-artifact@main
with:
name: p2p-${{ github.ref_name }}
path: bin
@@ -84,7 +121,7 @@ jobs:
ls -al dist
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2 # 更新到最新稳定的v2版本
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}

View File

@@ -7,7 +7,6 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcron"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gfile"
)
func Boot() {
@@ -15,8 +14,6 @@ func Boot() {
getDev, _ := g.Cfg().GetWithEnv(gctx.New(), "dev")
if !getDev.Bool() {
var update = updateGithub.New("https://api.github.com/repos/ayflying/p2p/releases/latest")
gfile.PutContents("version.txt", "v0.0.9")
// 每天0点检查更新
gcron.Add(gctx.New(), "0 0 0 * * *", func(ctx context.Context) {
err := update.CheckUpdate(true)