wasm.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # SuperTux
  2. # Copyright (C) 2020-2021 Jacob Burroughs <maths22@gmail.com>
  3. # 2020-2022 A. Semphris <semphris@protonmail.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. name: WebAssembly
  18. on:
  19. push:
  20. branches:
  21. - master
  22. tags:
  23. - '*'
  24. pull_request: {}
  25. jobs:
  26. wasm:
  27. strategy:
  28. fail-fast: false
  29. matrix:
  30. build_type: ["Release", "Debug"]
  31. runs-on: ubuntu-latest
  32. steps:
  33. - uses: actions/checkout@v2
  34. with:
  35. # Fetch the whole tree so git describe works
  36. fetch-depth: 0
  37. submodules: true
  38. - name: Install emscripten tools
  39. run: |
  40. cd ~
  41. sudo apt-get update
  42. sudo apt-get install -y git cmake build-essential curl zip
  43. git clone https://github.com/emscripten-core/emsdk.git
  44. cd emsdk
  45. ./emsdk install latest
  46. ./emsdk activate latest
  47. - name: Configure build
  48. env:
  49. BUILD_TYPE: ${{ matrix.build_type }}
  50. run: |
  51. source ~/emsdk/emsdk_env.sh
  52. mkdir build
  53. cd build
  54. # TODO: Re-add -DWERROR=ON when warnings will be fixed
  55. emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWARNINGS=ON ..
  56. - name: Sync data folder
  57. working-directory: build
  58. run: |
  59. rsync -aP ../data/ data/
  60. - name: Build
  61. working-directory: build
  62. run: |
  63. source ~/emsdk/emsdk_env.sh
  64. emmake make -j$(nproc)
  65. # Now you can run a local server with: `emrun supertux2.html`
  66. # Or any traditional web server will do the job
  67. # Note: opening the html file manually (file:///) won't work
  68. - name: Setup files for upload
  69. working-directory: build
  70. env:
  71. BUILD_TYPE: ${{ matrix.build_type }}
  72. run: |
  73. cp template.html supertux2.html
  74. mkdir upload/
  75. mv supertux2* upload/
  76. - uses: actions/upload-artifact@v2
  77. with:
  78. name: "wasm32-emscripten-${{ matrix.build_type }}-html"
  79. path: build/upload/*
  80. if-no-files-found: ignore
  81. - name: Upload to server
  82. if: ${{ github.ref == 'refs/heads/master' && matrix.build_type == 'Release' }}
  83. env:
  84. UPLOAD_URL: ${{ secrets.UPLOAD_URL }}
  85. run: |
  86. cd build/upload/
  87. mv supertux2.html index.html
  88. zip supertux2.zip *
  89. # TODO: Decomment (or replace URL with a different host)
  90. # curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL