forked from scjtqs/jd_cookie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
181 lines (168 loc) · 7.03 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
kind: pipeline
type: docker
name: default
# 限制 amd64的runner 执行本脚本。
#platform:
# os: linux
# arch: amd64
clone:
depth: 1
disable: true
steps:
# # 标记runner服务ip
# - name: name
## image: curlimages/curl:7.77.0
# image: alpine:3.13
# pull: if-not-exists
# environment:
# RUNNER_NAME: ${DRONE_RUNNER_NAME}
# commands:
## - env
# - echo ${RUNNER_NAME}
## - env
## - curl -L http://wx.scjtqs.com/ip.php
# 从github拉取代码 加上代理
- name: clone
image: alpine/git
pull: if-not-exists
# environment:
# https_proxy:
# from_secret: http_proxy
# http_proxy:
# from_secret: http_proxy
# all_proxy:
# from_secret: socket_proxy
commands:
- git clone --depth 1 https://hub.fastgit.org/scjtqs/jd_cookie.git -b $DRONE_BRANCH .
# - "[ ''$DRONE_BRANCH'' != 'master' ] && [ ''$DRONE_BANCH'' != 'main' ] && git switch -c ''$DRONE_BRANCH''"
# - git checkout $DRONE_COMMIT
- name: buildtest
image: golang:1.16-alpine
pull: if-not-exists
# environment:
# GOPROXY: "http://goproxy.cn,direct"
# CGO_ENABLED: 1
# GO111MODULE: "on"
# CGO_LDFLAGS: "-static"
commands:
- go env -w GOPROXY="http://goproxy.cn,direct"
- go env -w GO111MODULE=on
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
- apk add --no-cache gcc musl-dev
- go install github.com/mattn/go-sqlite3
# - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- go mod tidy
- go env -w CGO_ENABLED=1
- go env -w CGO_LDFLAGS="-static"
- CGO_ENABLED=1 CGO_LDFLAGS="-static" go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_COMMIT" -installsuffix cgo -o test
- ./test -h
depends_on:
- clone
# volumes:
# - name: dockersock
# path: /var/run
# go build
- name: build
image: golang:1.16-alpine
pull: if-not-exists
# environment:
# GOPROXY: "http://goproxy.cn,direct"
# GO111MODULE: "on"
# CGO_ENABLED: 1
# CGO_LDFLAGS: "-static"
commands:
- go env -w GOPROXY="http://goproxy.cn,direct"
- go env -w GO111MODULE=on
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
- apk add --no-cache gcc musl-dev sqlite-static sqlite-dev sqlite
# - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# - go install github.com/mattn/go-sqlite3
- go mod tidy
- go env -w CGO_ENABLED=0
# - go env -w CGO_LDFLAGS="-static"
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CGO_LDFLAGS="-static" go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_amd64
- GOOS=linux GOARCH=386 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_i386
- GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_armv7
- GOOS=linux GOARCH=arm64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_arm64
- GOOS=linux GOARCH=ppc64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_ppc64
- GOOS=linux GOARCH=ppc64le go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_ppc64le
- GOOS=linux GOARCH=mips go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_mips
- GOOS=linux GOARCH=mipsle go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_mipsle
- GOOS=linux GOARCH=mips64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_mips64
- GOOS=linux GOARCH=mips64le go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_linux_mips64le
- GOOS=windows GOARCH=386 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_windows_i386.exe
- GOOS=windows GOARCH=amd64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_windows_adm64.exe
- GOOS=windows GOARCH=arm GOARM=7 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_windows_arm.exe
- GOOS=darwin GOARCH=arm64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_darwin_arm64
- GOOS=darwin GOARCH=amd64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_darwin_amd64
# - GOOS=android GOARCH=arm GOARM=7 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_android_arm
# - GOOS=android GOARCH=arm64 go build -ldflags "-w -s -X main.Build=`date +%FT%T%z` -X main.Version=$DRONE_TAG" -installsuffix cgo -o dist/jdcookie_v3_android_arm64
depends_on:
- buildtest
when:
event: tag
# volumes:
# - name: dockersock
# path: /var/run
# 发布github的resease
- name: publish
image: plugins/github-release
pull: if-not-exists
settings:
api_key:
from_secret: github_token
files: dist/*
# title: v1.0.0
# note: "第一个公开版本,只提取cookie,不带推送更新cookie到服务器"
# draft: true
# overwrite: true
when:
event: tag
depends_on:
- build
# # docker buildx 多平台镜像编译
# - name: docker buildx
# image: jdrouet/docker-with-buildx:stable
# pull: if-not-exists
# volumes:
# - name: dockersock
# path: /var/run
# environment:
# DOCKER_DRIVER: overlay2
# DOCKER_USERNAME:
# from_secret: docker_username
# DOCKER_PASSWORD:
# from_secret: docker_password
# commands:
# - /bin/sh ./buildx.sh
# depends_on:
# - buildtest
# when:
# branch:
# exclude:
# - feature/*
# event:
# - push
# - pull_request
# - tag
# - promote
# - rollback
#services:
# - name: docker
# image: docker:dind
# detach: true
# privileged: true
# volumes:
# - name: dockersock
# path: /var/run
volumes:
- name: dockersock
temp: {}
trigger:
# branch:
# - master
event:
- custom
- push
- cron
- tag