summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/webassembly.yml
blob: 7356c4f0508abc49f39371319b809204428c7d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: WebAssembly

on: 
  push:
  pull_request:
  release:
    types: [published]

jobs:
  build:
    runs-on: windows-latest
    
    env:
      VERSION: ${{ github.event.release.tag_name }}
      RELEASE_NAME: raylib-${{ github.event.release.tag_name }}_webassembly
    
    steps:
    - name: Checkout
      uses: actions/checkout@master
  
    - name: Setup emsdk
      uses: mymindstorm/setup-emsdk@v6
      with:
        version: 2.0.0
        actions-cache-folder: 'emsdk-cache'

    - name: Setup Environment
      run: | 
        mkdir build
        cd build
        mkdir ${{ env.RELEASE_NAME }}
        cd ${{ env.RELEASE_NAME }}
        mkdir include
        mkdir lib
        cd ../..
        
    - name: Setup Release Version
      run: |
        echo "::set-env name=RELEASE_NAME::raylib-${{ github.event.release.tag_name }}_webassembly"
        echo "::set-env name=VERSION_SHORT::${VERSION//.}"
      shell: bash
      if: github.event_name == 'release' && github.event.action == 'published'
   
    - name: Build Library
      run: |
        cd src
        emcc -v
        make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-master" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
        cd ..
  
    - name: Generate Artifacts
      run: |
        copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
        cd build
        7z a ./${{ env.RELEASE_NAME }}.zip ./${{ env.RELEASE_NAME }}
        dir
      shell: cmd
        
    - name: Upload Artifacts
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.RELEASE_NAME }}.zip
        path: ./build/${{ env.RELEASE_NAME }}.zip
        
    - name: Upload Artifact to Release
      uses: actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: ./build/${{ env.RELEASE_NAME }}.zip
          asset_name: ${{ env.RELEASE_NAME }}.zip
          asset_content_type: application/zip
      if: github.event_name == 'release' && github.event.action == 'published'