Deleting extra assets #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: The Threadbare Authors | |
| # SPDX-License-Identifier: MPL-2.0 | |
| name: "Build and Export Game" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| build_flatpak: | |
| description: 'Also build a Flatpak bundle' | |
| type: boolean | |
| pull_request: | |
| release: | |
| types: | |
| - published | |
| push: | |
| branches: | |
| - '*' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| env: | |
| GODOT_VERSION: 4.4.1 | |
| PCK_NAME: threadbare | |
| jobs: | |
| build: | |
| name: Build for web | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| lfs: true | |
| # TODO: can we use --filter to avoid fetching the trees & blobs for | |
| # all historical commits, while still fetching the commit history & | |
| # tags? | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Cache Godot Engine downloads | |
| id: cache-godot | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| build/godot | |
| build/._sc_ | |
| build/editor_data/export_templates/${{ env.GODOT_VERSION }}.stable | |
| key: godot-${{ env.GODOT_VERSION }} | |
| - name: Download Godot Engine from GitHub release | |
| id: download | |
| if: steps.cache-godot.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p build && cd build | |
| # Download Godot Engine itself | |
| wget --progress=dot:giga https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \ | |
| unzip Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \ | |
| mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 godot | |
| # Download export templates | |
| mkdir -p editor_data/export_templates | |
| wget --progress=dot:giga https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \ | |
| unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \ | |
| mv templates editor_data/export_templates/${GODOT_VERSION}.stable | |
| # Tell Godot Engine to run in "self-contained" mode so it looks for | |
| # templates here instead of in ~/.local/share/godot/ | |
| touch ._sc_ | |
| - name: Export web release | |
| run: | | |
| mkdir -v -p build/web && cd build | |
| # Note that the export path can be confusing; it's relative to the | |
| # Godot project path, NOT necessarily the current directory or Godot | |
| # binary location | |
| ./godot --headless --verbose --path ../ --export-release "Web" ./build/web/index.html | |
| # PCK files are the same across export presets/platforms; prep the one | |
| # just exported for web to be used separately, i.e. for Flatpak builds | |
| - name: Copy PCK file | |
| run: | | |
| cd build | |
| cp web/index.pck '${{ env.PCK_NAME }}.pck' | |
| - name: Upload web artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web | |
| path: build/web | |
| - name: Upload PCK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pck | |
| path: build/${{ env.PCK_NAME }}.pck | |
| flatpak: | |
| name: Build Flatpak | |
| needs: build | |
| if: ${{ inputs.build_flatpak || github.event_name == 'release' }} | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-24.08 | |
| options: --privileged | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| lfs: true | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| name: pck | |
| path: build | |
| - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 | |
| with: | |
| bundle: threadbare.flatpak | |
| manifest-path: org.endlessaccess.threadbare.yml | |
| cache-key: "flatpak-builder-${{ github.sha }}" | |
| - name: Create Linux metadata bundle | |
| run: | | |
| tar --create --gzip \ | |
| --file threadbare-linux-metadata.tar.gz \ | |
| --transform=s,^,threadbare-linux-metadata/, \ | |
| icon.png \ | |
| icon-256.png \ | |
| linux/launcher.desktop \ | |
| linux/metainfo.xml \ | |
| linux/releases.xml | |
| - name: Upload Linux metadata bundle | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: threadbare-linux-metadata | |
| path: threadbare-linux-metadata.tar.gz | |
| release: | |
| name: Attach to release | |
| needs: [build, flatpak] | |
| if: ${{ github.event_name == 'release' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download PCK | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: pck | |
| - name: Attach PCK | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| mv '${{ env.PCK_NAME }}.pck' '${{ env.PCK_NAME }}-${{ github.ref_name }}.pck' | |
| gh release upload '${{ github.ref_name }}' '${{ env.PCK_NAME }}-${{ github.ref_name }}.pck' --repo '${{ github.repository }}' | |
| - name: Download Flatpak bundle | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: threadbare-x86_64.flatpak | |
| - name: Attach Flatpak bundle to release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| mv threadbare.flatpak 'threadbare-${{ github.ref_name }}-x86_64.flatpak' | |
| gh release upload '${{ github.ref_name }}' 'threadbare-${{ github.ref_name }}-x86_64.flatpak' --repo '${{ github.repository }}' | |
| - name: Download web bundle | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: web | |
| path: web | |
| - name: Attach web bundle to release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| pushd web | |
| zip -r "../threadbare-${{ github.ref_name }}-web.zip" . | |
| popd | |
| gh release upload '${{ github.ref_name }}' 'threadbare-${{ github.ref_name }}-web.zip' --repo '${{ github.repository }}' | |
| - name: Download Linux metadata bundle | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: threadbare-linux-metadata | |
| - name: Attach Linux metadata bundle to release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| mv threadbare-linux-metadata.tar.gz 'threadbare-${{ github.ref_name }}-linux-metadata.tar.gz' | |
| gh release upload '${{ github.ref_name }}' 'threadbare-${{ github.ref_name }}-linux-metadata.tar.gz' --repo '${{ github.repository }}' |