Enhance publish_release job: export version and add release metadata for automated releases

This commit is contained in:
MaddoScientisto 2026-02-22 14:51:44 +01:00
commit 3ae4da3e49

View file

@ -120,6 +120,7 @@ publish_release:
version=$(minver 2>/dev/null | tail -n1 || true)
if [ -z "$version" ]; then echo "minver failed to produce a version"; exit 1; fi
echo "Using version: $version"
export VERSION="$version"
# find the single-file exe from the publish output
file=$(find imagecatalog/bin -type f -iname '*.exe' -print | head -n1 || true)
if [ -z "$file" ]; then file=$(find imagecatalog -type f -iname '*.exe' -print | head -n1 || true); fi
@ -131,13 +132,18 @@ publish_release:
assetUrl="$CI_SERVER_URL$assetPath"
echo "Uploaded asset url: $assetUrl"
basename=$(basename "$file")
cat > release.json <<EOF
{"name":"$version","tag_name":"$version","ref":"$CI_COMMIT_SHA","description":"Automated release from CI (version $version)","assets":{"links":[{"name":"$basename","url":"$assetUrl"}]}}
EOF
echo "Creating release for tag: $version"
curl --silent --show-error --header "JOB-TOKEN:$CI_JOB_TOKEN" -X POST -H "Content-Type: application/json" --data @release.json "$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases"
export RELEASE_ASSET_URL="$assetUrl"
export ASSET_BASENAME="$basename"
artifacts:
expire_in: 1 day
release:
tag_name: "$VERSION"
name: "Release $VERSION"
description: "Automated release from CI (version $VERSION)"
assets:
links:
- name: "$ASSET_BASENAME"
url: "$RELEASE_ASSET_URL"
# only:
# - tags