.drone.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. ---
  2. kind: pipeline
  3. name: build linux/amd64
  4. steps:
  5. - commands:
  6. - git fetch --tags
  7. image: alpine/git
  8. name: fetch tags
  9. - commands:
  10. - go test -v ./...
  11. environment:
  12. GOPROXY: https://goproxy.io,direct
  13. image: golang:1.23
  14. name: go test
  15. - commands:
  16. - DIST_DIR=$(mktemp -d)
  17. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  18. --always)" -o $DIST_DIR ./cmd/um
  19. - mkdir -p dist
  20. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64-$(git describe --tags
  21. --always).tar.gz"
  22. environment:
  23. GOARCH: amd64
  24. GOOS: linux
  25. GOPROXY: https://goproxy.io,direct
  26. image: golang:1.23
  27. name: go build linux/amd64
  28. - commands:
  29. - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64-$(git
  30. describe --tags --always).tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64-$(git
  31. describe --tags --always).tar.gz"
  32. - sha256sum dist/um-linux-amd64-$(git describe --tags --always).tar.gz
  33. - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
  34. environment:
  35. DRONE_GITEA_SERVER: https://git.unlock-music.dev
  36. GITEA_API_KEY:
  37. from_secret: GITEA_API_KEY
  38. image: golang:1.23
  39. name: upload artifact
  40. trigger:
  41. event:
  42. - push
  43. - pull_request
  44. type: docker
  45. ---
  46. kind: pipeline
  47. name: build windows/amd64
  48. steps:
  49. - commands:
  50. - git fetch --tags
  51. image: alpine/git
  52. name: fetch tags
  53. - commands:
  54. - DIST_DIR=$(mktemp -d)
  55. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  56. --always)" -o $DIST_DIR ./cmd/um
  57. - mkdir -p dist
  58. - command -v zip >/dev/null || (apt update && apt install -y zip)
  59. - zip -9 -j -r "dist/um-windows-amd64-$(git describe --tags --always).zip" $DIST_DIR
  60. environment:
  61. GOARCH: amd64
  62. GOOS: windows
  63. GOPROXY: https://goproxy.io,direct
  64. image: golang:1.23
  65. name: go build windows/amd64
  66. - commands:
  67. - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64-$(git
  68. describe --tags --always).zip" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64-$(git
  69. describe --tags --always).zip"
  70. - sha256sum dist/um-windows-amd64-$(git describe --tags --always).zip
  71. - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
  72. environment:
  73. DRONE_GITEA_SERVER: https://git.unlock-music.dev
  74. GITEA_API_KEY:
  75. from_secret: GITEA_API_KEY
  76. image: golang:1.23
  77. name: upload artifact
  78. trigger:
  79. event:
  80. - push
  81. - pull_request
  82. type: docker
  83. ---
  84. kind: pipeline
  85. name: build darwin/amd64
  86. steps:
  87. - commands:
  88. - git fetch --tags
  89. image: alpine/git
  90. name: fetch tags
  91. - commands:
  92. - DIST_DIR=$(mktemp -d)
  93. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  94. --always)" -o $DIST_DIR ./cmd/um
  95. - mkdir -p dist
  96. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64-$(git describe --tags
  97. --always).tar.gz"
  98. environment:
  99. GOARCH: amd64
  100. GOOS: darwin
  101. GOPROXY: https://goproxy.io,direct
  102. image: golang:1.23
  103. name: go build darwin/amd64
  104. - commands:
  105. - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64-$(git
  106. describe --tags --always).tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64-$(git
  107. describe --tags --always).tar.gz"
  108. - sha256sum dist/um-darwin-amd64-$(git describe --tags --always).tar.gz
  109. - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
  110. environment:
  111. DRONE_GITEA_SERVER: https://git.unlock-music.dev
  112. GITEA_API_KEY:
  113. from_secret: GITEA_API_KEY
  114. image: golang:1.23
  115. name: upload artifact
  116. trigger:
  117. event:
  118. - push
  119. - pull_request
  120. type: docker
  121. ---
  122. kind: pipeline
  123. name: release
  124. steps:
  125. - commands:
  126. - git fetch --tags
  127. image: alpine/git
  128. name: fetch tags
  129. - commands:
  130. - go test -v ./...
  131. environment:
  132. GOPROXY: https://goproxy.io,direct
  133. image: golang:1.23
  134. name: go test
  135. - commands:
  136. - DIST_DIR=$(mktemp -d)
  137. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  138. --always)" -o $DIST_DIR ./cmd/um
  139. - mkdir -p dist
  140. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64-$(git describe --tags
  141. --always).tar.gz"
  142. environment:
  143. GOARCH: amd64
  144. GOOS: linux
  145. GOPROXY: https://goproxy.io,direct
  146. image: golang:1.23
  147. name: go build linux/amd64
  148. - commands:
  149. - DIST_DIR=$(mktemp -d)
  150. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  151. --always)" -o $DIST_DIR ./cmd/um
  152. - mkdir -p dist
  153. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-arm64-$(git describe --tags
  154. --always).tar.gz"
  155. environment:
  156. GOARCH: arm64
  157. GOOS: linux
  158. GOPROXY: https://goproxy.io,direct
  159. image: golang:1.23
  160. name: go build linux/arm64
  161. - commands:
  162. - DIST_DIR=$(mktemp -d)
  163. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  164. --always)" -o $DIST_DIR ./cmd/um
  165. - mkdir -p dist
  166. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-386-$(git describe --tags --always).tar.gz"
  167. environment:
  168. GOARCH: "386"
  169. GOOS: linux
  170. GOPROXY: https://goproxy.io,direct
  171. image: golang:1.23
  172. name: go build linux/386
  173. - commands:
  174. - DIST_DIR=$(mktemp -d)
  175. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  176. --always)" -o $DIST_DIR ./cmd/um
  177. - mkdir -p dist
  178. - command -v zip >/dev/null || (apt update && apt install -y zip)
  179. - zip -9 -j -r "dist/um-windows-amd64-$(git describe --tags --always).zip" $DIST_DIR
  180. environment:
  181. GOARCH: amd64
  182. GOOS: windows
  183. GOPROXY: https://goproxy.io,direct
  184. image: golang:1.23
  185. name: go build windows/amd64
  186. - commands:
  187. - DIST_DIR=$(mktemp -d)
  188. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  189. --always)" -o $DIST_DIR ./cmd/um
  190. - mkdir -p dist
  191. - command -v zip >/dev/null || (apt update && apt install -y zip)
  192. - zip -9 -j -r "dist/um-windows-arm64-$(git describe --tags --always).zip" $DIST_DIR
  193. environment:
  194. GOARCH: arm64
  195. GOOS: windows
  196. GOPROXY: https://goproxy.io,direct
  197. image: golang:1.23
  198. name: go build windows/arm64
  199. - commands:
  200. - DIST_DIR=$(mktemp -d)
  201. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  202. --always)" -o $DIST_DIR ./cmd/um
  203. - mkdir -p dist
  204. - command -v zip >/dev/null || (apt update && apt install -y zip)
  205. - zip -9 -j -r "dist/um-windows-386-$(git describe --tags --always).zip" $DIST_DIR
  206. environment:
  207. GOARCH: "386"
  208. GOOS: windows
  209. GOPROXY: https://goproxy.io,direct
  210. image: golang:1.23
  211. name: go build windows/386
  212. - commands:
  213. - DIST_DIR=$(mktemp -d)
  214. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  215. --always)" -o $DIST_DIR ./cmd/um
  216. - mkdir -p dist
  217. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64-$(git describe --tags
  218. --always).tar.gz"
  219. environment:
  220. GOARCH: amd64
  221. GOOS: darwin
  222. GOPROXY: https://goproxy.io,direct
  223. image: golang:1.23
  224. name: go build darwin/amd64
  225. - commands:
  226. - DIST_DIR=$(mktemp -d)
  227. - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
  228. --always)" -o $DIST_DIR ./cmd/um
  229. - mkdir -p dist
  230. - tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-arm64-$(git describe --tags
  231. --always).tar.gz"
  232. environment:
  233. GOARCH: arm64
  234. GOOS: darwin
  235. GOPROXY: https://goproxy.io,direct
  236. image: golang:1.23
  237. name: go build darwin/arm64
  238. - commands:
  239. - mv dist/*.tar.gz dist/*.zip ./
  240. image: golang:1.23
  241. name: prepare root
  242. - image: plugins/gitea-release
  243. name: create release
  244. settings:
  245. api_key:
  246. from_secret: GITEA_API_KEY
  247. base_url: https://git.unlock-music.dev
  248. checksum: sha256
  249. draft: true
  250. files:
  251. - um-*.tar.gz
  252. - um-*.zip
  253. title: ${DRONE_TAG}
  254. trigger:
  255. event:
  256. - tag
  257. type: docker