Skip to content

Commit

Permalink
ci: use llm to generate release notes
Browse files Browse the repository at this point in the history
(cherry picked from commit 6fe3676)
Signed-off-by: Tigran Mkrtchyan <[email protected]>
  • Loading branch information
kofemann committed Sep 9, 2024
1 parent b368ef4 commit a6fffd4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .ci/get-git-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Function to decrement a version string
decrement_version() {
local version=$1
local major minor patch

# Extract major, minor, and patch components
IFS='.' read -r major minor patch <<< "$version"

if [[ $patch -gt 0 ]]; then
# Decrement patch version
patch=$((patch - 1))
elif [[ $minor -gt 0 ]]; then
# Decrement minor version and reset patch to max value (assumed to be 9 for simplicity)
minor=$((minor - 1))
patch=0
elif [[ $major -gt 0 ]]; then
# Decrement major version, reset minor and patch to max value
major=$((major - 1))
minor=`git tag -l "$major.*" | sort -V -r | head -1 | cut -d '.' -f 2`
patch=0
else
# If all components are zero, cannot decrement further
echo "Version cannot be decremented further."
exit 1
fi

echo "$major.$minor.$patch"
}

# Main script
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <version>"
exit 1
fi

version=$1

# Validate version format
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Expected format: major.minor.patch (e.g., 0.25.0)"
exit 1
fi

previous_version=$(decrement_version "$version")
echo "$previous_version"

15 changes: 14 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,31 @@ upload_container:
#
# This jobs needs that the number of changes to fetch from GitLab when cloning a repository is high enough to generate
# the changelog.
Generate release notes:
AI Generated Release Notes:
image: almalinux:9-minimal
stage: upload
extends: .upload_rules
allow_failure: true
dependencies:
- sign_deb
- sign_rpm
- sign_srm_client_rpm
- tar
script:
- microdnf install -y git-core
- git fetch --refetch --all --tags
- .ci/generate-changelog.sh >> release-$CI_COMMIT_TAG.md
- curl -L -o chatgpt https://github.com/kardolus/chatgpt-cli/releases/latest/download/chatgpt-linux-amd64 && chmod +x chatgpt
- LAST_TAG=$(.ci/get-git-version.sh $CI_COMMIT_TAG)
- |-
git log $LAST_TAG..$CI_COMMIT_TAG | \
OPENAI_API_KEY=$LLM_API_KEY \
OPENAI_URL=$LLM_API_ENDPOINT \
OPENAI_MODEL=$LLM_MODEL \
OPENAI_COMPLETIONS_PATH=$LLM_COMPLETIONS_PATH \
OPENAI_ROLE="You are a helpful tech writer working on release notes of the dCache project." \
./chatgpt "$LLM_PROMPT" | \
tee -a release-$CI_COMMIT_TAG.md
artifacts:
paths:
- release-*.md
Expand Down

0 comments on commit a6fffd4

Please sign in to comment.