name: Build libsm64 on: push: branches: - "**" pull_request: jobs: Build: name: Build libsm64 for ${{ matrix.identifier }} strategy: fail-fast: false matrix: include: - identifier: linux os: ubuntu-latest - identifier: windows os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - name: Checkout project uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.10" - name: (Windows) Install MinGW if: matrix.identifier == 'windows' run: | sudo apt-get update -y -qq sudo apt-get install -y mingw-w64 sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - name: (Windows) Prepare cross compilation if: ${{ startsWith(matrix.identifier, 'windows') }} shell: sh run: | echo "OS=Windows_NT" >> $GITHUB_ENV - name: (Linux) Install dependencies if: matrix.identifier == 'linux' run: | sudo apt-get update -y -qq sudo apt-get install -y libsdl2-dev libglew-dev - name: Build shared library shell: bash run: | if [[ "${{ matrix.identifier }}" == "windows" ]]; then make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) \ CC=x86_64-w64-mingw32-gcc \ CXX=x86_64-w64-mingw32-g++ else make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) fi - name: Build test executable (Linux only) if: matrix.identifier == 'linux' run: make test -j$(nproc) - name: Prepare artifacts run: | mkdir -p artifacts/${{ matrix.identifier }} cp -r dist artifacts/${{ matrix.identifier }}/ cp README.md artifacts/${{ matrix.identifier }}/ - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: libsm64_${{ matrix.identifier }} path: artifacts/${{ matrix.identifier }} Release: name: Snapshot Release runs-on: ubuntu-latest needs: Build if: github.ref_type == 'branch' steps: - name: Get short SHA id: vars shell: bash run: | SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7) echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT - name: Download artifacts uses: actions/download-artifact@v3 with: path: artifacts - name: Create zip files run: | mkdir -p release_files cd artifacts/libsm64_linux zip -r ../../release_files/libsm64_linux.zip . cd ../libsm64_windows zip -r ../../release_files/libsm64_windows.zip . - name: Create Release uses: akkuman/gitea-release-action@v1 with: token: ${{ secrets.GITEA_TOKEN }} repository: NepuShiro/libsm64 tag_name: build-${{ steps.vars.outputs.short_sha }} name: Snapshot Build ${{ steps.vars.outputs.short_sha }} prerelease: true files: | release_files/libsm64_linux.zip release_files/libsm64_windows.zip