ci(drone): 添加 Go 模块和构建缓存

- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
This commit is contained in:
hxt
2025-07-08 21:02:12 +08:00
parent 5de9db3cc8
commit d4c68baed0

View File

@@ -16,15 +16,27 @@ steps:
- go/pkg/mod - go/pkg/mod
- ~/.cache/go-build - ~/.cache/go-build
backend: local backend: local
cache_key: go-mod-cache-{{ branch }} cache_key: go-mod-cache-${DRONE_BRANCH}
- name: build - name: build
image: golang:1.22 image: golang:1.22
commands: commands:
- echo "==== Before build, go/pkg/mod ===="
- ls -lR /go/pkg/mod || echo "/go/pkg/mod not found"
- echo "==== Before build, /root/.cache/go-build ===="
- ls -lR /root/.cache/go-build || echo "/root/.cache/go-build not found"
- echo "==== Before build, /go/.cache/go-build ===="
- ls -lR /go/.cache/go-build || echo "/go/.cache/go-build not found"
- go env -w GO111MODULE=on - go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct - go env -w GOPROXY=https://goproxy.cn,direct
- go mod tidy - go mod tidy
- go build -o main.exe . - go build -o main.exe .
- echo "==== After build, go/pkg/mod ===="
- ls -lR /go/pkg/mod || echo "/go/pkg/mod not found"
- echo "==== After build, /root/.cache/go-build ===="
- ls -lR /root/.cache/go-build || echo "/root/.cache/go-build not found"
- echo "==== After build, /go/.cache/go-build ===="
- ls -lR /go/.cache/go-build || echo "/go/.cache/go-build not found"
- name: rebuild cache - name: rebuild cache
image: drillster/drone-volume-cache image: drillster/drone-volume-cache
@@ -39,7 +51,7 @@ steps:
- go/pkg/mod - go/pkg/mod
- ~/.cache/go-build - ~/.cache/go-build
backend: local backend: local
cache_key: go-mod-cache-{{ branch }} cache_key: go-mod-cache-${DRONE_BRANCH}
- name: upload - name: upload
image: appleboy/drone-scp image: appleboy/drone-scp