diff --git a/.ci/get-git-version.sh b/.ci/get-git-version.sh new file mode 100755 index 00000000000..db500711268 --- /dev/null +++ b/.ci/get-git-version.sh @@ -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 " + 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" + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61087c88c6f..ca399cf8e69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -353,10 +353,11 @@ 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 @@ -364,7 +365,19 @@ Generate release notes: - 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