@victorrl/semantic-release-godot 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +12 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +232 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +24 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +59 -0
- package/dist/options.js.map +1 -0
- package/docs/index.md +13 -0
- package/examples/README.md +7 -0
- package/examples/semantic-release.config.js +30 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# `@victorrl/semantic-release-godot`
|
|
2
|
+
|
|
3
|
+
`semantic-release` plugin to automate version and build number injection for Godot 4 projects, specifically targeting Android and global game configurations.
|
|
4
|
+
|
|
5
|
+
The plugin runs during the semantic-release `prepare` lifecycle, ensuring that version numbers are baked into project files before your build/export stage and before the release is tagged in Git.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## How It Works
|
|
10
|
+
|
|
11
|
+
This plugin automates three common versioning techniques in Godot 4:
|
|
12
|
+
|
|
13
|
+
### 1. Android Preset Options (`export_presets.cfg`)
|
|
14
|
+
Bakes the user-facing version name and unique build code into the Android preset options before you trigger `godot --export-release`.
|
|
15
|
+
- **`version/name`**: Set to the next release version (e.g., `"1.0.1"`).
|
|
16
|
+
- **`version/code`**: Set to a strictly increasing integer. By default, it computes the **total git commit count** (`git rev-list --count HEAD`) to use as the build number. You can also specify an offset or override this manually.
|
|
17
|
+
|
|
18
|
+
### 2. Custom Global Config (Approach A - `project.godot`)
|
|
19
|
+
By default, this is enabled and writes/updates the game version inside `project.godot` (default key is `config/version` under `[application]`).
|
|
20
|
+
You can read this at runtime in GDScript:
|
|
21
|
+
```gdscript
|
|
22
|
+
var game_version = ProjectSettings.get_setting("application/config/version")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 3. Autoload Script Constant (Approach B - GDScript)
|
|
26
|
+
Optionally updates a specific version constant (default name `GAME_VERSION`) in an Autoload script (e.g. `res://scripts/Version.gd`):
|
|
27
|
+
```gdscript
|
|
28
|
+
extends Node
|
|
29
|
+
const GAME_VERSION = "1.0.1"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install --save-dev @victorrl/semantic-release-godot
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Configure the plugin in your `release.config.js` or `.releaserc`:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
export default {
|
|
46
|
+
plugins: [
|
|
47
|
+
"@semantic-release/commit-analyzer",
|
|
48
|
+
"@semantic-release/release-notes-generator",
|
|
49
|
+
[
|
|
50
|
+
"@victorrl/semantic-release-godot",
|
|
51
|
+
{
|
|
52
|
+
// By default, Approach A is enabled, Approach B is disabled
|
|
53
|
+
enableApproachA: true,
|
|
54
|
+
enableApproachB: true,
|
|
55
|
+
gdScriptPath: "res://scripts/Version.gd"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"@semantic-release/github"
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Configuration Options
|
|
66
|
+
|
|
67
|
+
| Option | Env Fallback | Default | Description |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| `exportPresetsPath` | `GODOT_EXPORT_PRESETS_PATH` | `export_presets.cfg` | Path to your Godot export configuration file. |
|
|
70
|
+
| `projectGodotPath` | `GODOT_PROJECT_GODOT_PATH` | `project.godot` | Path to your `project.godot` file. |
|
|
71
|
+
| `enableApproachA` | `GODOT_ENABLE_APPROACH_A` | `true` | Update the version inside `project.godot`. |
|
|
72
|
+
| `projectVersionKey` | `GODOT_PROJECT_VERSION_KEY` | `config/version` | The key under `[application]` to write the version to in `project.godot`. |
|
|
73
|
+
| `enableApproachB` | `GODOT_ENABLE_APPROACH_B` | `false` | Update a version constant inside a GDScript file. |
|
|
74
|
+
| `gdScriptPath` | `GODOT_GDSCRIPT_PATH` | `null` | Path to the GDScript file (supports `res://` prefix). Required if `enableApproachB` is `true`. |
|
|
75
|
+
| `gdScriptVersionConstant` | `GODOT_GDSCRIPT_VERSION_CONSTANT` | `GAME_VERSION` | The variable/constant name in the GDScript to update. |
|
|
76
|
+
| `versionCode` | `GODOT_VERSION_CODE` | `null` | Manual version code value. If not specified, git commit count is used. |
|
|
77
|
+
| `versionCodeOffset` | `GODOT_VERSION_CODE_OFFSET` | `0` | Offset added to the computed git commit count version code. |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class GodotPluginError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly details?: string | undefined;
|
|
4
|
+
readonly name = "SemanticReleaseError";
|
|
5
|
+
readonly semanticRelease = true;
|
|
6
|
+
constructor(code: string, message: string, details?: string | undefined);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;aAKzB,IAAI,EAAE,MAAM;aAEZ,OAAO,CAAC,EAAE,MAAM;IANjC,SAAyB,IAAI,0BAA0B;IACvD,SAAgB,eAAe,QAAQ;gBAGtB,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,MAAM,YAAA;CAIjC"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class GodotPluginError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
name = "SemanticReleaseError";
|
|
5
|
+
semanticRelease = true;
|
|
6
|
+
constructor(code, message, details) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.details = details;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAKzB;IAEA;IANQ,IAAI,GAAG,sBAAsB,CAAC;IACvC,eAAe,GAAG,IAAI,CAAC;IAEvC,YACiB,IAAY,EAC5B,OAAe,EACC,OAAgB;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAQ;QAEZ,YAAO,GAAP,OAAO,CAAS;IAGjC,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PrepareContext, VerifyConditionsContext } from "semantic-release";
|
|
2
|
+
import { type GodotPluginOptions } from "./options.js";
|
|
3
|
+
export type { GodotPluginOptions };
|
|
4
|
+
interface Line {
|
|
5
|
+
type: "empty" | "comment" | "keyvalue" | "unknown";
|
|
6
|
+
key?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
raw: string;
|
|
9
|
+
}
|
|
10
|
+
interface Section {
|
|
11
|
+
name: string;
|
|
12
|
+
lines: Line[];
|
|
13
|
+
}
|
|
14
|
+
export declare function parseGodotConfig(content: string): Section[];
|
|
15
|
+
export declare function stringifyGodotConfig(sections: Section[]): string;
|
|
16
|
+
export declare function updateExportPresets(content: string, versionName: string, versionCode: number): string;
|
|
17
|
+
export declare function updateProjectGodot(content: string, versionName: string, versionKey?: string): string;
|
|
18
|
+
export declare function updateGDScript(content: string, versionName: string, constantName?: string): string;
|
|
19
|
+
export declare function verifyConditions(pluginConfig: GodotPluginOptions, context: VerifyConditionsContext): Promise<void>;
|
|
20
|
+
export declare function prepare(pluginConfig: GodotPluginOptions, context: PrepareContext): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AAI3E,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,UAAU,IAAI;IACb,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,UAAU,OAAO;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,EAAE,CAAC;CACd;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAyC3D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAehE;AAED,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GACjB,MAAM,CA6DR;AAED,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,SAAmB,GAC3B,MAAM,CAuBR;AAED,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,SAAiB,GAC3B,MAAM,CAYR;AAwBD,wBAAsB,gBAAgB,CACrC,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAwDf;AAED,wBAAsB,OAAO,CAC5B,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CA2Df"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { access, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { GodotPluginError } from "./error.js";
|
|
6
|
+
import { resolveGodotConfig } from "./options.js";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
export function parseGodotConfig(content) {
|
|
9
|
+
const lines = content.split(/\r?\n/);
|
|
10
|
+
const sections = [];
|
|
11
|
+
let currentSection = { name: "", lines: [] };
|
|
12
|
+
sections.push(currentSection);
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
16
|
+
const name = trimmed.slice(1, -1);
|
|
17
|
+
currentSection = { name, lines: [] };
|
|
18
|
+
sections.push(currentSection);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (trimmed === "") {
|
|
22
|
+
currentSection.lines.push({ type: "empty", raw: line });
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (trimmed.startsWith(";")) {
|
|
26
|
+
currentSection.lines.push({ type: "comment", raw: line });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const equalIndex = line.indexOf("=");
|
|
30
|
+
if (equalIndex !== -1) {
|
|
31
|
+
const key = line.slice(0, equalIndex).trim();
|
|
32
|
+
const value = line.slice(equalIndex + 1).trim();
|
|
33
|
+
currentSection.lines.push({
|
|
34
|
+
type: "keyvalue",
|
|
35
|
+
key,
|
|
36
|
+
value,
|
|
37
|
+
raw: line,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
currentSection.lines.push({ type: "unknown", raw: line });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return sections;
|
|
45
|
+
}
|
|
46
|
+
export function stringifyGodotConfig(sections) {
|
|
47
|
+
const output = [];
|
|
48
|
+
for (const section of sections) {
|
|
49
|
+
if (section.name !== "") {
|
|
50
|
+
output.push(`[${section.name}]`);
|
|
51
|
+
}
|
|
52
|
+
for (const line of section.lines) {
|
|
53
|
+
if (line.type === "keyvalue") {
|
|
54
|
+
output.push(`${line.key}=${line.value}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
output.push(line.raw);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return output.join("\n");
|
|
62
|
+
}
|
|
63
|
+
export function updateExportPresets(content, versionName, versionCode) {
|
|
64
|
+
const sections = parseGodotConfig(content);
|
|
65
|
+
// Find all preset indices that are Android
|
|
66
|
+
const androidPresets = new Set();
|
|
67
|
+
for (const section of sections) {
|
|
68
|
+
const match = section.name.match(/^preset\.(\d+)$/);
|
|
69
|
+
if (match) {
|
|
70
|
+
const index = match[1];
|
|
71
|
+
if (index) {
|
|
72
|
+
const platformLine = section.lines.find((l) => l.type === "keyvalue" && l.key === "platform");
|
|
73
|
+
if (platformLine?.value === '"Android"') {
|
|
74
|
+
androidPresets.add(index);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Update options sections for those presets
|
|
80
|
+
for (const index of androidPresets) {
|
|
81
|
+
const optionsSectionName = `preset.${index}.options`;
|
|
82
|
+
let optionsSection = sections.find((s) => s.name === optionsSectionName);
|
|
83
|
+
if (!optionsSection) {
|
|
84
|
+
optionsSection = { name: optionsSectionName, lines: [] };
|
|
85
|
+
sections.push(optionsSection);
|
|
86
|
+
}
|
|
87
|
+
// Update or add version/code
|
|
88
|
+
const codeLine = optionsSection.lines.find((l) => l.type === "keyvalue" && l.key === "version/code");
|
|
89
|
+
if (codeLine) {
|
|
90
|
+
codeLine.value = String(versionCode);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
optionsSection.lines.push({
|
|
94
|
+
type: "keyvalue",
|
|
95
|
+
key: "version/code",
|
|
96
|
+
value: String(versionCode),
|
|
97
|
+
raw: `version/code=${versionCode}`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// Update or add version/name
|
|
101
|
+
const nameLine = optionsSection.lines.find((l) => l.type === "keyvalue" && l.key === "version/name");
|
|
102
|
+
if (nameLine) {
|
|
103
|
+
nameLine.value = `"${versionName}"`;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
optionsSection.lines.push({
|
|
107
|
+
type: "keyvalue",
|
|
108
|
+
key: "version/name",
|
|
109
|
+
value: `"${versionName}"`,
|
|
110
|
+
raw: `version/name="${versionName}"`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return stringifyGodotConfig(sections);
|
|
115
|
+
}
|
|
116
|
+
export function updateProjectGodot(content, versionName, versionKey = "config/version") {
|
|
117
|
+
const sections = parseGodotConfig(content);
|
|
118
|
+
let appSection = sections.find((s) => s.name === "application");
|
|
119
|
+
if (!appSection) {
|
|
120
|
+
appSection = { name: "application", lines: [] };
|
|
121
|
+
sections.push(appSection);
|
|
122
|
+
}
|
|
123
|
+
const versionLine = appSection.lines.find((l) => l.type === "keyvalue" && l.key === versionKey);
|
|
124
|
+
if (versionLine) {
|
|
125
|
+
versionLine.value = `"${versionName}"`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
appSection.lines.push({
|
|
129
|
+
type: "keyvalue",
|
|
130
|
+
key: versionKey,
|
|
131
|
+
value: `"${versionName}"`,
|
|
132
|
+
raw: `${versionKey}="${versionName}"`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return stringifyGodotConfig(sections);
|
|
136
|
+
}
|
|
137
|
+
export function updateGDScript(content, versionName, constantName = "GAME_VERSION") {
|
|
138
|
+
const regex = new RegExp(`(${constantName}(?:\\s*:\\s*\\w+)?\\s*=\\s*["'])([^"']*)(["'])`);
|
|
139
|
+
if (!regex.test(content)) {
|
|
140
|
+
throw new GodotPluginError("EGDSCRIPTCONSTANTNOTFOUND", `semantic-release-godot: Could not find version constant "${constantName}" in script.`, "Verify the constant exists in the GDScript file and is assigned a string value.");
|
|
141
|
+
}
|
|
142
|
+
return content.replace(regex, `$1${versionName}$3`);
|
|
143
|
+
}
|
|
144
|
+
const resolveScriptPath = (path, cwd) => {
|
|
145
|
+
const cleanPath = path.startsWith("res://") ? path.slice(6) : path;
|
|
146
|
+
return resolve(cwd, cleanPath);
|
|
147
|
+
};
|
|
148
|
+
const getCommitCount = async (cwd) => {
|
|
149
|
+
try {
|
|
150
|
+
const { stdout } = await execFileAsync("git", ["rev-list", "--count", "HEAD"], { cwd });
|
|
151
|
+
return Number.parseInt(stdout.trim(), 10);
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
throw new GodotPluginError("EGITCOMMITCOUNT", "semantic-release-godot: Failed to determine git commit count.", err instanceof Error ? err.message : String(err));
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
export async function verifyConditions(pluginConfig, context) {
|
|
158
|
+
const config = resolveGodotConfig(pluginConfig, context.env);
|
|
159
|
+
const cwd = context.cwd ?? process.cwd();
|
|
160
|
+
// 1. Verify git is available if versionCode is computed
|
|
161
|
+
if (config.versionCode === null) {
|
|
162
|
+
try {
|
|
163
|
+
await execFileAsync("git", ["--version"], { cwd });
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
throw new GodotPluginError("EGITNOTFOUND", "semantic-release-godot: git must be installed to compute versionCode.", err instanceof Error ? err.message : String(err));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// 2. Verify export_presets.cfg exists
|
|
170
|
+
const presetsPath = resolve(cwd, config.exportPresetsPath);
|
|
171
|
+
try {
|
|
172
|
+
await access(presetsPath);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
throw new GodotPluginError("EMISSINGEXPORTPRESETS", `semantic-release-godot: export_presets.cfg not found at "${presetsPath}".`, "Make sure export_presets.cfg exists in your project repository.");
|
|
176
|
+
}
|
|
177
|
+
// 3. If Approach A is enabled, verify project.godot exists
|
|
178
|
+
if (config.enableApproachA) {
|
|
179
|
+
const projectGodotPath = resolve(cwd, config.projectGodotPath);
|
|
180
|
+
try {
|
|
181
|
+
await access(projectGodotPath);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
throw new GodotPluginError("EMISSINGPROJECTGODOT", `semantic-release-godot: project.godot not found at "${projectGodotPath}".`, "Approach A is enabled by default. Set enableApproachA to false if you do not want to use it.");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// 4. If Approach B is enabled, verify gdScriptPath exists
|
|
188
|
+
if (config.enableApproachB && config.gdScriptPath) {
|
|
189
|
+
const scriptPath = resolveScriptPath(config.gdScriptPath, cwd);
|
|
190
|
+
try {
|
|
191
|
+
await access(scriptPath);
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
throw new GodotPluginError("EMISSINGGDSCRIPT", `semantic-release-godot: GDScript file not found at "${scriptPath}".`, "Make sure the gdScriptPath option matches an existing file in your repository.");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export async function prepare(pluginConfig, context) {
|
|
199
|
+
const config = resolveGodotConfig(pluginConfig, context.env);
|
|
200
|
+
const cwd = context.cwd ?? process.cwd();
|
|
201
|
+
// 1. Calculate version code
|
|
202
|
+
let code = config.versionCode;
|
|
203
|
+
if (code === null) {
|
|
204
|
+
const commitCount = await getCommitCount(cwd);
|
|
205
|
+
code = commitCount + config.versionCodeOffset;
|
|
206
|
+
}
|
|
207
|
+
const versionName = context.nextRelease.version;
|
|
208
|
+
// 2. Update export_presets.cfg
|
|
209
|
+
const presetsPath = resolve(cwd, config.exportPresetsPath);
|
|
210
|
+
const presetsContent = await readFile(presetsPath, "utf8");
|
|
211
|
+
const updatedPresetsContent = updateExportPresets(presetsContent, versionName, code);
|
|
212
|
+
await writeFile(presetsPath, updatedPresetsContent, "utf8");
|
|
213
|
+
context.logger.log(`[semantic-release-godot] Updated Android preset options in "${config.exportPresetsPath}" with version/name="${versionName}" and version/code=${code}`);
|
|
214
|
+
// 3. If Approach A is enabled, update project.godot
|
|
215
|
+
if (config.enableApproachA) {
|
|
216
|
+
const projectGodotPath = resolve(cwd, config.projectGodotPath);
|
|
217
|
+
const projectGodotContent = await readFile(projectGodotPath, "utf8");
|
|
218
|
+
const updatedProjectGodotContent = updateProjectGodot(projectGodotContent, versionName, config.projectVersionKey);
|
|
219
|
+
await writeFile(projectGodotPath, updatedProjectGodotContent, "utf8");
|
|
220
|
+
context.logger.log(`[semantic-release-godot] Updated "${config.projectGodotPath}" [application] ${config.projectVersionKey} to "${versionName}"`);
|
|
221
|
+
}
|
|
222
|
+
// 4. If Approach B is enabled, update GDScript file
|
|
223
|
+
if (config.enableApproachB && config.gdScriptPath) {
|
|
224
|
+
const scriptPath = resolveScriptPath(config.gdScriptPath, cwd);
|
|
225
|
+
const scriptContent = await readFile(scriptPath, "utf8");
|
|
226
|
+
const updatedScriptContent = updateGDScript(scriptContent, versionName, config.gdScriptVersionConstant);
|
|
227
|
+
await writeFile(scriptPath, updatedScriptContent, "utf8");
|
|
228
|
+
context.logger.log(`[semantic-release-godot] Updated GDScript constant "${config.gdScriptVersionConstant}" in "${config.gdScriptPath}" to "${versionName}"`);
|
|
229
|
+
}
|
|
230
|
+
context.logger.success("[semantic-release-godot] Successfully injected version info!");
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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?: string;
|
|
3
|
+
readonly projectGodotPath?: string;
|
|
4
|
+
readonly enableApproachA?: boolean;
|
|
5
|
+
readonly projectVersionKey?: string;
|
|
6
|
+
readonly enableApproachB?: boolean;
|
|
7
|
+
readonly gdScriptPath?: string;
|
|
8
|
+
readonly gdScriptVersionConstant?: string;
|
|
9
|
+
readonly versionCode?: number;
|
|
10
|
+
readonly versionCodeOffset?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolvedGodotPluginConfig {
|
|
13
|
+
readonly exportPresetsPath: string;
|
|
14
|
+
readonly projectGodotPath: string;
|
|
15
|
+
readonly enableApproachA: boolean;
|
|
16
|
+
readonly projectVersionKey: string;
|
|
17
|
+
readonly enableApproachB: boolean;
|
|
18
|
+
readonly gdScriptPath: string | null;
|
|
19
|
+
readonly gdScriptVersionConstant: string;
|
|
20
|
+
readonly versionCode: number | null;
|
|
21
|
+
readonly versionCodeOffset: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function resolveGodotConfig(pluginConfig: GodotPluginOptions, env: Readonly<Record<string, string | undefined>>): ResolvedGodotPluginConfig;
|
|
24
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AA2BD,wBAAgB,kBAAkB,CACjC,YAAY,EAAE,kBAAkB,EAChC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAC/C,yBAAyB,CA2D3B"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { GodotPluginError } from "./error.js";
|
|
2
|
+
const parseBoolean = (name, value, defaultValue) => {
|
|
3
|
+
if (value === undefined) {
|
|
4
|
+
return defaultValue;
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === "boolean") {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
const normalized = value.trim().toLowerCase();
|
|
10
|
+
if (["true", "1", "yes"].includes(normalized)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (["false", "0", "no"].includes(normalized)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
throw new GodotPluginError("EINVALIDBOOLEAN", `semantic-release-godot: ${name} must be a boolean.`, `Use true/false for ${name}.`);
|
|
17
|
+
};
|
|
18
|
+
export function resolveGodotConfig(pluginConfig, env) {
|
|
19
|
+
const enableApproachA = parseBoolean("enableApproachA", pluginConfig.enableApproachA ?? env.GODOT_ENABLE_APPROACH_A, true);
|
|
20
|
+
const enableApproachB = parseBoolean("enableApproachB", pluginConfig.enableApproachB ?? env.GODOT_ENABLE_APPROACH_B, false);
|
|
21
|
+
const gdScriptPath = pluginConfig.gdScriptPath || env.GODOT_GDSCRIPT_PATH || null;
|
|
22
|
+
if (enableApproachB && !gdScriptPath) {
|
|
23
|
+
throw new GodotPluginError("EMISSINGGDSCRIPTPATH", "semantic-release-godot: gdScriptPath is required when enableApproachB is true.", "Set gdScriptPath in plugin options or GODOT_GDSCRIPT_PATH environment variable.");
|
|
24
|
+
}
|
|
25
|
+
let versionCodeRaw = null;
|
|
26
|
+
if (pluginConfig.versionCode !== undefined) {
|
|
27
|
+
versionCodeRaw = pluginConfig.versionCode;
|
|
28
|
+
}
|
|
29
|
+
else if (env.GODOT_VERSION_CODE) {
|
|
30
|
+
versionCodeRaw = Number.parseInt(env.GODOT_VERSION_CODE, 10);
|
|
31
|
+
}
|
|
32
|
+
let versionCodeOffset = 0;
|
|
33
|
+
if (pluginConfig.versionCodeOffset !== undefined) {
|
|
34
|
+
versionCodeOffset = pluginConfig.versionCodeOffset;
|
|
35
|
+
}
|
|
36
|
+
else if (env.GODOT_VERSION_CODE_OFFSET) {
|
|
37
|
+
versionCodeOffset = Number.parseInt(env.GODOT_VERSION_CODE_OFFSET, 10);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
exportPresetsPath: pluginConfig.exportPresetsPath ||
|
|
41
|
+
env.GODOT_EXPORT_PRESETS_PATH ||
|
|
42
|
+
"export_presets.cfg",
|
|
43
|
+
projectGodotPath: pluginConfig.projectGodotPath ||
|
|
44
|
+
env.GODOT_PROJECT_GODOT_PATH ||
|
|
45
|
+
"project.godot",
|
|
46
|
+
enableApproachA,
|
|
47
|
+
projectVersionKey: pluginConfig.projectVersionKey ||
|
|
48
|
+
env.GODOT_PROJECT_VERSION_KEY ||
|
|
49
|
+
"config/version",
|
|
50
|
+
enableApproachB,
|
|
51
|
+
gdScriptPath,
|
|
52
|
+
gdScriptVersionConstant: pluginConfig.gdScriptVersionConstant ||
|
|
53
|
+
env.GODOT_GDSCRIPT_VERSION_CONSTANT ||
|
|
54
|
+
"GAME_VERSION",
|
|
55
|
+
versionCode: versionCodeRaw,
|
|
56
|
+
versionCodeOffset,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0B9C,MAAM,YAAY,GAAG,CACpB,IAAY,EACZ,KAAmC,EACnC,YAAqB,EACX,EAAE;IACZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,IAAI,gBAAgB,CACzB,iBAAiB,EACjB,2BAA2B,IAAI,qBAAqB,EACpD,sBAAsB,IAAI,GAAG,CAC7B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,kBAAkB,CACjC,YAAgC,EAChC,GAAiD;IAEjD,MAAM,eAA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QACf,iBAAiB,EAChB,YAAY,CAAC,iBAAiB;YAC9B,GAAG,CAAC,yBAAyB;YAC7B,gBAAgB;QACjB,eAAe;QACf,YAAY;QACZ,uBAAuB,EACtB,YAAY,CAAC,uBAAuB;YACpC,GAAG,CAAC,+BAA+B;YACnC,cAAc;QACf,WAAW,EAAE,cAAc;QAC3B,iBAAiB;KACjB,CAAC;AACH,CAAC"}
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Godot 4 semantic-release plugin
|
|
2
|
+
|
|
3
|
+
This plugin automates the injection of version names and build codes for Godot 4 games during the `prepare` phase of the release pipeline.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Android Export Versioning (`export_presets.cfg`)**: Automatically updates or adds `version/name` and `version/code` configuration properties.
|
|
8
|
+
- **Approach A (`project.godot`)**: Updates the application config version string so the game can read it dynamically at runtime.
|
|
9
|
+
- **Approach B (GDScript Autoload)**: Performs regex-based substitution of a version constant in a GDScript file.
|
|
10
|
+
|
|
11
|
+
## Lifecycle Placement
|
|
12
|
+
|
|
13
|
+
The version changes are written locally during the `prepare` step, allowing subsequent steps in your pipeline (like exporting/compiling via the Godot CLI, or committing changed files back to Git) to have access to the exact release version.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
These examples show how to configure `@victorrl/semantic-release-godot` in a `semantic-release` pipeline.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- [`semantic-release.config.js`](./semantic-release.config.js): A typical semantic-release plugin chain setup that modifies your Android export presets, `project.godot` file, and an Autoload GDScript file containing a version constant, and then commits the modified files back to Git before creating the release.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
branches: ["main", { name: "next", prerelease: true }],
|
|
3
|
+
plugins: [
|
|
4
|
+
"@semantic-release/commit-analyzer",
|
|
5
|
+
"@semantic-release/release-notes-generator",
|
|
6
|
+
[
|
|
7
|
+
"@victorrl/semantic-release-godot",
|
|
8
|
+
{
|
|
9
|
+
exportPresetsPath: "export_presets.cfg",
|
|
10
|
+
projectGodotPath: "project.godot",
|
|
11
|
+
enableApproachA: true,
|
|
12
|
+
enableApproachB: true,
|
|
13
|
+
gdScriptPath: "res://scripts/Version.gd",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
"@semantic-release/git",
|
|
18
|
+
{
|
|
19
|
+
assets: [
|
|
20
|
+
"export_presets.cfg",
|
|
21
|
+
"project.godot",
|
|
22
|
+
"scripts/Version.gd",
|
|
23
|
+
],
|
|
24
|
+
message:
|
|
25
|
+
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
"@semantic-release/github",
|
|
29
|
+
],
|
|
30
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@victorrl/semantic-release-godot",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "semantic-release plugin to automate version and build code injection for Godot 4 projects.",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"docs",
|
|
21
|
+
"examples",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20",
|
|
26
|
+
"bun": ">=1.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"prepack": "npm install --no-audit --no-fund && npm run build",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "biome check src tests",
|
|
33
|
+
"lint:fix": "biome check --write src tests",
|
|
34
|
+
"format": "biome format --write src tests",
|
|
35
|
+
"format:check": "biome format src tests",
|
|
36
|
+
"test": "bun test tests",
|
|
37
|
+
"test:unit": "bun test tests/unit",
|
|
38
|
+
"test:integration": "bun test tests/integration",
|
|
39
|
+
"test:coverage": "bun test tests --coverage",
|
|
40
|
+
"audit": "bun audit"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"semantic-release": ">=24"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@biomejs/biome": "^2.5.0",
|
|
47
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
49
|
+
"@types/bun": "^1.3.14",
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"semantic-release": "24.2.0",
|
|
52
|
+
"typescript": "^5.6.0"
|
|
53
|
+
}
|
|
54
|
+
}
|