Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
c671a6524f | |||
ad7c5a4f85
|
|||
18b493d524
|
|||
466c1c4918 | |||
3d50c5cc8d
|
|||
a753d6aa3b
|
|||
7bba14fe49 | |||
c8628e7bd7
|
|||
df27af76ad
|
|||
6b4016177f | |||
33c5c71923
|
|||
8df31fb97e
|
24
CHANGELOG.md
24
CHANGELOG.md
@@ -2,6 +2,30 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [2.0.6](https://git.0xmax42.io/actions/auto-changelog-release-action/compare/v2.0.5..v2.0.6) - 2025-07-04
|
||||
|
||||
### 🚜 Refactor
|
||||
|
||||
- *(scripts)* Simplify path management and command execution - ([18b493d](https://git.0xmax42.io/actions/auto-changelog-release-action/commit/18b493d524630e8da304e2a8ec098415fa9140e1))
|
||||
|
||||
## [2.0.5](https://git.0xmax42.io/actions/auto-changelog-release-action/compare/v2.0.4..v2.0.5) - 2025-07-04
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- *(script)* Correct path formatting in version detection script - ([a753d6a](https://git.0xmax42.io/actions/auto-changelog-release-action/commit/a753d6aa3b45d4dab36e4ef56bbc71046eb032c9))
|
||||
|
||||
## [2.0.4](https://git.0xmax42.io/actions/auto-changelog-release-action/compare/v2.0.3..v2.0.4) - 2025-07-04
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- *(main)* Update script path to ensure correct resolution - ([df27af7](https://git.0xmax42.io/actions/auto-changelog-release-action/commit/df27af76add1dc4b50ead8015976b5e96b177661))
|
||||
|
||||
## [2.0.3](https://git.0xmax42.io/actions/auto-changelog-release-action/compare/v2.0.2..v2.0.3) - 2025-07-04
|
||||
|
||||
### 🚜 Refactor
|
||||
|
||||
- *(action)* Simplify composite action structure - ([8df31fb](https://git.0xmax42.io/actions/auto-changelog-release-action/commit/8df31fb97ebd73e71b2f8a9dc925fe8a81192be3))
|
||||
|
||||
## [2.0.2](https://git.0xmax42.io/actions/auto-changelog-release-action/compare/v2.0.1..v2.0.2) - 2025-07-04
|
||||
|
||||
### 🚜 Refactor
|
||||
|
57
action.yml
57
action.yml
@@ -1,46 +1,29 @@
|
||||
name: "Auto Changelog & Release"
|
||||
description: "Detects version bump and, in post-step, writes changelog or publishes release."
|
||||
name: Auto Changelog & Release
|
||||
description: One-stop composite action
|
||||
|
||||
inputs:
|
||||
token: { description: "Gitea/GitHub PAT", default: "" }
|
||||
author_name: { description: "Commit author", default: "" }
|
||||
author_email: { description: "Commit e-mail", default: "" }
|
||||
token:
|
||||
description: "Gitea/GitHub PAT für Release-API"
|
||||
required: false
|
||||
default: ""
|
||||
author_name:
|
||||
description: "Commit-Autorname"
|
||||
required: false
|
||||
default: ""
|
||||
author_email:
|
||||
description: "Commit-Autore-Mail"
|
||||
required: false
|
||||
default: ""
|
||||
allow_non_main_release:
|
||||
description: "Allow release on branches ≠ main"
|
||||
description: "Allow publishing releases from branches other than 'main'."
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
outputs:
|
||||
release:
|
||||
description: "true if VERSION changed"
|
||||
value: ${{ steps.detect.outputs.version_changed }}
|
||||
description: "Whether a release should be made (true/false)"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: detect
|
||||
name: Detect version change + queue post work
|
||||
uses: ./with-post-step
|
||||
with:
|
||||
key: AUTOCHANGELOG
|
||||
#################### MAIN ####################
|
||||
main: |
|
||||
${{ github.action_path }}/scripts/detect-version-change.sh
|
||||
#################### POST ####################
|
||||
post: |
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# VERSION_CHANGED kommt aus detect-Script via $GITHUB_ENV
|
||||
CLIFF_VERSION="$(
|
||||
${{ github.action_path }}/scripts/read-cliff-version.sh | tail -n1
|
||||
)"
|
||||
"${{ github.action_path }}/scripts/install-git-cliff.sh" "$CLIFF_VERSION"
|
||||
"${{ github.action_path }}/scripts/setup-git.sh" \
|
||||
"${{ inputs.author_name }}" "${{ inputs.author_email }}"
|
||||
if [[ "${VERSION_CHANGED:-false}" == "true" ]]; then
|
||||
# --- Release-Pfad ---
|
||||
RELEASE_PUBLISH_TOKEN='${{ inputs.token }}' \
|
||||
"${{ github.action_path }}/scripts/release-from-version.sh"
|
||||
else
|
||||
# --- Nur Changelog aktualisieren ---
|
||||
"${{ github.action_path }}/scripts/generate-unreleased-changelog.sh"
|
||||
fi
|
||||
using: "node20"
|
||||
main: "dist/main.js"
|
||||
post: "dist/post.js"
|
||||
|
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 script = path.join(__dirname, "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();
|
42
dist/post.js
vendored
Normal file
42
dist/post.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
const cp = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
function run(script, args = []) {
|
||||
const cmd = typeof script === "string" ? script : script.join(" ");
|
||||
cp.execSync(cmd, {
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
env: process.env,
|
||||
});
|
||||
}
|
||||
|
||||
function scriptPath(...segments) {
|
||||
return path.join(__dirname, "scripts", ...segments);
|
||||
}
|
||||
|
||||
function main() {
|
||||
const versionChanged = (process.env.VERSION_CHANGED || "false").toLowerCase() === "true";
|
||||
|
||||
const readCliffScript = scriptPath("read-cliff-version.sh");
|
||||
const cliffVersion = cp
|
||||
.execSync(readCliffScript, { encoding: "utf-8", shell: true })
|
||||
.trim()
|
||||
.split("\n")
|
||||
.pop();
|
||||
|
||||
run(scriptPath("install-git-cliff.sh") + " " + cliffVersion);
|
||||
|
||||
run(
|
||||
scriptPath("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(scriptPath("release-from-version.sh"));
|
||||
} else {
|
||||
run(scriptPath("generate-unreleased-changelog.sh"));
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
@@ -1,11 +0,0 @@
|
||||
name: "with-post-step"
|
||||
description: "Runs a main command and, afterwards, a post command."
|
||||
inputs:
|
||||
main: { description: "Command for the main step", required: true }
|
||||
post: { description: "Command for the post step", required: true }
|
||||
key: { description: "State key", default: POST }
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
main: main.js
|
||||
post: main.js
|
@@ -1,18 +0,0 @@
|
||||
const { spawn } = require("child_process");
|
||||
const { appendFileSync } = require("fs");
|
||||
const { EOL } = require("os");
|
||||
|
||||
function run(cmd) {
|
||||
const proc = spawn(cmd, { stdio: "inherit", shell: true });
|
||||
proc.on("exit", code => process.exitCode = code);
|
||||
}
|
||||
|
||||
const key = process.env.INPUT_KEY.toUpperCase();
|
||||
if (process.env[`STATE_${key}`] !== undefined) {
|
||||
// ---------- POST ----------
|
||||
run(process.env.INPUT_POST);
|
||||
} else {
|
||||
// ---------- MAIN ----------
|
||||
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
|
||||
run(process.env.INPUT_MAIN);
|
||||
}
|
Reference in New Issue
Block a user