All checks were successful
Auto Changelog & Release / release (push) Successful in 7s
- Deleted `config.env` as all values are now directly integrated into the scripts. - Updated `scripts/generate-changelog.sh` to replace remaining `echo` commands with `log_info` and `log_error`. - Ensured all scripts are self-contained and consistent in their logging and configuration handling.
110 lines
3.8 KiB
Bash
Executable File
110 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# run.sh – local wrapper for the “deb-changelog-action”
|
|
#
|
|
# This script
|
|
# 1. clones https://git.0xmax42.io/actions/deb-changelog-action at the
|
|
# requested version into a temporary directory,
|
|
# 2. installs git-cliff using the action’s helper script, and
|
|
# 3. generates a Debian-style changelog **in the current working directory**
|
|
# via the action’s generator script.
|
|
#
|
|
# Usage:
|
|
# ./run.sh --version v0 \
|
|
# --tag v2.9.1 \
|
|
# --package_name mypkg \
|
|
# --author_name "Max Mustermann" \
|
|
# --author_email max@example.com \
|
|
# [--output_file debian/changelog] \
|
|
# [--cliff_config path/to/cliff.toml]
|
|
#
|
|
# Notes:
|
|
# • Paths given for --output_file are interpreted relative to the directory
|
|
# where you run this script.
|
|
# • If --cliff_config is omitted, the default config shipped with the action
|
|
# (configs/cliff.debian.toml) is used.
|
|
# • PACKAGE_NAME, AUTHOR_NAME, AUTHOR_EMAIL are exported so the TOML template
|
|
# can reference them (e.g. {{ get_env(name="PACKAGE_NAME") }}).
|
|
set -euo pipefail
|
|
|
|
# Minimal utility functions for bootstrap
|
|
log_info() {
|
|
echo "[INFO] $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo "[ERROR] $1" >&2
|
|
}
|
|
|
|
validate_arg() {
|
|
local arg_name="$1"
|
|
local arg_value="$2"
|
|
if [[ -z "$arg_value" ]]; then
|
|
log_error "Missing required argument: $arg_name"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# ───────────────────────────────────────────────
|
|
VERSION=""
|
|
TAG=""
|
|
PACKAGE_NAME=""
|
|
AUTHOR_NAME=""
|
|
AUTHOR_EMAIL=""
|
|
OUTPUT_FILE="debian/changelog"
|
|
CLIFF_CONFIG=""
|
|
REPO_URL="https://git.0xmax42.io/actions/deb-changelog-action"
|
|
# ───────────────────────────────────────────────
|
|
|
|
show_help() { sed -n '2,25p' "$0"; }
|
|
|
|
# 1 ─ Parse CLI options ─────────────────────────
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--version) VERSION="$2"; shift 2 ;;
|
|
--tag) TAG="$2"; shift 2 ;;
|
|
--package_name) PACKAGE_NAME="$2"; shift 2 ;;
|
|
--author_name) AUTHOR_NAME="$2"; shift 2 ;;
|
|
--author_email) AUTHOR_EMAIL="$2"; shift 2 ;;
|
|
--output_file) OUTPUT_FILE="$2"; shift 2 ;;
|
|
--cliff_config) CLIFF_CONFIG="$2"; shift 2 ;;
|
|
-h|--help) show_help; exit 0 ;;
|
|
*) log_error "Unknown option: $1"; show_help; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# 2 ─ Validate mandatory inputs ────────────────
|
|
validate_arg "--version" "$VERSION"
|
|
validate_arg "--tag" "$TAG"
|
|
validate_arg "--package_name" "$PACKAGE_NAME"
|
|
validate_arg "--author_name" "$AUTHOR_NAME"
|
|
validate_arg "--author_email" "$AUTHOR_EMAIL"
|
|
|
|
# 3 ─ Prepare temporary clone ──────────────────
|
|
TMP_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
log_info "Cloning ${REPO_URL}@${VERSION} → $TMP_DIR"
|
|
git clone --depth 1 --branch "$VERSION" "$REPO_URL" "$TMP_DIR" >/dev/null
|
|
|
|
# 4 ─ Install git-cliff via helper script ──────
|
|
bash "$TMP_DIR/scripts/install-git-cliff.sh"
|
|
|
|
# 5 ─ Determine config path ────────────────────
|
|
if [[ -z "$CLIFF_CONFIG" ]]; then
|
|
CLIFF_CONFIG="$TMP_DIR/configs/cliff.debian.toml"
|
|
fi
|
|
[[ ! -r "$CLIFF_CONFIG" ]] && { log_error "Config not found: $CLIFF_CONFIG"; exit 1; }
|
|
|
|
# 6 ─ Generate changelog in CURRENT dir ────────
|
|
log_info "Generating changelog (output → $OUTPUT_FILE)"
|
|
env \
|
|
PACKAGE_NAME="$PACKAGE_NAME" \
|
|
AUTHOR_NAME="$AUTHOR_NAME" \
|
|
AUTHOR_EMAIL="$AUTHOR_EMAIL" \
|
|
bash "$TMP_DIR/scripts/generate-changelog.sh" \
|
|
-c "$CLIFF_CONFIG" \
|
|
-t "$TAG" \
|
|
-o "$OUTPUT_FILE"
|
|
|
|
log_info "Changelog ready: $OUTPUT_FILE"
|