ci(drone): 添加 Go 模块和构建缓存
- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
This commit is contained in:
16
.drone.yml
16
.drone.yml
@@ -16,15 +16,27 @@ steps:
|
||||
- go/pkg/mod
|
||||
- ~/.cache/go-build
|
||||
backend: local
|
||||
cache_key: go-mod-cache-{{ branch }}
|
||||
cache_key: go-mod-cache-${DRONE_BRANCH}
|
||||
|
||||
- name: build
|
||||
image: golang:1.22
|
||||
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 GOPROXY=https://goproxy.cn,direct
|
||||
- go mod tidy
|
||||
- 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
|
||||
image: drillster/drone-volume-cache
|
||||
@@ -39,7 +51,7 @@ steps:
|
||||
- go/pkg/mod
|
||||
- ~/.cache/go-build
|
||||
backend: local
|
||||
cache_key: go-mod-cache-{{ branch }}
|
||||
cache_key: go-mod-cache-${DRONE_BRANCH}
|
||||
|
||||
- name: upload
|
||||
image: appleboy/drone-scp
|
||||
|
||||
Reference in New Issue
Block a user