You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

232 lines
9.9KB

  1. # Golang CircleCI 2.0 configuration file
  2. #
  3. # Check https://circleci.com/docs/2.0/language-go/ for more details
  4. version: 2.1
  5. jobs:
  6. lint:
  7. docker:
  8. - image: circleci/golang:1.14.1
  9. steps:
  10. - checkout
  11. - run:
  12. name: Run golangci-lint
  13. command: |
  14. go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0
  15. golangci-lint run
  16. build-linux:
  17. docker:
  18. - image: circleci/golang:1.14.1
  19. steps:
  20. - checkout
  21. - run:
  22. name: Create artifact upload directory and set variables
  23. command: |
  24. mkdir /tmp/upload
  25. echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV
  26. echo 'export CIVERSION=$(sh contrib/semver/version.sh --bare)' >> $BASH_ENV
  27. echo 'export CIVERSIONRPM=$(sh contrib/semver/version.sh --bare | tr "-" ".")' >> $BASH_ENV
  28. echo 'export CIBRANCH=$(echo $CIRCLE_BRANCH | tr -d "/")' >> $BASH_ENV
  29. case "$CINAME" in \
  30. "yggdrasil") (echo 'export CICONFLICTS=yggdrasil-develop' >> $BASH_ENV) ;; \
  31. "yggdrasil-develop") (echo 'export CICONFLICTS=yggdrasil' >> $BASH_ENV) ;; \
  32. *) (echo 'export CICONFLICTS="yggdrasil yggdrasil-develop"' >> $BASH_ENV) ;; \
  33. esac
  34. git config --global user.email "$(git log --format='%ae' HEAD -1)";
  35. git config --global user.name "$(git log --format='%an' HEAD -1)";
  36. - run:
  37. name: Install RPM utilities
  38. command: |
  39. sudo apt-get update
  40. sudo apt-get install -y rpm file
  41. mkdir -p ~/rpmbuild/BUILD ~/rpmbuild/RPMS ~/rpmbuild/SOURCES ~/rpmbuild/SPECS ~/rpmbuild/SRPMS
  42. - run:
  43. name: Test debug builds
  44. command: |
  45. ./build -d
  46. test -f yggdrasil && test -f yggdrasilctl
  47. - run:
  48. name: Build for Linux (including Debian packages)
  49. command: |
  50. rm -f {yggdrasil,yggdrasilctl}
  51. PKGARCH=amd64 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-amd64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-amd64;
  52. PKGARCH=i386 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-i386 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-i386;
  53. PKGARCH=mipsel sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mipsel && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-mipsel;
  54. PKGARCH=mips sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mips && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-mips;
  55. PKGARCH=armhf sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-armhf && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-armhf;
  56. PKGARCH=armel sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-armel && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-armel;
  57. PKGARCH=arm64 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-arm64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-linux-arm64;
  58. mv *.deb /tmp/upload/
  59. - run:
  60. name: Build for Linux (RPM packages)
  61. command: |
  62. git clone https://github.com/yggdrasil-network/yggdrasil-package-rpm ~/rpmbuild/SPECS
  63. cd ../ && tar -czvf ~/rpmbuild/SOURCES/v$CIVERSIONRPM --transform "s/project/yggdrasil-go-$CIBRANCH-$CIVERSIONRPM/" project
  64. sed -i "s/yggdrasil-go/yggdrasil-go-$CIBRANCH/" ~/rpmbuild/SPECS/yggdrasil.spec
  65. sed -i "s/^PKGNAME=yggdrasil/PKGNAME=yggdrasil-$CIBRANCH/" ~/rpmbuild/SPECS/yggdrasil.spec
  66. sed -i "s/^Name\:.*/Name\: $CINAME/" ~/rpmbuild/SPECS/yggdrasil.spec
  67. sed -i "s/^Version\:.*/Version\: $CIVERSIONRPM/" ~/rpmbuild/SPECS/yggdrasil.spec
  68. sed -i "s/^Conflicts\:.*/Conflicts\: $CICONFLICTS/" ~/rpmbuild/SPECS/yggdrasil.spec
  69. cat ~/rpmbuild/SPECS/yggdrasil.spec
  70. GOARCH=amd64 rpmbuild -v --nodeps --target=x86_64 -ba ~/rpmbuild/SPECS/yggdrasil.spec
  71. #GOARCH=386 rpmbuild -v --nodeps --target=i386 -bb ~/rpmbuild/SPECS/yggdrasil.spec
  72. find ~/rpmbuild/RPMS/ -name '*.rpm' -exec mv {} /tmp/upload \;
  73. find ~/rpmbuild/SRPMS/ -name '*.rpm' -exec mv {} /tmp/upload \;
  74. - run:
  75. name: Build for EdgeRouter and VyOS
  76. command: |
  77. rm -f {yggdrasil,yggdrasilctl}
  78. git clone https://github.com/neilalexander/vyatta-yggdrasil /tmp/vyatta-yggdrasil;
  79. cd /tmp/vyatta-yggdrasil;
  80. BUILDDIR_YGG=$CIRCLE_WORKING_DIRECTORY ./build-edgerouter-x $CIRCLE_BRANCH;
  81. BUILDDIR_YGG=$CIRCLE_WORKING_DIRECTORY ./build-edgerouter-lite $CIRCLE_BRANCH;
  82. BUILDDIR_YGG=$CIRCLE_WORKING_DIRECTORY ./build-vyos-i386 $CIRCLE_BRANCH
  83. BUILDDIR_YGG=$CIRCLE_WORKING_DIRECTORY ./build-vyos-amd64 $CIRCLE_BRANCH
  84. mv *.deb /tmp/upload;
  85. - persist_to_workspace:
  86. root: /tmp
  87. paths:
  88. - upload
  89. build-macos:
  90. macos:
  91. xcode: "10.0.0"
  92. working_directory: ~/go/src/github.com/yggdrasil-network/yggdrasil-go
  93. steps:
  94. - checkout
  95. - run:
  96. name: Create artifact upload directory and set variables
  97. command: |
  98. mkdir /tmp/upload
  99. echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV
  100. echo 'export CIVERSION=$(sh contrib/semver/version.sh --bare)' >> $BASH_ENV
  101. echo 'export PATH=$PATH:/usr/local/go/bin:~/go/bin' >> $BASH_ENV
  102. git config --global user.email "$(git log --format='%ae' HEAD -1)";
  103. git config --global user.name "$(git log --format='%an' HEAD -1)";
  104. echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
  105. - run:
  106. name: Install Go 1.14.1
  107. command: |
  108. cd /tmp
  109. curl -LO https://dl.google.com/go/go1.14.1.darwin-amd64.pkg
  110. sudo installer -pkg /tmp/go1.14.1.darwin-amd64.pkg -target /
  111. #- run:
  112. # name: Install Gomobile
  113. # command: |
  114. # GO111MODULE=off go get golang.org/x/mobile/cmd/gomobile
  115. # gomobile init
  116. - run:
  117. name: Build for macOS
  118. command: |
  119. GO111MODULE=on GOOS=darwin GOARCH=amd64 ./build
  120. cp yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-amd64
  121. cp yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-darwin-amd64;
  122. - run:
  123. name: Build for macOS (.pkg format)
  124. command: |
  125. PKGARCH=amd64 sh contrib/macos/create-pkg.sh
  126. mv *.pkg /tmp/upload/
  127. #- run:
  128. # name: Build framework for iOS (.framework format)
  129. # command: |
  130. # sudo GO111MODULE=off go get -v github.com/yggdrasil-network/yggdrasil-go/cmd/...
  131. # sudo GO111MODULE=off go get -v github.com/yggdrasil-network/yggdrasil-go/src/...
  132. # GO111MODULE=off ./build -i
  133. # mv *.framework /tmp/upload
  134. - persist_to_workspace:
  135. root: /tmp
  136. paths:
  137. - upload
  138. build-other:
  139. docker:
  140. - image: circleci/golang:1.14.1
  141. steps:
  142. - checkout
  143. - run:
  144. name: Create artifact upload directory and set variables
  145. command: |
  146. mkdir /tmp/upload
  147. echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV
  148. echo 'export CIVERSION=$(sh contrib/semver/version.sh --bare)' >> $BASH_ENV
  149. git config --global user.email "$(git log --format='%ae' HEAD -1)";
  150. git config --global user.name "$(git log --format='%an' HEAD -1)";
  151. - run:
  152. name: Build for OpenBSD
  153. command: |
  154. rm -f {yggdrasil,yggdrasilctl}
  155. GOOS=openbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-amd64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-openbsd-amd64;
  156. GOOS=openbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-i386 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-openbsd-i386;
  157. - run:
  158. name: Build for FreeBSD
  159. command: |
  160. rm -f {yggdrasil,yggdrasilctl}
  161. GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-amd64;
  162. GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-i386 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-i386;
  163. - run:
  164. name: Build for Windows
  165. command: |
  166. rm -f {yggdrasil,yggdrasilctl}
  167. GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-amd64.exe;
  168. GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-i386.exe;
  169. - persist_to_workspace:
  170. root: /tmp
  171. paths:
  172. - upload
  173. upload:
  174. machine: true
  175. steps:
  176. - attach_workspace:
  177. at: /tmp
  178. - store_artifacts:
  179. path: /tmp/upload
  180. destination: /
  181. workflows:
  182. version: 2.1
  183. build:
  184. jobs:
  185. - lint
  186. - build-linux:
  187. requires:
  188. - lint
  189. - build-macos:
  190. requires:
  191. - lint
  192. - build-other:
  193. requires:
  194. - lint
  195. - upload:
  196. requires:
  197. - build-linux
  198. - build-macos
  199. - build-other