Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: package-release

# Builds editor RelWithDebInfo
# Attaches the Windows installer and the Linux tarball to a release

on:
workflow_call:
inputs:
tag:
description: Release tag, e.g. 2.8.0
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: Release tag, e.g. 2.8.0
required: true
type: string

permissions:
contents: write

env:
GH_TOKEN: ${{ github.token }}

jobs:
windows:
name: windows installer
runs-on: [self-hosted, windows]
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.tag }}
fetch-depth: 1
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1

- name: Setup vcpkg
id: vcpkg
uses: ./.github/actions/setup-vcpkg

- name: Build editor
run: |
cmake -B build/package `
-G Ninja `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_C_COMPILER=cl `
-DCMAKE_CXX_COMPILER=cl `
-DCMAKE_TOOLCHAIN_FILE="${{ steps.vcpkg.outputs.toolchain-file }}" `
-DVCPKG_TARGET_TRIPLET=x64-windows
cmake --build build/package --target editor

- name: Stage out/RelWithDebInfo
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$stage = Join-Path $env:RUNNER_TEMP 'toast-stage'
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory $stage | Out-Null
Copy-Item -Recurse -Force 'out/RelWithDebInfo/*' $stage
foreach ($name in Get-Content tools/installer/exclude.txt) {
if ($name.Trim()) { Remove-Item -Recurse -Force (Join-Path $stage $name.Trim()) -ErrorAction SilentlyContinue }
}
Set-Content -NoNewline -Path (Join-Path $stage 'version.txt') -Value '${{ inputs.tag }}'
"STAGE=$stage" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV

- name: Install Inno Setup
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$dir = Join-Path $env:RUNNER_TOOL_CACHE 'InnoSetup'
if (-not (Test-Path (Join-Path $dir 'ISCC.exe'))) {
$setup = Join-Path $env:RUNNER_TEMP 'innosetup.exe'
Invoke-WebRequest -Uri 'https://jrsoftware.org/download.php/is.exe' -OutFile $setup
Start-Process -Wait -FilePath $setup -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/CURRENTUSER', "/DIR=$dir"
}
"ISCC=$(Join-Path $dir 'ISCC.exe')" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV

- name: Build installer
shell: pwsh
run: |
& $env:ISCC "/DAppVersion=${{ inputs.tag }}" "/DSourceDir=$env:STAGE" "/O$env:RUNNER_TEMP" tools/installer/toast-engine.iss
if ($LASTEXITCODE -ne 0) { throw "iscc failed" }

- name: Upload to release
shell: pwsh
run: gh release upload "${{ inputs.tag }}" "$env:RUNNER_TEMP/ToastEngine-${{ inputs.tag }}-setup.exe" --clobber --repo "${{ github.repository }}"

linux:
name: linux tarball
runs-on: [self-hosted, Linux, X64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6

- name: Build editor
run: nix develop --command bash -c "
rustup toolchain install stable --no-self-update &&
rustup default stable &&
cmake -B build/package -G Ninja
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DTOAST_X86_MARCH=x86-64
-DCMAKE_TOOLCHAIN_FILE=\$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache &&
cmake --build build/package --parallel \$(nproc) --target editor
"

- name: Package
shell: bash
run: |
set -euo pipefail
name="toast-engine-${{ inputs.tag }}-linux-x64"
stage="${RUNNER_TEMP}/${name}"
rm -rf "${stage}"
mkdir -p "${stage}"
cp -r out/RelWithDebInfo/. "${stage}/"
while read -r entry; do
[[ -n "${entry}" ]] && rm -rf "${stage:?}/${entry}"
done < tools/installer/exclude.txt
printf '%s' "${{ inputs.tag }}" > "${stage}/version.txt"
cp tools/installer/linux/install.sh "${stage}/install.sh"
chmod +x "${stage}/install.sh"
tar -C "${RUNNER_TEMP}" -czf "${RUNNER_TEMP}/${name}.tar.gz" "${name}"
echo "TARBALL=${RUNNER_TEMP}/${name}.tar.gz" >> "${GITHUB_ENV}"

- name: Upload to release
run: gh release upload "${{ inputs.tag }}" "${TARBALL}" --clobber --repo "${{ github.repository }}"
29 changes: 28 additions & 1 deletion .github/workflows/release-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
release:
name: tag and release
runs-on: [self-hosted, Linux, X64]
outputs:
new_tag: ${{ steps.version.outputs.new_tag }}
create_release: ${{ steps.version.outputs.create_release }}
if: github.event.pull_request.merged == true && github.event.pull_request.base.repo.fork == false && github.event.pull_request.base.repo.full_name == github.repository
steps:
- name: Checkout repository
Expand Down Expand Up @@ -83,9 +86,33 @@ jobs:
repo: context.repo.repo,
tag_name: tag,
name: `Toast Engine v${tag}`,
body: ""
body: "",
// Published once the installers are attached, editors only follow the latest published release
draft: true
});

package:
name: package installers
needs: release
if: needs.release.outputs.create_release == 'true'
permissions:
contents: write
uses: ./.github/workflows/package-release.yml
with:
tag: ${{ needs.release.outputs.new_tag }}

publish:
name: publish release
needs: [release, package]
runs-on: [self-hosted, Linux, X64]
permissions:
contents: write
steps:
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit "${{ needs.release.outputs.new_tag }}" --repo "${{ github.repository }}" --draft=false --latest

deploy-docs:
name: Deploy Doxygen docs
needs: release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ logs/
**[Oo]bj**
**[Tt]arget**
!**/CrashTarget.cs
!**/BuildInfo.cs
[Oo]ut
engine/include/
vcpkg_installed/
Expand Down
21 changes: 17 additions & 4 deletions editor/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using System.IO;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
Expand All @@ -24,10 +27,20 @@ public override void OnFrameworkInitializationCompleted() {
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
desktop.ShutdownMode = ShutdownMode.OnMainWindowClose;

desktop.MainWindow = new StartWindow.StartWindow {
DataContext = new StartWindowViewModel()
};
desktop.MainWindow.Show();
var vm = new StartWindowViewModel();

// Opened by double clicking a .toast file
var projectArg = desktop.Args?.FirstOrDefault(a =>
a.EndsWith(".toast", StringComparison.OrdinalIgnoreCase) && File.Exists(a));

if (projectArg != null) {
vm.LaunchProject(Path.GetFullPath(projectArg), null);
} else {
desktop.MainWindow = new StartWindow.StartWindow {
DataContext = vm
};
desktop.MainWindow.Show();
}
}

base.OnFrameworkInitializationCompleted();
Expand Down
4 changes: 4 additions & 0 deletions editor/Components/Modals/LoadingPopup.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ public LoadingPopup(string text) {
InitializeComponent();
Message.Text = text;
}

public void SetText(string text) {
Message.Text = text;
}
}
34 changes: 34 additions & 0 deletions editor/Install/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// BuildInfo.cs
// Where this editor is installed and which release it came from
//

using System;
using System.IO;

namespace editor.Install;

public static class BuildInfo {
public static string InstallRoot { get; } =
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, ".."));

public static string ToastPath { get; } =
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "toast_engine"));

public static string EditorExe => Environment.ProcessPath ?? Path.Combine(AppContext.BaseDirectory, "editor");

public static Version? Version { get; } = ReadVersion();

public static string UpdateRepo =>
Environment.GetEnvironmentVariable("TOAST_UPDATE_REPO") is { Length: > 0 } r ? r : "nullptr-studios/toast-engine";

private static Version? ReadVersion() {
try {
var file = Path.Combine(InstallRoot, "version.txt");
if (!File.Exists(file)) return null;
return System.Version.TryParse(File.ReadAllText(file).Trim().TrimStart('v'), out var v) ? v : null;
} catch {
return null;
}
}
}
Loading
Loading