diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04537ad..f905d4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,20 +26,29 @@ jobs: exit 1 fi - CHANGELOG_CONTENT=$(awk '/^### / {if (p) exit; p=1} p' "$CHANGELOG_FILE") + CHANGELOG_CONTENT=$(awk '/^## / {print; getline; while ($0 !~ /^### / && $0 != "") {print; getline}}' "$CHANGELOG_FILE") if [ -z "$CHANGELOG_CONTENT" ]; then echo "Error: Could not extract the latest changelog entry." + echo "::error::Extracted content is empty." exit 1 fi + echo "Extracted changelog content:" + echo "$CHANGELOG_CONTENT" echo "::set-output name=content::$CHANGELOG_CONTENT" - - name: Create annotated tag with changelog + - name: Create or update annotated tag with changelog run: | TAG_NAME="${{ github.ref_name }}" CHANGELOG_CONTENT="${{ steps.changelog.outputs.content }}" + if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then + echo "Tag $TAG_NAME already exists. Updating tag message." + git tag -d "$TAG_NAME" + git push origin :"$TAG_NAME" + fi + git tag -a "$TAG_NAME" -m "$CHANGELOG_CONTENT" git push origin "$TAG_NAME"