config.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. version: 2.1
  2. workflows:
  3. version: 2
  4. build:
  5. jobs:
  6. - checkout_code
  7. - lint:
  8. requires:
  9. - checkout_code
  10. go_version: "1.16"
  11. vips_version: "8.10"
  12. - build:
  13. name: go<< matrix.go_version >>_vips<< matrix.vips_version >>
  14. requires:
  15. - checkout_code
  16. matrix:
  17. parameters:
  18. go_version: ["1.17", "1.16"] # Go 1.15 doesn't support io/fs
  19. vips_version: ["8.12", "8.11", "8.10"]
  20. release:
  21. jobs:
  22. - checkout_code:
  23. filters: &release_tags_filter
  24. branches:
  25. ignore: /.*/
  26. tags:
  27. only: /^v\d+\.\d+\.\d+.*/
  28. - publish_github_release:
  29. requires:
  30. - checkout_code # to grab changes from CHANGELOG
  31. filters: *release_tags_filter
  32. executors:
  33. imgproxy:
  34. docker:
  35. - image: "darthsim/imgproxy-circleci:latest"
  36. working_directory: /go/src/imgproxy
  37. environment:
  38. BASH_ENV: "/root/.bashrc"
  39. TEST_RESULTS: /tmp/test-results
  40. commands:
  41. setup_vips:
  42. parameters:
  43. vips_version:
  44. type: string
  45. steps:
  46. - run:
  47. name: Setup Vips
  48. command: |
  49. echo 'LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/vips/<< parameters.vips_version >>/lib"' >> $BASH_ENV
  50. echo 'PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/root/vips/<< parameters.vips_version >>/lib/pkgconfig"' >> $BASH_ENV
  51. install_go:
  52. parameters:
  53. go_version:
  54. type: string
  55. steps:
  56. - run:
  57. name: Install Go
  58. command: |
  59. gvm install go<< parameters.go_version >> -B
  60. gvm use go<< parameters.go_version >> --default
  61. echo 'export GO111MODULE=on' >> $BASH_ENV
  62. echo 'export GOPATH=/go' >> $BASH_ENV
  63. echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> $BASH_ENV
  64. echo 'export CGO_LDFLAGS_ALLOW="-s|-w"' >> $BASH_ENV
  65. - run:
  66. name: Install gotestsum
  67. command: |
  68. mkdir -p /usr/local/bin && \
  69. curl -Ls https://github.com/gotestyourself/gotestsum/releases/download/v1.6.4/gotestsum_1.6.4_linux_amd64.tar.gz | \
  70. tar -xzC /usr/local/bin
  71. jobs:
  72. checkout_code:
  73. docker:
  74. - image: circleci/slim-base:latest
  75. working_directory: /go/src/imgproxy
  76. steps:
  77. - checkout:
  78. path: /go/src/imgproxy
  79. - persist_to_workspace:
  80. root: .
  81. paths: [.]
  82. lint:
  83. executor: imgproxy
  84. parameters:
  85. vips_version:
  86. type: string
  87. go_version:
  88. type: string
  89. steps:
  90. - attach_workspace:
  91. at: .
  92. - setup_vips:
  93. vips_version: << parameters.vips_version >>
  94. - install_go:
  95. go_version: << parameters.go_version >>
  96. - run:
  97. name: Install golangci-lint
  98. command: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint sh -s -- -b $(go env GOPATH)/bin v1.18.0
  99. - run:
  100. name: Lint imgproxy
  101. command: golangci-lint run
  102. build:
  103. executor: imgproxy
  104. parameters:
  105. vips_version:
  106. type: string
  107. go_version:
  108. type: string
  109. steps:
  110. - attach_workspace:
  111. at: .
  112. - setup_vips:
  113. vips_version: << parameters.vips_version >>
  114. - install_go:
  115. go_version: << parameters.go_version >>
  116. - restore_cache:
  117. keys:
  118. - go-modules-{{ checksum "go.sum" }}
  119. - run:
  120. name: Build imgproxy
  121. command: |
  122. mkdir -p $TEST_RESULTS && \
  123. gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- ./...
  124. - save_cache:
  125. key: go-modules-{{ checksum "go.sum" }}
  126. paths:
  127. - "/go/pkg/mod"
  128. - store_artifacts:
  129. path: /tmp/test-results
  130. destination: raw-test-output
  131. - store_test_results:
  132. path: /tmp/test-results
  133. publish_github_release:
  134. executor: imgproxy
  135. steps:
  136. - attach_workspace:
  137. at: .
  138. - install_go:
  139. go_version: "1.14"
  140. - run:
  141. name: Install github-release tool
  142. command: go get github.com/github-release/github-release
  143. - run:
  144. name: Upload GitHub release
  145. command: |
  146. # Extract changelog entries between this and previous version headers
  147. escaped_version=$(echo ${CIRCLE_TAG#v} | sed -e 's/[]\/$*.^[]/\\&/g')
  148. description_body=$(awk "BEGIN{inrelease=0} /## \[${escaped_version}\]/{inrelease=1;next} /## \[[0-9]+\.[0-9]+\.[0-9]+\]/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
  149. # Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
  150. [[ ${CIRCLE_TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]] && prerelease="--pre-release"
  151. # Create release!
  152. github-release release \
  153. --user ${CIRCLE_PROJECT_USERNAME} \
  154. --repo ${CIRCLE_PROJECT_REPONAME} \
  155. --tag ${CIRCLE_TAG} \
  156. --name ${CIRCLE_TAG} \
  157. --description "${description_body}" \
  158. $prerelease