fix(ci): correctly add release notes from tag to changelog
This commit is contained in:
@@ -5,16 +5,21 @@ TAG="$GITHUB_REF_NAME"
|
|||||||
VERSION=$(echo "$TAG" | sed 's/^v//')
|
VERSION=$(echo "$TAG" | sed 's/^v//')
|
||||||
DATE=$(date +%Y-%m-%d)
|
DATE=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
echo "🚀 Creating release for $TAG (safe mode)"
|
echo "🚀 Creating release for $TAG"
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 1. Extract release notes from annotated tag
|
# 1. Extract release notes from annotated tag
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Ensure the local git knows this is an annotated tag with metadata
|
||||||
|
git fetch origin "refs/tags/$TAG:refs/tags/$TAG" --force
|
||||||
|
|
||||||
|
# %(contents) gets the whole message.
|
||||||
|
# If you want ONLY what you typed after the first line, use %(contents:body)
|
||||||
NOTES=$(git tag -l "$TAG" --format='%(contents)')
|
NOTES=$(git tag -l "$TAG" --format='%(contents)')
|
||||||
|
|
||||||
if [ -z "$NOTES" ]; then
|
if [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
|
||||||
echo "❌ Tag message is empty"
|
echo "❌ Tag message is empty or tag is not annotated"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -23,10 +28,8 @@ git checkout main
|
|||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 2. Update all package.json versions
|
# 2. Update all package.json versions
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
echo "🔧 Updating package.json versions to $VERSION"
|
echo "🔧 Updating package.json versions to $VERSION"
|
||||||
|
find . -name package.json ! -path "*/node_modules/*" | while read -r file; do
|
||||||
find . -name package.json ! -path "*/node_modules/*" | while read file; do
|
|
||||||
tmp_file="$file.tmp"
|
tmp_file="$file.tmp"
|
||||||
jq --arg v "$VERSION" '.version = $v' "$file" >"$tmp_file"
|
jq --arg v "$VERSION" '.version = $v' "$file" >"$tmp_file"
|
||||||
mv "$tmp_file" "$file"
|
mv "$tmp_file" "$file"
|
||||||
@@ -35,20 +38,18 @@ done
|
|||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 3. Generate commit list since last release
|
# 3. Generate commit list since last release
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
# Get the previous tag (fallback to empty if none)
|
|
||||||
LAST_TAG=$(git tag --sort=-creatordate | grep -v "^$TAG$" | head -n 1 || echo "")
|
LAST_TAG=$(git tag --sort=-creatordate | grep -v "^$TAG$" | head -n 1 || echo "")
|
||||||
|
|
||||||
if [ -n "$LAST_TAG" ]; then
|
if [ -n "$LAST_TAG" ]; then
|
||||||
COMMITS=$(git log "$LAST_TAG"..HEAD --pretty=format:'[%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s')
|
# Filter out previous 'chore(release)' commits so the list stays clean
|
||||||
|
COMMITS=$(git log "$LAST_TAG"..HEAD --pretty=format:'* [%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s' | grep -v "chore(release)")
|
||||||
else
|
else
|
||||||
COMMITS=$(git log HEAD --pretty=format:'[%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s')
|
COMMITS=$(git log HEAD --pretty=format:'* [%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s' | grep -v "chore(release)")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 4. Update CHANGELOG.md (prepend)
|
# 4. Update CHANGELOG.md (prepend)
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
tmp_changelog="CHANGELOG.tmp"
|
tmp_changelog="CHANGELOG.tmp"
|
||||||
{
|
{
|
||||||
echo "## $TAG ($DATE)"
|
echo "## $TAG ($DATE)"
|
||||||
@@ -56,7 +57,7 @@ tmp_changelog="CHANGELOG.tmp"
|
|||||||
echo "$NOTES"
|
echo "$NOTES"
|
||||||
echo ""
|
echo ""
|
||||||
if [ -n "$COMMITS" ]; then
|
if [ -n "$COMMITS" ]; then
|
||||||
echo "All Commits:"
|
echo "### All Commits in this version:"
|
||||||
echo "$COMMITS"
|
echo "$COMMITS"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
@@ -74,26 +75,17 @@ pnpm exec dprint fmt CHANGELOG.md
|
|||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 5. Create release commit
|
# 5. Create release commit
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
git config user.name "release-bot"
|
git config user.name "release-bot"
|
||||||
git config user.email "release-bot@ci"
|
git config user.email "release-bot@ci"
|
||||||
|
|
||||||
git add CHANGELOG.md $(find . -name package.json ! -path "*/node_modules/*")
|
git add CHANGELOG.md $(find . -name package.json ! -path "*/node_modules/*")
|
||||||
|
|
||||||
# Skip commit if nothing changed
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "No changes to commit for release $TAG"
|
echo "No changes to commit for release $TAG"
|
||||||
exit 0
|
else
|
||||||
|
git commit -m "chore(release): $TAG"
|
||||||
|
git push origin main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit -m "chore(release): $TAG"
|
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
|
||||||
# 6. Push changes
|
|
||||||
# -------------------------------------------------------------------
|
|
||||||
|
|
||||||
git push origin main
|
|
||||||
|
|
||||||
cp CHANGELOG.md app/static/CHANGELOG.md
|
cp CHANGELOG.md app/static/CHANGELOG.md
|
||||||
|
echo "✅ Release process for $TAG complete"
|
||||||
echo "✅ Release commit for $TAG created successfully (tag untouched)"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user