Skip to content

Commit

Permalink
ci(draft_release): fix special characters on commits (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou authored Feb 8, 2025
1 parent 4a731f9 commit fde626a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ permissions:
contents: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_commits: |
{"section": "breaking_changes", "prefix": "break", "header": "💥 Breaking Changes"}
{"section": "fixes", "prefix": "fix", "header": "🐛 Fixes" }
Expand Down Expand Up @@ -85,11 +84,11 @@ jobs:
sed -i "s#$author_info#$username#g" "commits.md"
done < commits.md
- name: Parse commit messages and categorize
id: parse_commits
run: |
declare -A commits_map;
while IFS= read -r line; do
first_lower=$(echo "$line" | awk '{print $1}' | tr '[:upper:]' '[:lower:]')
scope=$(echo "$line" | cut -d' ' -f1)
Expand All @@ -109,12 +108,13 @@ jobs:
[[ $added == false ]] && commits_map["more"]+=$parsed_commit
done < commits.md
jq -n '{}' commitsJson > tempJson && mv tempJson commitsJson
for key in "${!commits_map[@]}"; do
echo "$key=${commits_map[$key]}" >> $GITHUB_OUTPUT
jq --arg key "$key" --arg value "${commits_map[$key]}" \
'. + {($key): $value}' commitsJson > tempJson && mv tempJson commitsJson
done
- name: Create Release Notes
id: release-notes
run: |
Expand All @@ -126,18 +126,20 @@ jobs:
[[ ! "$section" =~ [^[:space:]] ]] && continue
section_commits=$(echo '${{ toJson(steps.parse_commits.outputs) }}' | jq -r ".$section")
section_commits=$(jq -r --arg k "$section" '.[$k]' commitsJson)
if [ -n "$section_commits" ] && [ "$section_commits" != null ]; then
notes+="### $header \n $section_commits \n"
fi
done < <(echo '${{env.release_commits}}')
echo -e $notes > commits.md
set -f; echo -e $notes > commits.md; set +f
- name: Remove old Draft
id: remove_drafts
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release delete "Draft Latest version"

Expand Down

0 comments on commit fde626a

Please sign in to comment.