Skip to content

Commit 93fc1bc

Browse files
committed
Add GitHub Action to generate and update changelog
This commit introduces a new GitHub Action using `generate-changelog` to automate changelog creation or updates. It includes an `action.yml` for configuration, an `entrypoint.sh` script for handling inputs and execution, and a `Dockerfile` to set up the required environment.
1 parent bc03bcc commit 93fc1bc

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3-slim
2+
3+
ENV PYTHONDONTWRITEBYTECODE 1 \
4+
PYTHONUNBUFFERED 1
5+
6+
RUN python -m venv venv && \
7+
. venv/bin/activate && \
8+
pip install --upgrade pip && \
9+
venv/bin/pip install --upgrade --no-cache-dir generate-changelog==0.12.1
10+
11+
COPY entrypoint.sh /entrypoint.sh
12+
13+
ENTRYPOINT ["/entrypoint.sh"]

action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Run Generate Changelog"
2+
description: "Run generate-changelog to create or update a changelog."
3+
author: "Corey Oordt"
4+
inputs:
5+
config_file:
6+
description: "Path to the config file if it is not one of the defaults."
7+
required: false
8+
default: ""
9+
starting_tag:
10+
description: "Tag to generate a changelog from."
11+
required: false
12+
default: ""
13+
skip_output_pipeline:
14+
description: "Do not generate or update the CHANGELOG, but still return the release hint."
15+
required: false
16+
default: "false"
17+
branch_override:
18+
description: "Override the current branch for release hint decisions."
19+
required: false
20+
default: ""
21+
outputs:
22+
release_hint:
23+
description: "The suggested type of release to generate."
24+
branding:
25+
color: "black"
26+
icon: "file-text"
27+
runs:
28+
using: "docker"
29+
image: "Dockerfile"

entrypoint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e # Increase bash strictness
3+
set -o pipefail
4+
5+
function parse_boolean() {
6+
local value="false"
7+
value=$(echo "${1}" | awk '{print tolower($0)}') # Convert to lowercase
8+
case "$value" in
9+
"true" | "yes" | "1")
10+
echo 1
11+
;;
12+
*)
13+
echo 0
14+
;;
15+
esac
16+
}
17+
18+
changelog_args=("-o" "release-hint")
19+
20+
if [[ -n ${INPUT_STARTING_TAG} ]]; then
21+
changelog_args+=("-t" "${INPUT_STARTING_TAG}")
22+
fi
23+
24+
if [[ -n ${INPUT_SKIP_OUTPUT_PIPELINE} && $(parse_boolean "${INPUT_SKIP_OUTPUT_PIPELINE}") -eq 1 ]]; then
25+
changelog_args+=("--skip-output-pipeline")
26+
fi
27+
28+
if [[ -n ${INPUT_BRANCH_OVERRIDE} ]]; then
29+
changelog_args+=("-b" "${INPUT_BRANCH_OVERRIDE}")
30+
fi
31+
32+
echo "[action-generate-changelog] Generating the changelog with arguments '${changelog_args[*]}'"
33+
34+
RELEASE_HINT=$(/venv/bin/generate-changelog "${changelog_args[*]}")
35+
echo "::notice::Suggested release type for this branch is: ${RELEASE_HINT}"
36+
echo "release_hint=$RELEASE_HINT" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)