Skip to content
Draft
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
54 changes: 54 additions & 0 deletions .github/workflows/make-storyquest-kit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
name: "Make StoryQuest Kit"
on:
workflow_dispatch:
pull_request:
paths:
- 'tools/sqckck.*'
- '.github/workflows/make-storyquest-kit.yml'
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

env:
GODOT_VERSION: "4.7.1"

jobs:
make-storyquest-kit:
name: Make StoryQuest Kit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
# Fetch full history of commits and tags so that git describe --tags works
fetch-depth: 0

- uses: ./.github/actions/lfs-cached-checkout

- name: Install Godot
uses: endlessm/godot-export-action/install-godot@wjt/split-setup-steps
with:
godot_version: ${{ env.GODOT_VERSION }}

# TODO: .godot cache restore not save

- name: Make StoryQuest Kit
id: sqckck
run: ./tools/sqckck.sh
env:
GODOT: build/godot
GIT_AUTHOR_NAME: Threadbare StoryQuest Kit Maker
GIT_COMMITTER_NAME: Threadbare StoryQuest Kit Maker
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com

- name: Upload kit artifact
uses: actions/upload-artifact@v7
with:
path: ${{ steps.sqckck.outputs.zip_file }}
archive: false
11 changes: 10 additions & 1 deletion addons/storyquest_bootstrap/copier.gd
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,14 @@ func create_storyquest() -> void:
copy_tilesets()

var quest: StoryQuest = load(TEMPLATE_PATH.path_join(QUEST_FILENAME))
await copy_resource(quest)
var copied: StoryQuest = await copy_resource(quest)
EditorInterface.save_all_scenes()

var opening_quest := ThreadbareProjectSettings.get_setting(
ThreadbareProjectSettings.OPENING_QUEST
)
if ResourceUID.ensure_path(opening_quest) == ResourceUID.ensure_path(quest.resource_path):
ProjectSettings.set(
ThreadbareProjectSettings.OPENING_QUEST, ResourceUID.path_to_uid(copied.resource_path)
)
ProjectSettings.save()
10 changes: 7 additions & 3 deletions addons/threadbare_git_describe/export.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ func _get_name() -> String:
return "threadbare_git_describe_exporter"


func _export_begin(
_features: PackedStringArray, _is_debug: bool, _path: String, _flags: int
) -> void:
static func set_versions() -> void:
var describe := Version.git_describe(true)
ProjectSettings.set_setting(Version.FULL_VERSION_KEY, describe)
ProjectSettings.set_setting(Version.VERSION_KEY, Version.simplify(describe))


func _export_begin(
_features: PackedStringArray, _is_debug: bool, _path: String, _flags: int
) -> void:
set_versions()
var err := ProjectSettings.save()
if err != OK:
printerr("Failed to save project settings: %s" % error_string(err))
Expand Down
50 changes: 50 additions & 0 deletions tools/sqckck.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
@tool
extends MainLoop
## StoryQuest Construction Kit Construction Kit
##
## Prunes the game's source tree to make a reduced-size bundle that can be used
## as the basis for a StoryQuest.

const GitDescribeExport = preload("res://addons/threadbare_git_describe/export.gd")

const HOME_SCENE := "res://scenes/dev/dev_archipelago.tscn"

const TEMPLATE_QUEST := "res://scenes/quests/template_quests/NO_EDIT/quest.tres"

const DELETE_PATHS := [
"res://assets/third_party/tiny-swords-non-cc0",
"res://scenes/quests/lore_quests",
"res://scenes/quests/story_quests",
"res://scenes/world_map",
]


func rm_rf(path: String) -> void:
# You can only delete empty folders, so using DirAccess.remove() means
# traversing the whole folder tree and deleting each leaf before its parent
# folder. But you can trash a non-empty folder in a single step!
var global_path := ProjectSettings.globalize_path(path)
var ret := OS.move_to_trash(global_path)
if ret != OK:
push_error("Failed to trash ", global_path, ": ", error_string(ret))


func _process(_delta: float) -> bool:
var home_scene := ResourceUID.path_to_uid(HOME_SCENE)
ProjectSettings.set_setting(ThreadbareProjectSettings.HOME_SCENE, home_scene)

var opening_quest := ResourceUID.path_to_uid(TEMPLATE_QUEST)
ProjectSettings.set_setting(ThreadbareProjectSettings.OPENING_QUEST, opening_quest)

ProjectSettings.set_setting("application/config/name", "Threadbare StoryQuest Kit")
GitDescribeExport.set_versions()

if ProjectSettings.save() != OK:
push_error("Failed to save project settings")

for path: String in DELETE_PATHS:
rm_rf(path)

return true # End the main loop
1 change: 1 addition & 0 deletions tools/sqckck.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://leeahp1ik7lj
40 changes: 40 additions & 0 deletions tools/sqckck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
set -ex
: ${GODOT:=godot}
pushd $(dirname "$(dirname "$0")")

VERSION=$(git describe --tags)

echo "::group::Importing project"
$GODOT --headless --import
echo "::endgroup::"

echo "::group::Pruning project"
$GODOT --headless --script tools/sqckck.gd
rm -r .godot
echo "::endgroup::"

echo "::group::Adding Backstitch launcher"
gh release download -R inkandswitch/backstitch-launcher --pattern 'backstitch-launcher-*.zip'
unzip backstitch-launcher-*.zip
rm backstitch-launcher-*.zip
rm .gitignore.template
git add backstitch-launcher-*
echo "::endgroup::"

echo "::group::Committing pruned project"
git switch --detach
git commit --no-verify -am "Create StoryQuest kit for $VERSION"
echo "::endgroup::"

# TODO: merge this to a special branch? Push this as a tag?

echo "::group::Creating zip file"
git archive --format=zip --prefix=threadbare-storyquest/ --output="threadbare-storyquest-$VERSION.zip" @
echo "::endgroup::"

if [[ -n "$GITHUB_OUTPUT" ]]; then
echo "zip_file=threadbare-storyquest-$VERSION.zip" >> "$GITHUB_OUTPUT"
fi