Emscripten build #287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Emscripten build | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: # Nightly build | |
| - cron: "0 0 * * *" | |
| jobs: | |
| emscripten_build: | |
| name: Emscripten build | |
| # We are deliberately sticking back to Ubuntu 22.04 because the | |
| # version of Emscripten from 24.04 (3.1.6) doesn't build properly; | |
| # the more recent version from Debian testing does work, so when | |
| # Ubuntu catches up with that we can switch back to ubuntu-latest. | |
| runs-on: ubuntu-22.04 | |
| concurrency: | |
| group: emscripten-build | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Emscripten | |
| run: | | |
| sudo apt update | |
| sudo apt -q install emscripten pandoc | |
| - name: Find Git version | |
| id: version | |
| run: | | |
| if git describe --exact-match --tags >/dev/null; then | |
| VERSION=$(git describe --exact-match --tags) | |
| VERSION=${VERSION/#sdl-sopwith-/} | |
| else | |
| VERSION=git-$(git rev-parse --short HEAD) | |
| fi | |
| echo "VERSION=$VERSION-js" >> $GITHUB_OUTPUT | |
| # Patch the version in configure.ac: | |
| sed -i "s/\(AC_INIT([^,]*, \)\[[^]]*\], /\1[$VERSION], /" \ | |
| configure.ac | |
| - name: build | |
| run: ./embuild.sh | |
| - name: make pkg | |
| run: | | |
| make -C pkg/emscripten | |
| - name: Upload build | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: "pkg/emscripten/page" | |
| name: sdl-sopwith-${{steps.version.outputs.VERSION}} | |
| - name: Identify deploy folder | |
| id: deploy_folder | |
| run: | | |
| case ${{ github.ref }} in | |
| refs/heads/*) | |
| echo "${{github.ref}}" | \ | |
| sed "s/refs.heads./DEPLOY_FOLDER=branch\//; s/.merge//" | |
| ;; | |
| refs/pull/*/merge) | |
| sed "s/refs.pull./DEPLOY_FOLDER=prs\//; s/.merge//" | |
| pr=$(echo "${{github.ref}}" | sed "s/refs.pull.//; s/.merge//") | |
| echo "DEPLOY_FOLDER=/prs/$pr" | |
| echo "PR_NUMBER=$pr" | |
| ;; | |
| refs/tags/*) | |
| echo "${{github.ref}}" | sed "s/refs.tags./DEPLOY_FOLDER=tags\//" | |
| ;; | |
| *) | |
| ;; | |
| esac | tee "$GITHUB_OUTPUT" | |
| - name: Deploy | |
| if: ${{steps.deploy_folder.outputs.DEPLOY_FOLDER != ''}} | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| folder: "pkg/emscripten/page" | |
| repository-name: "fragglet/sdl-sopwith-builds" | |
| ssh-key: "${{ secrets.SDL_SOPWITH_BUILDS_KEY }}" | |
| target-folder: "${{steps.deploy_folder.outputs.DEPLOY_FOLDER}}" | |
| clean: true | |
| commit-message: "Build from fragglet/sdl-sopwith@${{github.sha}} (Version ${{steps.version.outputs.VERSION}})" | |
| - name: Comment PR | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| message: | | |
| Thanks for your pull request! A build of your change can be found [here](https://fragglet.github.io/sdl-sopwith-builds${{steps.deploy_folder.outputs.DEPLOY_FOLDER}}/sopwith.html) for people to try. | |
| pr_number: ${{steps.deploy_folder.outputs.PR_NUMBER}} |