generated from MechanicalFlower/godot-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
143 lines (111 loc) · 3.98 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env -S just --justfile
set dotenv-load := true
export PIP_REQUIRE_VIRTUALENV := "true"
# === Aliases ===
[private]
alias g := godot
[private]
alias e := editor
# === Variables ===
# Global directories
# To make the Godot binaries available for other projects
home_dir := env_var('HOME')
main_dir := home_dir / ".mkflower"
cache_dir := main_dir / "cache"
bin_dir := main_dir / "bin"
# Godot variables
godot_version := env_var('GODOT_VERSION')
godot_platform := if arch() == "x86" { "linux.x86_32" } else { if arch() == "x86_64" { "linux.x86_64" } else { "" } }
godot_filename := "Godot_v" + godot_version + "-stable_" + godot_platform
godot_bin := bin_dir / godot_filename
# Addon variables
addon_name := env_var('ADDON_NAME')
addon_version := env_var('ADDON_VERSION')
# Python virtualenv
venv_dir := justfile_directory() / "venv"
# === Commands ===
# Display all commands
@default:
echo "OS: {{ os() }} - ARCH: {{ arch() }}\n"
just --list
# Create directories
[private]
@makedirs:
mkdir -p {{ cache_dir }} {{ bin_dir }}
# Python virtualenv wrapper
[private]
@venv *ARGS:
[ ! -d {{ venv_dir }} ] && python3 -m venv {{ venv_dir }} || true
. {{ venv_dir }}/bin/activate && {{ ARGS }}
# Download Godot
[private]
install-godot:
#!/usr/bin/env sh
if [ ! -e {{ godot_bin }} ]
then
curl -X GET "https://downloads.tuxfamily.org/godotengine/{{ godot_version }}/{{ godot_filename }}.zip" --output {{ cache_dir }}/{{ godot_filename }}.zip
unzip {{ cache_dir }}/{{ godot_filename }}.zip -d {{ cache_dir }}
cp {{ cache_dir }}/{{ godot_filename }} {{ godot_bin }}
fi
# Download plugins
install-addons:
[ -f plug.gd ] && just godot --headless --script plug.gd install || true
# Workaround from https://github.com/godotengine/godot/pull/68461
# Import game resources
import-resources:
just godot --headless --export-pack null /dev/null
# timeout 60 just godot --editor || true
# just godot --headless --quit --editor
# Updates the addon version
@bump-version:
# echo "Update version in the plugin.cfg"
# sed -i "s,version=.*$,version=\"{{ addon_version }}\",g" ./addons/{{ addon_name }}/plugin.cfg
# Godot binary wrapper
@godot *ARGS: makedirs install-godot
{{ godot_bin }} {{ ARGS }}
# Open the Godot editor
editor:
just godot --editor
# Run files formatters
fmt:
just venv pip install pre-commit==3.3.3 reuse==2.1.0 gdtoolkit==4.*
just venv pre-commit run -a
# Remove cache and binaries created by this Justfile
[private]
clean-mkflower:
rm -rf {{ main_dir }}
rm -rf {{ venv_dir }}
# Remove plugins
clean-addons:
rm -rf .plugged
[ -f plug.gd ] && find addons/ -type d -not -name 'addons' -not -name 'gd-plug' -not -name '{{ addon_name }}' -exec rm -rf {} \; || true
# Remove any unnecessary files
clean: clean-addons
# Add some variables to Github env
ci-load-dotenv:
echo "godot_version={{ godot_version }}" >> $GITHUB_ENV
echo "addon_name={{ addon_name }}" >> $GITHUB_ENV
echo "addon_version={{ addon_version }}" >> $GITHUB_ENV
# Upload the addon on Github
publish:
gh release create "{{ addon_version }}" --title="v{{ addon_version }}" --generate-notes
# TODO: Add a asset-lib publish step
# Run unit tests
test: install-addons import-resources
just godot --headless --script addons/gut/gut_cmdln.gd -gconfig=.gutconfig.json
# Install MkDocs & MkDocs plugins
[private]
install-mkdocs-dependencies:
just venv pip install mkdocs==1.5.3 mkdocs-literate-nav==0.6.1
doc-cli *ARGS: install-godot
just godot --editor --headless --quit --script addons/godot-autogen-docs/cli.gd {{ ARGS }}
# Deploy your documentation to GitHub Pages
doc-deploy: install-mkdocs-dependencies
just venv mkdocs gh-deploy --force
# Generate documentation
doc-gen: install-mkdocs-dependencies
just cli-doc readthedocs -ddir=res://addons/godot-autogen-docs -doutdir=res://docs/dev-guide/api-ref/
just venv mkdocs build
# Start serving the documentation
doc-serve: install-mkdocs-dependencies
just venv mkdocs serve