|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + release: |
| 9 | + types: [ published ] |
| 10 | + |
| 11 | +env: |
| 12 | + app_name: hode |
| 13 | + build_dir: build |
| 14 | + package_dir: package |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: ${{ matrix.config.name }} | ${{ matrix.config.build_type }} |
| 19 | + runs-on: ${{ matrix.config.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + config: |
| 24 | + - { |
| 25 | + name: "Windows 64-bit", |
| 26 | + os: windows-latest, |
| 27 | + extra_options: "-A x64 -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake", |
| 28 | + platform: "win-x64", |
| 29 | + build_type: "Release" |
| 30 | + } |
| 31 | + - { |
| 32 | + name: "Linux", |
| 33 | + os: ubuntu-latest, |
| 34 | + deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev", |
| 35 | + platform: "linux-x64", |
| 36 | + build_type: "Release" |
| 37 | + } |
| 38 | + - { |
| 39 | + name: "macOS", |
| 40 | + os: macos-latest, |
| 41 | + deps_cmdline: "brew upgrade && brew install sdl2", |
| 42 | + platform: "osx-x64", |
| 43 | + build_type: "Release" |
| 44 | + } |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v2 |
| 48 | + |
| 49 | + - name: Install Dependencies |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + git submodule update --init ./3p/inih |
| 53 | + git submodule update --init ./3p/libxbr-standalone |
| 54 | + if [[ ! -z "${{ matrix.config.deps_cmdline }}" ]]; then |
| 55 | + eval ${{ matrix.config.deps_cmdline }} |
| 56 | + fi |
| 57 | + mkdir ${{ env.build_dir }} |
| 58 | +
|
| 59 | + - name: Configure |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + cmake -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} ${{ matrix.config.extra_options }} . |
| 63 | +
|
| 64 | + - name: Build |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + export MAKEFLAGS=--keep-going |
| 68 | + cmake --build ${{ env.build_dir }} --config ${{ matrix.config.build_type }} --parallel 3 |
| 69 | +
|
| 70 | + - name: Create Package |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + cd ${{ env.build_dir }} |
| 74 | + mkdir ${{ env.package_dir }} |
| 75 | + if [[ "${{ runner.os }}" == 'Windows' ]]; then |
| 76 | + cp ${{ matrix.config.build_type }}/${{ env.app_name }}.exe ${{ matrix.config.build_type }}/SDL2.dll ${{ matrix.config.build_type }}/getopt.dll ../${{ env.app_name }}.ini ${{ env.package_dir }} |
| 77 | + else |
| 78 | + cp ${{ env.app_name }} ../${{ env.app_name }}.ini ${{ env.package_dir }} |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Zip Package |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + filename=${{ env.app_name }}-${{ matrix.config.platform }} |
| 85 | + if [[ "${{ runner.os }}" == 'Windows' ]]; then |
| 86 | + 7z a $filename.zip ./${{ env.build_dir }}/${{ env.package_dir }}/* |
| 87 | + else |
| 88 | + zip --junk-paths $filename ./${{ env.build_dir }}/${{ env.package_dir }}/* |
| 89 | + fi |
| 90 | +
|
| 91 | + - name: Upload Zipped Artifact |
| 92 | + uses: actions/upload-artifact@v2 |
| 93 | + with: |
| 94 | + name: ${{ matrix.config.platform }} ${{ matrix.config.build_type }} |
| 95 | + path: ${{ env.app_name }}-${{ matrix.config.platform }}.zip |
| 96 | + |
| 97 | + - name: List Build Directory |
| 98 | + if: always() |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + git status |
| 102 | + ls -lR ${{ env.build_dir }} |
| 103 | +
|
| 104 | + upload-packages: |
| 105 | + needs: build |
| 106 | + runs-on: ubuntu-latest |
| 107 | + if: (github.event_name == 'release' && github.event.action == 'published' && startsWith(github.ref, 'refs/tags/')) |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + config: |
| 112 | + - { |
| 113 | + platform: win-x64, |
| 114 | + build_type: "Release" |
| 115 | + } |
| 116 | + - { |
| 117 | + platform: linux-x64, |
| 118 | + build_type: "Release" |
| 119 | + } |
| 120 | + - { |
| 121 | + platform: osx-x64, |
| 122 | + build_type: "Release" |
| 123 | + } |
| 124 | + steps: |
| 125 | + - name: Get release |
| 126 | + id: get_release |
| 127 | + uses: bruceadams/get-release@v1.2.0 |
| 128 | + env: |
| 129 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + |
| 131 | + - name: Download artifacts |
| 132 | + uses: actions/download-artifact@v2 |
| 133 | + with: |
| 134 | + name: ${{ matrix.config.platform }} ${{ matrix.config.build_type }} |
| 135 | + |
| 136 | + - name: Upload Release Assets |
| 137 | + uses: actions/upload-release-asset@v1 |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + with: |
| 141 | + upload_url: ${{ steps.get_release.outputs.upload_url }} |
| 142 | + asset_path: ${{ env.app_name }}-${{ matrix.config.platform }}.zip |
| 143 | + asset_name: ${{ env.app_name }}-${{ matrix.config.platform }}.zip |
| 144 | + asset_content_type: application/zip |
0 commit comments