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. workflow_dispatch:
  20. push:
  21. branches:
  22. - master
  23. tags:
  24. - '*'
  25. pull_request: {}
  26. jobs:
  27. wasm:
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. build_type: ["Release", "Debug"]
  32. runs-on: ubuntu-latest
  33. steps:
  34. - uses: actions/checkout@v4
  35. with:
  36. # Fetch the whole tree so git describe works
  37. fetch-depth: 0
  38. submodules: true
  39. - name: Install emscripten tools
  40. run: |
  41. cd ~
  42. sudo apt-get update
  43. sudo apt-get install -y git cmake build-essential curl zip
  44. git clone https://github.com/emscripten-core/emsdk.git
  45. cd emsdk
  46. ./emsdk install latest
  47. ./emsdk activate latest
  48. - name: Configure build
  49. env:
  50. BUILD_TYPE: ${{ matrix.build_type }}
  51. run: |
  52. source ~/emsdk/emsdk_env.sh
  53. mkdir build
  54. cd build
  55. # TODO: Re-add -DWERROR=ON when warnings will be fixed
  56. emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWARNINGS=ON ..
  57. - name: Sync data folder
  58. working-directory: build
  59. run: |
  60. rsync -aP ../data/ data/
  61. - name: Build
  62. working-directory: build
  63. run: |
  64. source ~/emsdk/emsdk_env.sh
  65. emmake make -j$(nproc)
  66. # Now you can run a local server with: `emrun supertux2.html`
  67. # Or any traditional web server will do the job
  68. # Note: opening the html file manually (file:///) won't work
  69. - name: Setup files for upload
  70. working-directory: build
  71. env:
  72. BUILD_TYPE: ${{ matrix.build_type }}
  73. run: |
  74. cp template.html supertux2.html
  75. mkdir upload/
  76. mv supertux2* upload/
  77. - uses: actions/upload-artifact@v4
  78. with:
  79. name: "wasm32-emscripten-${{ matrix.build_type }}-html"
  80. path: build/upload/*
  81. if-no-files-found: ignore
  82. - name: Upload to server
  83. if: ${{ github.ref == 'refs/heads/master' && matrix.build_type == 'Release' }}
  84. env:
  85. UPLOAD_URL: ${{ secrets.UPLOAD_URL }}
  86. run: |
  87. cd build/upload/
  88. mv supertux2.html index.html
  89. zip supertux2.zip *
  90. curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL