main.yml 9.1 KB

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