Skip to content

Build Project

Build Project #16

Workflow file for this run

###
# Copyright (c) SimChopper; Jovan Gerodetti and contributors.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
###
name: Build Project
on:
workflow_call:
inputs:
release:
type: boolean
default: false
required: false
workflow_dispatch:
inputs:
release:
type: boolean
default: true
required: false
jobs:
rust-build:
strategy:
matrix:
platform: ['linux', 'windows', 'darwin']
arch: ['x86_64', 'aarch64']
include:
- platform: linux
os: ubuntu-24.04
vendor: unknown
env: -gnu
lib: libnative.so
editor_lib: libeditor.so
- platform: windows
os: windows-2025
vendor: pc
env: '-msvc'
lib: native.dll
editor_lib: editor.dll
- platform: darwin
os: macos-14
vendor: apple
lib: libnative.dylib
editor_lib: libeditor.dylib
exclude:
- platform: linux
arch: aarch64
runs-on: ${{ matrix.os }}
env:
TARGET_TRIPLET: ${{ matrix.arch }}-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}
CARGO_BUILD: cargo build --target
RUST_BACKTRACE: full
steps:
- name: checkout
uses: actions/checkout@v4
with:
lfs: false
- name: Set up clang64
if: contains(matrix.os, 'windows')
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./native/
key: ${{ matrix.arch }}
- name: Add Build target
run: |
cd native/
rustup target add ${{ env.TARGET_TRIPLET }}
- name: Build Debug
if: ${{ !inputs.release }}
run: |
cd native/
${{ env.CARGO_BUILD}} ${{ env.TARGET_TRIPLET}}
- name: Build Release
if: inputs.release
run: |
cd native/
${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release
- name: Debug libnative Artifact
uses: actions/upload-artifact@v4
if: ${{ !inputs.release }}
with:
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-debug
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.lib }}
- name: Debug libeditor Artifact
uses: actions/upload-artifact@v4
with:
name: libeditor-${{ matrix.platform }}-${{ matrix.arch }}-debug
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.editor_lib }}
- name: Release libnative Artifacts
uses: actions/upload-artifact@v4
if: inputs.release
with:
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-release
path: native/target/${{ env.TARGET_TRIPLET }}/release/${{ matrix.lib }}
godot-export:
strategy:
matrix:
profile: ['macOS', 'Windows', 'Linux']
version: ['4.6']
include:
- profile: 'macOS'
platform: darwin
vendor: apple
os: macos-15
x86_64: true
aarch64: true
extension: '.dmg'
lib: libnative.dylib
editor_lib: "libeditor.dylib"
template_dir: '$HOME/Library/Application\ Support/Godot/export_templates'
godot_artefact: 'macOS.universal'
- profile: 'Windows'
platform: windows
env: '-msvc'
vendor: pc
os: ubuntu-24.04
x86_64: true
aarch64: true
extension: '.exe'
lib: native.dll
editor_lib: "libeditor.so"
template_dir: '$HOME/.local/share/godot/export_templates'
godot_artefact: 'linux.x86_64'
- profile: 'Linux'
platform: 'linux'
env: '-gnu'
vendor: 'unknown'
os: ubuntu-24.04
lib: libnative.so
editor_lib: "libeditor.so"
template_dir: '$HOME/.local/share/godot/export_templates'
godot_artefact: 'linux.x86_64'
x86_64: true
needs: rust-build
runs-on: ${{ matrix.os }}
env:
EXPORT_DIR: build/${{ matrix.profile }}
EXPORT_ARGS: ${{ matrix.profile }} build/${{ matrix.profile }}/SimChopper${{ matrix.extension }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
lfs: true
- uses: hustcer/setup-nu@main
with:
version: "0.107.*"
- name: setup Godot
shell: nu {0}
run: |
let bin_path = "${{ startsWith(matrix.os, 'ubuntu') && format('./Godot_v{0}-stable_linux.x86_64', matrix.version) || './Godot.app/Contents/MacOS/Godot' }}"
mkdir .godot_bin
http get "https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_${{ matrix.godot_artefact }}.zip"
| save -rf .godot_bin/godot.zip
cd .godot_bin
unzip godot.zip
chmod +x $bin_path
ln -s $bin_path "./godot"
ls -a
- name: download Godot export template
run: |
mkdir -p ${{ matrix.template_dir }}/${{ matrix.version }}.stable
cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable
curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz
unzip -j Godot_v${{ matrix.version }}-stable_export_templates.tpz
- name: download editor lib
uses: actions/download-artifact@v8
with:
name: libeditor-${{ startsWith(matrix.os, 'ubuntu') && 'linux' || matrix.platform }}-${{ startsWith(matrix.os, 'ubuntu') && 'x86_64' || 'aarch64' }}-debug
path: native/target/${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-unknown-linux-gnu' || 'aarch64-apple-darwin' }}/debug/
merge-multiple: true
- name: download x86_64 debug libs
if: ${{ matrix.x86_64 && !inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-x86_64-debug
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
merge-multiple: true
- name: download x86_64 release libs
if: ${{ matrix.x86_64 && inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-x86_64-release
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
merge-multiple: true
- name: download aarch64 debug libs
if: ${{ matrix.aarch64 && !inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-aarch64-debug
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
merge-multiple: true
- name: download aarch64 release libs
if: ${{ matrix.aarch64 && inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-aarch64-release
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
merge-multiple: true
- name: create universal libnative
if: matrix.platform == 'darwin'
shell: nu {0}
run: |
let platform_dir = "${{ matrix.vendor }}-${{ matrix.platform }}"
let release = ${{inputs.release}}
let x86_path = $"native/target/x86_64-($platform_dir)"
let x86_debug = $"($x86_path)/debug/${{ matrix.lib }}"
let x86_release = $"($x86_path)/release/${{ matrix.lib }}"
let aarch64_path = $"native/target/aarch64-($platform_dir)"
let aarch64_debug = $"($aarch64_path)/debug/${{ matrix.lib }}"
let aarch64_release = $"($aarch64_path)/release/${{ matrix.lib }}"
if !$release {
mkdir $"native/target/universal-($platform_dir)/debug/"
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
}
if $release {
mkdir $"native/target/universal-($platform_dir)/release/"
lipo -create $x86_release $aarch64_release -output $"native/target/universal-($platform_dir)/release/${{ matrix.lib }}"
}
- name: import godot project
shell: nu {0}
run: |
$env.PATH = $env.PATH | append ("./.godot_bin" | path expand)
godot --headless --verbose --import
- name: clean up libnative variants
if: matrix.platform == 'darwin'
shell: nu {0}
run: |
let platform_dir = "${{ matrix.vendor }}-${{ matrix.platform }}"
let release = ${{ inputs.release }}
let profile = if $release { "release" } else { "debug" }
rm -r $"native/target/x86_64-($platform_dir)/($profile)/"
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
- name: export-debug
shell: nu {0}
if: ${{ !inputs.release }}
run: |
$env.PATH = $env.PATH | append ("./.godot_bin" | path expand)
mkdir "${{ env.EXPORT_DIR }}"
if ("${{ matrix.os }}" | str starts-with "ubuntu") {
sudo apt update
sudo apt install xwayland-run mesa-vulkan-drivers
wlheadless-run -- godot --verbose --export-debug ${{ env.EXPORT_ARGS }}
} else {
godot --verbose --export-debug ${{ env.EXPORT_ARGS }}
}
if (ls -a "${{ env.EXPORT_DIR }}" | length) < 1 { exit 1 }
- name: export-release
shell: nu {0}
if: inputs.release
run: |
$env.PATH = $env.PATH | append ("./.godot_bin" | path expand)
mkdir "${{ env.EXPORT_DIR }}"
if ("${{ matrix.os }}" | str starts-with "ubuntu") {
sudo apt install xwayland-run mesa-vulkan-drivers
wlheadless-run -- godot --verbose --export-release ${{ env.EXPORT_ARGS }}
} else {
godot --verbose --export-release ${{ env.EXPORT_ARGS }}
}
if (ls -a "${{ env.EXPORT_DIR }}" | length) < 1 { exit 1 }
- name: describe revision
id: describe
run: echo "ref=$(git describe --tags --always)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }}
path: ${{ env.EXPORT_DIR }}