|
|
|
@ -7,22 +7,6 @@ platform: |
|
|
|
arch: amd64 |
|
|
|
|
|
|
|
steps: |
|
|
|
# 使用缓存进行存储 |
|
|
|
- name: restore-cache |
|
|
|
image: meltwater/drone-cache |
|
|
|
pull: always |
|
|
|
settings: |
|
|
|
backend: "filesystem" |
|
|
|
restore: true |
|
|
|
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}' |
|
|
|
archive_format: "gzip" |
|
|
|
mount: |
|
|
|
- pkg.mod |
|
|
|
- pkg.build |
|
|
|
volumes: |
|
|
|
- name: cache |
|
|
|
path: /go |
|
|
|
|
|
|
|
# golang 编译 |
|
|
|
- name: build |
|
|
|
image: golang:1.17 |
|
|
|
@ -36,29 +20,13 @@ steps: |
|
|
|
commands: |
|
|
|
- go build -ldflags "-w -s" -o tmp/carp main.go |
|
|
|
volumes: |
|
|
|
- name: cache |
|
|
|
path: /go |
|
|
|
- name: pkgdeps |
|
|
|
path: /drone/src |
|
|
|
when: |
|
|
|
event: |
|
|
|
- push |
|
|
|
- tag |
|
|
|
|
|
|
|
# 缓存编译 |
|
|
|
- name: rebuild-cache |
|
|
|
image: meltwater/drone-cache |
|
|
|
pull: if-not-exists |
|
|
|
settings: |
|
|
|
backend: "filesystem" |
|
|
|
rebuild: true |
|
|
|
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}' |
|
|
|
archive_format: "gzip" |
|
|
|
mount: |
|
|
|
- pkg.mod |
|
|
|
- pkg.build |
|
|
|
volumes: |
|
|
|
- name: cache |
|
|
|
path: /go |
|
|
|
|
|
|
|
# 发布,编译镜像并推送到私有镜像仓库 |
|
|
|
- name: publish |
|
|
|
image: plugins/docker |
|
|
|
@ -130,6 +98,7 @@ steps: |
|
|
|
when: |
|
|
|
status: [failure, success] |
|
|
|
|
|
|
|
volumes: |
|
|
|
- name: cache |
|
|
|
temp: {} |
|
|
|
volumes: # 挂载,持久化数据 |
|
|
|
- name: pkgdeps |
|
|
|
host: |
|
|
|
path: /tmp/pkg/repotest |