Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset bundling #513

Merged
merged 9 commits into from
Jun 30, 2024
135 changes: 85 additions & 50 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
repository_dispatch:
types: [run_build]

env:
OPENOMF_VERSION: '0.6.6'
OPENOMF_ASSETS_URL: 'https://www.omf2097.com/pub/files/omf/omf2097-assets.zip'

jobs:

# Check code formatting correctness
Expand Down Expand Up @@ -82,47 +86,72 @@ jobs:
- name: Generate Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release/usr ..
make -j $(getconf _NPROCESSORS_ONLN)
make -j $(getconf _NPROCESSORS_ONLN) install

- name: Get short SHA
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT

- name: Restore omf2097-assets.zip
id: cache-assets
uses: actions/cache/restore@v4
with:
path: omf2097-assets.zip
key: omf2097-assets.zip

- name: Download omf 2097 assets
if: steps.cache-assets.outputs.cache-hit != 'true'
run: wget -q "${{ env.OPENOMF_ASSETS_URL }}"

- name: Cache omf2097-assets.zip
uses: actions/cache/save@v4
with:
path: omf2097-assets.zip
key: omf2097-assets.zip

- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf

- name: Generate TGZ package
run: tar cvfz ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz -C build-release/release/ .
run: tar cvfz ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz -C build-release/release/ .

- name: Upload TGZ artifact
uses: actions/upload-artifact@v4
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz
if-no-files-found: error

- name: Generate DEB package
uses: jiro4989/build-deb-action@v2
with:
package: openomf
package_root: build-release/release
maintainer: ${{ github.repository_owner }}
version: 0.6.6-${{ steps.slug.outputs.sha8 }}
version: ${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}
arch: 'amd64'
depends: 'libargtable2, libsdl2-mixer, libconfuse, libenet, libsdl2, libxmp, libpng'
depends: 'libargtable2-0, libsdl2-mixer-2.0-0, libconfuse2, libenet7, libsdl2-2.0-0, libxmp4, libpng16-16'
desc: 'One Must Fall 2097 Remake'

- name: Install the DEB package
run: sudo apt install ./openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_amd64.deb

- name: Upload DEB artifact
uses: actions/upload-artifact@v4
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_deb_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_amd64.deb
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_deb_amd64
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_amd64.deb
if-no-files-found: error

# Build macos package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
build_macos:
build_macos-arm:
needs: [unittest, formatting-check]

name: Build macos-12
runs-on: macos-12
name: Build macos-14
runs-on: macos-14

steps:
- uses: actions/checkout@v4
Expand All @@ -135,45 +164,29 @@ jobs:
- name: Generate Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release/usr ..
make -j $(getconf _NPROCESSORS_ONLN)
make -j $(getconf _NPROCESSORS_ONLN) install

- name: Get short SHA
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT

- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip .

- name: Upload artifacts
uses: actions/upload-artifact@v4
- name: Restore omf2097-assets.zip
id: cache-assets
uses: actions/cache/restore@v4
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip
path: omf2097-assets.zip
key: omf2097-assets.zip

build_macos-arm:
needs: [unittest, formatting-check]
- name: Download omf 2097 assets
if: steps.cache-assets.outputs.cache-hit != 'true'
run: wget -q "${{ env.OPENOMF_ASSETS_URL }}"

name: Build macos-14
runs-on: macos-14

steps:
- uses: actions/checkout@v4

- name: Install Mac Dependencies
run: |
brew update
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng
- name: Cache omf2097-assets.zip
uses: actions/cache/save@v4
with:
path: omf2097-assets.zip
key: omf2097-assets.zip

- name: Generate Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release ..
make -j $(getconf _NPROCESSORS_ONLN)
make -j $(getconf _NPROCESSORS_ONLN) install
- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf

- name: Get short SHA
id: slug
Expand All @@ -182,13 +195,14 @@ jobs:
- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip .
zip -r ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip .

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos14_arm
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip
if-no-files-found: error

# Build windows package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -227,22 +241,43 @@ jobs:
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT

- name: Restore omf2097-assets.zip
id: cache-assets
uses: actions/cache/restore@v4
with:
path: omf2097-assets.zip
key: omf2097-assets.zip

- name: Download omf 2097 assets
if: steps.cache-assets.outputs.cache-hit != 'true'
run: wget -q "${{ env.OPENOMF_ASSETS_URL }}"

- name: Cache omf2097-assets.zip
uses: actions/cache/save@v4
with:
path: omf2097-assets.zip
key: omf2097-assets.zip

- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-release/release/openomf/resources

- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip openomf
zip -r ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip openomf

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_amd64
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip
if-no-files-found: error


# Create a "latest" release
# -----------------------------------------------------------------------------------------------
make_release:
needs: [build_windows, build_macos, build_macos-arm, build_ubuntu]
needs: [build_windows, build_macos-arm, build_ubuntu]
if: github.ref == 'refs/heads/master'

name: Make "latest" release
Expand Down
Loading