refactor(action): simplify composite action structure
- Replaces custom with-post-step logic with Node.js-based implementation - Consolidates main and post scripts for clarity and maintainability - Updates descriptions and input definitions for improved readability
This commit is contained in:
34
dist/main.js
vendored
Normal file
34
dist/main.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
const cp = require("child_process");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
function run(script) {
|
||||
cp.execFileSync(script, { stdio: "inherit", shell: true });
|
||||
}
|
||||
|
||||
function exportOutput(key, value) {
|
||||
fs.appendFileSync(process.env.GITHUB_OUTPUT, `${key}=${value}\n`);
|
||||
}
|
||||
|
||||
function setEnv(key, value) {
|
||||
fs.appendFileSync(process.env.GITHUB_ENV, `${key}=${value}\n`);
|
||||
}
|
||||
|
||||
function main() {
|
||||
const actionPath = process.env.GITHUB_ACTION_PATH || ".";
|
||||
const script = path.join(actionPath, "scripts/detect-version-change.sh");
|
||||
|
||||
run(script);
|
||||
|
||||
// Hier nehmen wir an, dass das Script selbst bereits `version_changed=true/false`
|
||||
// in $GITHUB_OUTPUT geschrieben hat.
|
||||
// Zur Sicherheit lesen wir das nochmal aus und speichern es auch als release-Flag.
|
||||
const output = fs.readFileSync(process.env.GITHUB_OUTPUT, "utf-8");
|
||||
const match = output.match(/^version_changed=(.*)$/m);
|
||||
const value = match?.[1]?.trim() || "false";
|
||||
|
||||
exportOutput("release", value);
|
||||
setEnv("VERSION_CHANGED", value);
|
||||
}
|
||||
|
||||
main();
|
31
dist/post.js
vendored
Normal file
31
dist/post.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
const cp = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
function run(script, args = []) {
|
||||
cp.execFileSync(script, {
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
env: process.env,
|
||||
});
|
||||
}
|
||||
|
||||
function main() {
|
||||
const actionPath = process.env.GITHUB_ACTION_PATH || ".";
|
||||
const versionChanged = (process.env.VERSION_CHANGED || "false").toLowerCase() === "true";
|
||||
|
||||
const readCliff = path.join(actionPath, "scripts/read-cliff-version.sh");
|
||||
const cliffVersion = cp.execSync(readCliff, { encoding: "utf-8", shell: true }).trim().split("\n").pop();
|
||||
|
||||
run(path.join(actionPath, "scripts/install-git-cliff.sh"), [cliffVersion]);
|
||||
|
||||
run(`${path.join(actionPath, "scripts/setup-git.sh")} "${process.env.INPUT_AUTHOR_NAME}" "${process.env.INPUT_AUTHOR_EMAIL}"`);
|
||||
|
||||
if (versionChanged) {
|
||||
process.env.RELEASE_PUBLISH_TOKEN = process.env.INPUT_TOKEN || "";
|
||||
run(path.join(actionPath, "scripts/release-from-version.sh"));
|
||||
} else {
|
||||
run(path.join(actionPath, "scripts/generate-unreleased-changelog.sh"));
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
Reference in New Issue
Block a user