main.yml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. # TODO: support skip ci (https://github.community/t/github-actions-does-not-respect-skip-ci/17325/8)
  2. name: CI
  3. on: [push, pull_request]
  4. jobs:
  5. cancel:
  6. name: "Cancel previous runs"
  7. runs-on: ubuntu-latest
  8. timeout-minutes: 3
  9. steps:
  10. - uses: styfle/[email protected]
  11. with:
  12. workflow_id: 1447568
  13. access_token: ${{ github.token }}
  14. windows64-build:
  15. runs-on: windows-latest
  16. env:
  17. PLATFORM: windows64
  18. OPAMYES: 1
  19. CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
  20. ARCH: 64
  21. MINGW_ARCH: x86_64
  22. CYGWIN_SETUP: https://cygwin.com/setup-x86_64.exe
  23. CYG_ROOT: C:/cygwin64
  24. steps:
  25. - uses: actions/checkout@main
  26. with:
  27. submodules: recursive
  28. @import install-neko-windows.yml
  29. @import build-windows.yml
  30. windows-build:
  31. runs-on: windows-latest
  32. env:
  33. PLATFORM: windows
  34. OPAMYES: 1
  35. CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
  36. ARCH: 32
  37. MINGW_ARCH: i686
  38. CYGWIN_SETUP: https://cygwin.com/setup-x86.exe
  39. CYG_ROOT: C:/cygwin
  40. steps:
  41. - uses: actions/checkout@main
  42. with:
  43. submodules: recursive
  44. @import install-neko-windows.yml
  45. @import build-windows.yml
  46. linux-build:
  47. runs-on: ubuntu-latest
  48. env:
  49. PLATFORM: linux64
  50. OPAMYES: 1
  51. steps:
  52. - uses: actions/checkout@main
  53. with:
  54. submodules: recursive
  55. @import build-linux.yml
  56. mac-build:
  57. runs-on: macos-latest
  58. env:
  59. PLATFORM: mac
  60. OPAMYES: 1
  61. steps:
  62. - uses: actions/checkout@main
  63. with:
  64. submodules: recursive
  65. @import install-neko-mac.yml
  66. @import build-mac.yml
  67. windows64-test:
  68. needs: windows64-build
  69. runs-on: windows-latest
  70. env:
  71. PLATFORM: windows64
  72. TEST: ${{matrix.target}}
  73. HXCPP_COMPILE_CACHE: ~/hxcache
  74. ARCH: 64
  75. strategy:
  76. fail-fast: false
  77. matrix:
  78. # TODO enable lua after https://github.com/HaxeFoundation/haxe/issues/5024
  79. target: [macro, js, hl, cpp, 'java,jvm', cs, php, python, neko]
  80. steps:
  81. - uses: actions/checkout@main
  82. with:
  83. submodules: recursive
  84. - uses: actions/download-artifact@v1
  85. with:
  86. name: win${{env.ARCH}}Binaries
  87. @import install-neko-windows.yml
  88. @import test-windows.yml
  89. windows-test:
  90. needs: windows-build
  91. runs-on: windows-latest
  92. env:
  93. PLATFORM: windows
  94. TEST: ${{matrix.target}}
  95. HXCPP_COMPILE_CACHE: ~/hxcache
  96. ARCH: 32
  97. strategy:
  98. fail-fast: false
  99. matrix:
  100. # TODO jvm: https://github.com/HaxeFoundation/haxe/issues/8601
  101. # TODO enable lua after https://github.com/HaxeFoundation/haxe/issues/5024
  102. target: [macro, js, hl, cpp, java, cs, php, python, neko]
  103. steps:
  104. - uses: actions/checkout@main
  105. with:
  106. submodules: recursive
  107. - uses: actions/download-artifact@v1
  108. with:
  109. name: win${{env.ARCH}}Binaries
  110. @import install-neko-windows.yml
  111. @import test-windows.yml
  112. linux-test:
  113. needs: linux-build
  114. runs-on: ubuntu-latest
  115. env:
  116. PLATFORM: linux64
  117. TEST: ${{matrix.target}}
  118. HXCPP_COMPILE_CACHE: ~/hxcache
  119. strategy:
  120. fail-fast: false
  121. matrix:
  122. target: [macro, js, hl, cpp, 'java,jvm', cs, php, python, lua, flash9, neko]
  123. include:
  124. - target: js
  125. # SAUCE: 1
  126. # SAUCE_TUNNEL_ID: 'linux-test'
  127. # SAUCE_BUILD: '${{env.GITHUB_RUN_NUMBER}}' # $(Build.BuildNumber)
  128. - target: hl
  129. APT_PACKAGES: cmake ninja-build libturbojpeg-dev
  130. - target: cpp
  131. APT_PACKAGES: gcc-multilib g++-multilib
  132. - target: lua
  133. APT_PACKAGES: ncurses-dev
  134. - target: flash9
  135. APT_PACKAGES: libglib2.0 libfreetype6 xvfb
  136. steps:
  137. - uses: actions/checkout@main
  138. with:
  139. submodules: recursive
  140. - uses: actions/download-artifact@v1
  141. with:
  142. name: linuxBinaries
  143. @import install-neko-linux.yml
  144. @import test-linux.yml
  145. mac-test:
  146. needs: mac-build
  147. runs-on: macos-latest
  148. env:
  149. PLATFORM: mac
  150. TEST: ${{matrix.target}}
  151. HXCPP_COMPILE_CACHE: ~/hxcache
  152. strategy:
  153. fail-fast: false
  154. matrix:
  155. target: [macro, js, hl, cpp, 'java,jvm', cs, php, python, lua, flash9, neko]
  156. include:
  157. - target: hl
  158. BREW_PACKAGES: ninja
  159. steps:
  160. - uses: actions/checkout@main
  161. with:
  162. submodules: recursive
  163. - uses: actions/download-artifact@v1
  164. with:
  165. name: macBinaries
  166. @import install-neko-mac.yml
  167. @import test-mac.yml
  168. deploy:
  169. if: github.event_name != 'pull_request'
  170. needs: [linux-test, mac-test, windows-test, windows64-test]
  171. runs-on: ubuntu-latest
  172. steps:
  173. # this is only needed for to get `COMMIT_DATE`...
  174. # maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
  175. # would be faster
  176. - name: Checkout the repository
  177. uses: actions/checkout@main
  178. - name: Download build artifacts
  179. uses: actions/download-artifact@v2
  180. - name: Install awscli
  181. run: |
  182. set -ex
  183. sudo apt-get update -qqy
  184. sudo apt-get install -qqy awscli
  185. # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
  186. - name: Extract branch name
  187. id: extract_branch
  188. shell: bash
  189. run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
  190. - name: Upload binaries
  191. shell: bash
  192. env:
  193. AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
  194. AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
  195. HXBUILDS_S3ADDR: ${{ secrets.HXBUILDS_S3ADDR }}/gh-actions
  196. run: |
  197. set -ex
  198. COMMIT_HASH_SHORT=${GITHUB_SHA:0:7}
  199. COMMIT_DATE=`TZ=UTC git show --quiet --date='format-local:%Y-%m-%d' --format="%cd"`
  200. FILE_NAME=haxe_${COMMIT_DATE}_${{ steps.extract_branch.outputs.branch }}_${COMMIT_HASH_SHORT}
  201. aws s3 cp linuxBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux64/${FILE_NAME}.tar.gz
  202. aws s3 cp macBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac/${FILE_NAME}.tar.gz
  203. aws s3 cp macBinaries/*_installer.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac-installer/${FILE_NAME}.tar.gz
  204. aws s3 cp win64Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows64/${FILE_NAME}.zip
  205. aws s3 cp win64Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows64-installer/${FILE_NAME}.zip
  206. aws s3 cp win64Binaries/*.nupkg ${HXBUILDS_S3ADDR}/haxe/windows64-choco/
  207. aws s3 cp win32Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows/${FILE_NAME}.zip
  208. aws s3 cp win32Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows-installer/${FILE_NAME}.zip
  209. aws s3 cp win32Binaries/*.nupkg ${HXBUILDS_S3ADDR}/haxe/windows-choco/
  210. - name: Update "latest"
  211. if: github.ref == 'refs/heads/development'
  212. shell: bash
  213. env:
  214. AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
  215. AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
  216. HXBUILDS_S3ADDR: ${{ secrets.HXBUILDS_S3ADDR }}/gh-actions
  217. run: |
  218. set -ex
  219. aws s3 cp linuxBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux64/haxe_latest.tar.gz
  220. aws s3 cp macBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac/haxe_latest.tar.gz
  221. aws s3 cp macBinaries/*_installer.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac-installer/haxe_latest.tar.gz
  222. aws s3 cp win64Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows64/haxe_latest.zip
  223. aws s3 cp win64Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows64-installer/haxe_latest.zip
  224. aws s3 cp win32Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows/haxe_latest.zip
  225. aws s3 cp win32Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows-installer/haxe_latest.zip
  226. # Chocolatey packages have to be named with version number,
  227. # so let's use web redirection to keep the original file name.
  228. [[ "$HXBUILDS_S3ADDR" =~ s3://([^/]+)(.*) ]] && HXBUILDS_S3BUCKET="${BASH_REMATCH[1]}" && HXBUILDS_S3PATH="${BASH_REMATCH[2]}"
  229. [[ `echo win64Binaries/*.nupkg` =~ win64Binaries/(.+) ]] && FILE_NAME="${BASH_REMATCH[1]}"
  230. aws s3 cp ${HXBUILDS_S3ADDR}/haxe/windows64-choco/${FILE_NAME} ${HXBUILDS_S3ADDR}/haxe/windows64-choco/haxe_latest.nupkg --acl public-read --website-redirect "${HXBUILDS_S3PATH}/haxe/windows64-choco/${FILE_NAME}"
  231. [[ `echo win32Binaries/*.nupkg` =~ win32Binaries/(.+) ]] && FILE_NAME="${BASH_REMATCH[1]}"
  232. aws s3 cp ${HXBUILDS_S3ADDR}/haxe/windows-choco/${FILE_NAME} ${HXBUILDS_S3ADDR}/haxe/windows-choco/haxe_latest.nupkg --acl public-read --website-redirect "${HXBUILDS_S3PATH}/haxe/windows-choco/${FILE_NAME}"