|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + name: Linux Native Release |
| 13 | + |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + shell: bash |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + submodules: recursive |
| 24 | + |
| 25 | + - name: Set reusable strings |
| 26 | + run: | |
| 27 | + preset_name=linux-release |
| 28 | + workspace_dir=${{ github.workspace }} |
| 29 | + source_dir=${workspace_dir} |
| 30 | + build_dir=${workspace_dir}/build/$preset_name |
| 31 | + install_dir=$build_dir/install |
| 32 | + echo "source_dir=$source_dir" >> "$GITHUB_ENV" |
| 33 | + echo "build_dir=$build_dir" >> "$GITHUB_ENV" |
| 34 | + echo "install_dir=$install_dir" >> "$GITHUB_ENV" |
| 35 | + echo "preset_name=$preset_name" >> "$GITHUB_ENV" |
| 36 | +
|
| 37 | + - name: Install packages |
| 38 | + run: | |
| 39 | + sudo apt update |
| 40 | + sudo apt install libelf-dev ninja-build -y |
| 41 | +
|
| 42 | + - name: Git fetch tags |
| 43 | + run: git fetch origin --tags |
| 44 | + |
| 45 | + # Build |
| 46 | + |
| 47 | + - name: CMake configure build |
| 48 | + working-directory: ${{ env.source_dir }} |
| 49 | + run: > |
| 50 | + cmake |
| 51 | + --preset ${{ env.preset_name }} |
| 52 | + -DCMAKE_INSTALL_PREFIX=${{ env.install_dir }} |
| 53 | +
|
| 54 | + - name: CMake build |
| 55 | + working-directory: ${{ env.source_dir }} |
| 56 | + run: cmake --build --preset ${{ env.preset_name }} --parallel --verbose |
| 57 | + |
| 58 | + - name: Install executable |
| 59 | + run: cmake --install ${{ env.build_dir }} |
| 60 | + |
| 61 | + # Artifacts |
| 62 | + |
| 63 | + - name: Upload libraries |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: gamedata-gen |
| 67 | + path: ${{ env.install_dir }}/bin/gamedata-gen |
| 68 | + |
| 69 | + # upload-latest-build: |
| 70 | + # name: Upload Latest Build |
| 71 | + # |
| 72 | + # needs: [build, pack-resources] |
| 73 | + # runs-on: ubuntu-latest |
| 74 | + # if: github.ref == 'refs/heads/master' |
| 75 | + # permissions: |
| 76 | + # contents: write |
| 77 | + # |
| 78 | + # steps: |
| 79 | + # - name: Download all artifacts |
| 80 | + # uses: actions/download-artifact@v4 |
| 81 | + # |
| 82 | + # - name: Packing artifacts |
| 83 | + # run: 'parallel 7z a -tzip -mx=9 "{}.zip" "./{}/*" ::: *' |
| 84 | + # |
| 85 | + # - name: Create & upload latest build |
| 86 | + # env: |
| 87 | + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + # REPO_INFO: ${{ github.repository }} |
| 89 | + # run: | |
| 90 | + # # Delete old "latest" (delete step always returns true so that even if there's no release, it still uploads) |
| 91 | + # gh release delete latest --cleanup-tag --yes --repo "$REPO_INFO" || true |
| 92 | + # # Create new "latest" |
| 93 | + # gh release create latest *.zip --prerelease --title "Latest Master Build" --repo "$REPO_INFO" |
| 94 | + # |
| 95 | + # upload-release: |
| 96 | + # name: Upload Release |
| 97 | + # |
| 98 | + # needs: [build, pack-resources] |
| 99 | + # runs-on: ubuntu-latest |
| 100 | + # if: github.event_name == 'release' && github.event.action == 'published' |
| 101 | + # permissions: |
| 102 | + # contents: write |
| 103 | + # |
| 104 | + # steps: |
| 105 | + # - name: Download all artifacts |
| 106 | + # uses: actions/download-artifact@v4 |
| 107 | + # |
| 108 | + # # TODO remove? |
| 109 | + # - name: Deleting every debug artifact |
| 110 | + # run: 'rm -r *-Debug' |
| 111 | + # |
| 112 | + # - name: Packing artifacts |
| 113 | + # run: 'parallel 7z a -tzip -mx=9 "{= s/neo-(.*)/neo-$GITHUB_REF_NAME-\1.zip/ =}" "./{}/*" ::: *' # TODO fix this command |
| 114 | + # |
| 115 | + # - name: Upload assets to a release |
| 116 | + # env: |
| 117 | + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + # REPO_INFO: ${{ github.repository }} |
| 119 | + # run: 'gh release upload "$GITHUB_REF_NAME" *.zip --clobber --repo "$REPO_INFO"' |
0 commit comments