main.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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-18.04
  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-amd64:
  49. runs-on: ubuntu-18.04
  50. permissions:
  51. packages: write
  52. env:
  53. FORCE_COLOR: 1
  54. steps:
  55. - name: Login to GitHub Container Registry
  56. uses: docker/login-action@v1
  57. with:
  58. registry: ghcr.io
  59. username: ${{ github.actor }}
  60. password: ${{ secrets.GITHUB_TOKEN }}
  61. - name: Install Earthly
  62. run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.13/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'
  63. - uses: actions/checkout@main
  64. with:
  65. submodules: recursive
  66. - name: Set ADD_REVISION=1 for non-release
  67. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  68. run: echo "ADD_REVISION=1" >> $GITHUB_ENV
  69. - name: Set CONTAINER_ vars
  70. run: |
  71. echo "CONTAINER_REG=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV;
  72. echo "CONTAINER_TAG=$(echo ${{ github.ref_name }} | sed -e 's/[^A-Za-z0-9\.]/-/g')" >> $GITHUB_ENV;
  73. - name: Build devcontainer
  74. run: earthly +devcontainer --ADD_REVISION="$ADD_REVISION" --IMAGE_NAME="ghcr.io/${CONTAINER_REG}_devcontainer" --IMAGE_TAG="${CONTAINER_TAG}-amd64" --IMAGE_CACHE="ghcr.io/haxefoundation/haxe_devcontainer:development-amd64"
  75. env:
  76. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  77. EARTHLY_USE_INLINE_CACHE: true
  78. EARTHLY_SAVE_INLINE_CACHE: true
  79. - name: Build
  80. run: earthly +build --ADD_REVISION="$ADD_REVISION"
  81. env:
  82. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  83. EARTHLY_REMOTE_CACHE: "ghcr.io/${{env.CONTAINER_REG}}_cache:build-${{env.CONTAINER_TAG}}-amd64"
  84. - name: Build xmldoc
  85. run: earthly +xmldoc --COMMIT="${{ github.sha }}" --BRANCH="${{ github.ref_name }}"
  86. - name: Upload xmldoc artifact
  87. uses: actions/[email protected]
  88. with:
  89. name: xmldoc
  90. path: extra/doc
  91. - name: Upload artifact
  92. uses: actions/[email protected]
  93. with:
  94. name: linuxBinaries
  95. path: out/linux/amd64
  96. - name: Test
  97. run: earthly +test-all --GITHUB_ACTIONS="$GITHUB_ACTIONS"
  98. env:
  99. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  100. EARTHLY_REMOTE_CACHE: "ghcr.io/${{env.CONTAINER_REG}}_cache:test-${{env.CONTAINER_TAG}}-amd64"
  101. linux-arm64:
  102. runs-on: ubuntu-18.04
  103. permissions:
  104. packages: write
  105. env:
  106. FORCE_COLOR: 1
  107. steps:
  108. - name: Login to GitHub Container Registry
  109. uses: docker/login-action@v1
  110. with:
  111. registry: ghcr.io
  112. username: ${{ github.actor }}
  113. password: ${{ secrets.GITHUB_TOKEN }}
  114. - name: Install Earthly
  115. run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.13/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'
  116. - name: Set up QEMU
  117. id: qemu
  118. uses: docker/setup-qemu-action@v1
  119. with:
  120. image: tonistiigi/binfmt:latest
  121. platforms: all
  122. - uses: actions/checkout@main
  123. with:
  124. submodules: recursive
  125. - name: Set ADD_REVISION=1 for non-release
  126. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  127. run: echo "ADD_REVISION=1" >> $GITHUB_ENV
  128. - name: Set CONTAINER_ vars
  129. run: |
  130. echo "CONTAINER_REG=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV;
  131. echo "CONTAINER_TAG=$(echo ${{ github.ref_name }} | sed -e 's/[^A-Za-z0-9\.]/-/g')" >> $GITHUB_ENV;
  132. - name: Build devcontainer
  133. run: earthly --platform=linux/arm64 +devcontainer --ADD_REVISION="$ADD_REVISION" --IMAGE_NAME="ghcr.io/${CONTAINER_REG}_devcontainer" --IMAGE_TAG="${CONTAINER_TAG}-arm64" --IMAGE_CACHE="ghcr.io/haxefoundation/haxe_devcontainer:development-arm64"
  134. env:
  135. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  136. EARTHLY_USE_INLINE_CACHE: true
  137. EARTHLY_SAVE_INLINE_CACHE: true
  138. - name: Build
  139. run: earthly --platform=linux/arm64 +build --ADD_REVISION="$ADD_REVISION"
  140. env:
  141. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  142. EARTHLY_REMOTE_CACHE: "ghcr.io/${{env.CONTAINER_REG}}_cache:build-${{env.CONTAINER_TAG}}-arm64"
  143. - name: Upload artifact
  144. uses: actions/[email protected]
  145. with:
  146. name: linuxArm64Binaries
  147. path: out/linux/arm64
  148. # Do not run test for arm64 for now
  149. linux-multiarch:
  150. needs: [linux-amd64, linux-arm64]
  151. runs-on: ubuntu-18.04
  152. permissions:
  153. packages: write
  154. env:
  155. FORCE_COLOR: 1
  156. steps:
  157. - name: Login to GitHub Container Registry
  158. uses: docker/login-action@v1
  159. with:
  160. registry: ghcr.io
  161. username: ${{ github.actor }}
  162. password: ${{ secrets.GITHUB_TOKEN }}
  163. - name: Install Earthly
  164. run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.13/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'
  165. - name: Set up QEMU
  166. id: qemu
  167. uses: docker/setup-qemu-action@v1
  168. with:
  169. image: tonistiigi/binfmt:latest
  170. platforms: all
  171. - uses: actions/checkout@main
  172. with:
  173. submodules: recursive
  174. - name: Set ADD_REVISION=1 for non-release
  175. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  176. run: echo "ADD_REVISION=1" >> $GITHUB_ENV
  177. - name: Set CONTAINER_ vars
  178. run: |
  179. echo "CONTAINER_REG=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV;
  180. echo "CONTAINER_TAG=$(echo ${{ github.ref_name }} | sed -e 's/[^A-Za-z0-9\.]/-/g')" >> $GITHUB_ENV;
  181. - name: Build devcontainer
  182. run: earthly +devcontainer-multiarch --ADD_REVISION="$ADD_REVISION" --IMAGE_NAME="ghcr.io/${CONTAINER_REG}_devcontainer" --IMAGE_TAG="${CONTAINER_TAG}"
  183. env:
  184. EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
  185. EARTHLY_USE_INLINE_CACHE: true
  186. EARTHLY_SAVE_INLINE_CACHE: true
  187. mac-build:
  188. runs-on: macos-latest
  189. env:
  190. PLATFORM: mac
  191. OPAMYES: 1
  192. MACOSX_DEPLOYMENT_TARGET: 10.13
  193. steps:
  194. - uses: actions/checkout@main
  195. with:
  196. submodules: recursive
  197. @import install-neko-unix.yml
  198. @import build-mac.yml
  199. windows64-test:
  200. needs: windows64-build
  201. runs-on: windows-latest
  202. env:
  203. ACTIONS_ALLOW_UNSECURE_COMMANDS: true
  204. PLATFORM: windows64
  205. TEST: ${{matrix.target}}
  206. HXCPP_COMPILE_CACHE: ~/hxcache
  207. ARCH: 64
  208. strategy:
  209. fail-fast: false
  210. matrix:
  211. # TODO enable lua after https://github.com/HaxeFoundation/haxe/issues/5024
  212. target: [macro, js, hl, cpp, 'java,jvm', cs, php, python, flash9, neko]
  213. steps:
  214. - uses: actions/checkout@main
  215. with:
  216. submodules: recursive
  217. - uses: actions/download-artifact@v1
  218. with:
  219. name: win${{env.ARCH}}Binaries
  220. @import install-neko-windows.yml
  221. @import test-windows.yml
  222. windows-test:
  223. needs: windows-build
  224. runs-on: windows-latest
  225. env:
  226. ACTIONS_ALLOW_UNSECURE_COMMANDS: true
  227. PLATFORM: windows
  228. TEST: ${{matrix.target}}
  229. HXCPP_COMPILE_CACHE: ~/hxcache
  230. ARCH: 32
  231. strategy:
  232. fail-fast: false
  233. matrix:
  234. # TODO jvm: https://github.com/HaxeFoundation/haxe/issues/8601
  235. # TODO enable lua after https://github.com/HaxeFoundation/haxe/issues/5024
  236. target: [macro, js, hl, cpp, java, cs, php, python, neko]
  237. steps:
  238. - uses: actions/checkout@main
  239. with:
  240. submodules: recursive
  241. - uses: actions/download-artifact@v1
  242. with:
  243. name: win${{env.ARCH}}Binaries
  244. @import install-neko-windows.yml
  245. @import test-windows.yml
  246. mac-test:
  247. needs: mac-build
  248. runs-on: macos-latest
  249. env:
  250. PLATFORM: mac
  251. TEST: ${{matrix.target}}
  252. HXCPP_COMPILE_CACHE: ~/hxcache
  253. strategy:
  254. fail-fast: false
  255. matrix:
  256. target: [macro, js, hl, cpp, 'java,jvm', cs, php, python, flash9, neko]
  257. include:
  258. - target: hl
  259. BREW_PACKAGES: ninja
  260. steps:
  261. - uses: actions/checkout@main
  262. with:
  263. submodules: recursive
  264. - uses: actions/download-artifact@v1
  265. with:
  266. name: macBinaries
  267. @import install-neko-unix.yml
  268. @import test-mac.yml
  269. deploy:
  270. if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
  271. needs: [linux-amd64, linux-arm64, mac-test, windows-test, windows64-test]
  272. runs-on: ubuntu-18.04
  273. steps:
  274. # this is only needed for to get `COMMIT_DATE`...
  275. # maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
  276. # would be faster
  277. - name: Checkout the repository
  278. uses: actions/checkout@main
  279. - name: Download build artifacts
  280. uses: actions/download-artifact@v2
  281. - name: Install awscli
  282. run: |
  283. set -ex
  284. sudo apt-get update -qqy
  285. sudo apt-get install -qqy awscli
  286. # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
  287. - name: Extract branch name
  288. id: extract_branch
  289. shell: bash
  290. run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
  291. - name: Upload binaries
  292. shell: bash
  293. env:
  294. AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
  295. AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
  296. HXBUILDS_S3ADDR: ${{ secrets.HXBUILDS_S3ADDR }}
  297. AWS_EC2_METADATA_DISABLED: true
  298. run: |
  299. set -ex
  300. COMMIT_HASH_SHORT=${GITHUB_SHA:0:7}
  301. COMMIT_DATE=`TZ=UTC git show --quiet --date='format-local:%Y-%m-%d' --format="%cd"`
  302. FILE_NAME=haxe_${COMMIT_DATE}_${{ steps.extract_branch.outputs.branch }}_${COMMIT_HASH_SHORT}
  303. aws s3 cp linuxBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux64/${FILE_NAME}.tar.gz
  304. aws s3 cp linuxArm64Binaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux-arm64/${FILE_NAME}.tar.gz
  305. aws s3 cp macBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac/${FILE_NAME}.tar.gz
  306. aws s3 cp macBinaries/*_installer.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac-installer/${FILE_NAME}.tar.gz
  307. aws s3 cp win64Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows64/${FILE_NAME}.zip
  308. aws s3 cp win64Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows64-installer/${FILE_NAME}.zip
  309. aws s3 cp win64Binaries/*.nupkg ${HXBUILDS_S3ADDR}/haxe/windows64-choco/
  310. aws s3 cp win32Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows/${FILE_NAME}.zip
  311. aws s3 cp win32Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows-installer/${FILE_NAME}.zip
  312. aws s3 cp win32Binaries/*.nupkg ${HXBUILDS_S3ADDR}/haxe/windows-choco/
  313. - name: Update "latest"
  314. if: github.ref == 'refs/heads/development'
  315. shell: bash
  316. env:
  317. AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
  318. AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
  319. HXBUILDS_S3ADDR: ${{ secrets.HXBUILDS_S3ADDR }}
  320. AWS_EC2_METADATA_DISABLED: true
  321. run: |
  322. set -ex
  323. aws s3 cp linuxBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux64/haxe_latest.tar.gz
  324. aws s3 cp linuxArm64Binaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/linux-arm64/haxe_latest.tar.gz
  325. aws s3 cp macBinaries/*_bin.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac/haxe_latest.tar.gz
  326. aws s3 cp macBinaries/*_installer.tar.gz ${HXBUILDS_S3ADDR}/haxe/mac-installer/haxe_latest.tar.gz
  327. aws s3 cp win64Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows64/haxe_latest.zip
  328. aws s3 cp win64Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows64-installer/haxe_latest.zip
  329. aws s3 cp win32Binaries/*_bin.zip ${HXBUILDS_S3ADDR}/haxe/windows/haxe_latest.zip
  330. aws s3 cp win32Binaries/*_installer.zip ${HXBUILDS_S3ADDR}/haxe/windows-installer/haxe_latest.zip
  331. # Chocolatey packages have to be named with version number,
  332. # so let's use web redirection to keep the original file name.
  333. [[ "$HXBUILDS_S3ADDR" =~ s3://([^/]+)(.*) ]] && HXBUILDS_S3BUCKET="${BASH_REMATCH[1]}" && HXBUILDS_S3PATH="${BASH_REMATCH[2]}"
  334. [[ `echo win64Binaries/*.nupkg` =~ win64Binaries/(.+) ]] && FILE_NAME="${BASH_REMATCH[1]}"
  335. 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}"
  336. [[ `echo win32Binaries/*.nupkg` =~ win32Binaries/(.+) ]] && FILE_NAME="${BASH_REMATCH[1]}"
  337. 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}"
  338. deploy_apidoc:
  339. if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
  340. needs: [linux-amd64, linux-arm64, mac-test, windows-test, windows64-test]
  341. runs-on: ubuntu-18.04
  342. steps:
  343. - name: Download Haxe
  344. uses: actions/download-artifact@v2
  345. with:
  346. name: linuxBinaries
  347. path: linuxBinaries
  348. - name: Setup Haxe
  349. run: |
  350. set -ex
  351. tar -xf linuxBinaries/*_bin.tar.gz -C linuxBinaries --strip-components=1
  352. sudo mkdir -p /usr/local/bin/
  353. sudo mkdir -p /usr/local/share/haxe/
  354. sudo ln -s `pwd`/linuxBinaries/haxe /usr/local/bin/haxe
  355. sudo ln -s `pwd`/linuxBinaries/haxelib /usr/local/bin/haxelib
  356. sudo ln -s `pwd`/linuxBinaries/std /usr/local/share/haxe/std
  357. - name: Download xmldoc artifact
  358. uses: actions/download-artifact@v2
  359. with:
  360. name: xmldoc
  361. path: xmldoc
  362. - name: Deploy to api.haxe.org
  363. env:
  364. GHP_EMAIL: [email protected]
  365. GHP_USERNAME: Haxe CI Bot
  366. GHP_REMOTE: ${{ secrets.GHP_REMOTE }}
  367. run: |
  368. set -ex
  369. LOCAL="`pwd`/extra/api.haxe.org"
  370. git clone "${GHP_REMOTE}" "${LOCAL}"
  371. haxe --cwd "${LOCAL}" --run ImportXml "`pwd`/xmldoc"