Skip to content

Commit a9b7489

Browse files
committed
upgrade tag github action - contributors list
1 parent dbe841c commit a9b7489

1 file changed

Lines changed: 74 additions & 2 deletions

File tree

.github/workflows/tag_release.yml

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,79 @@ jobs:
5858
id: extract-release-notes
5959
uses: ffurrer2/extract-release-notes@v1
6060

61+
- name: Extract contributors from commits
62+
id: contributors
63+
env:
64+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
# Trouver le tag précédent
67+
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -A1 "^${{ env.release_tag }}$" | tail -n 1)
68+
69+
if [ -z "$PREV_TAG" ] || [ "$PREV_TAG" = "${{ env.release_tag }}" ]; then
70+
echo "Pas de tag précédent, analyse de tout l'historique."
71+
RANGE="${{ env.release_tag }}"
72+
else
73+
echo "Analyse des commits entre $PREV_TAG et ${{ env.release_tag }}"
74+
RANGE="$PREV_TAG..${{ env.release_tag }}"
75+
fi
76+
77+
# Récupérer les SHA des commits de la plage
78+
COMMIT_SHAS=$(git log "$RANGE" --format="%H")
79+
80+
CONTRIBUTORS_MD=""
81+
declare -A SEEN_LOGINS
82+
83+
for SHA in $COMMIT_SHAS; do
84+
RESPONSE=$(gh api repos/${{ github.repository }}/commits/$SHA 2>/dev/null)
85+
LOGIN=$(echo "$RESPONSE" | python3 -c "import sys,json; d=json.load(sys.stdin); a=d.get('author'); print(a['login'] if a else '')" 2>/dev/null)
86+
AVATAR=$(echo "$RESPONSE" | python3 -c "import sys,json; d=json.load(sys.stdin); a=d.get('author'); print(a['avatar_url'] if a else '')" 2>/dev/null)
87+
88+
# Ignorer les bots et les doublons
89+
if [ -z "$LOGIN" ] || [[ "$LOGIN" == *"[bot]"* ]] || [ "${SEEN_LOGINS[$LOGIN]+_}" ]; then
90+
continue
91+
fi
92+
SEEN_LOGINS[$LOGIN]=1
93+
94+
CONTRIBUTORS_MD="${CONTRIBUTORS_MD}- [![${LOGIN}](${AVATAR}&s=20)](https://github.com/${LOGIN}) [@${LOGIN}](https://github.com/${LOGIN})\n"
95+
done
96+
97+
if [ -z "$CONTRIBUTORS_MD" ]; then
98+
CONTRIBUTORS_MD=""
99+
fi
100+
101+
{
102+
echo "section<<EOF"
103+
printf "%b\n" "$CONTRIBUTORS_MD"
104+
echo "EOF"
105+
} >> $GITHUB_OUTPUT
106+
107+
- name: Build release body
108+
id: release_body
109+
env:
110+
RELEASE_NOTES: ${{ steps.extract-release-notes.outputs.release_notes }}
111+
CONTRIBUTORS_SECTION: ${{ steps.contributors.outputs.section }}
112+
run: |
113+
python3 - <<'PYEOF'
114+
import os
115+
116+
release_notes = os.environ.get("RELEASE_NOTES", "").strip()
117+
contributors = os.environ.get("CONTRIBUTORS_SECTION", "").strip()
118+
119+
parts = [release_notes]
120+
if contributors:
121+
parts.append("## 👥 Contributors\n\n" + contributors)
122+
123+
body = "\n\n".join(parts)
124+
125+
with open("/tmp/release_body.md", "w") as f:
126+
f.write(body)
127+
128+
print("Corps de la release généré :")
129+
print(body)
130+
PYEOF
131+
132+
echo "body_path=/tmp/release_body.md" >> $GITHUB_OUTPUT
133+
61134
- name: Build project
62135
run: mvn -e -B clean package -DskipTests -Drevision=${{ env.release_tag }}
63136

@@ -77,8 +150,7 @@ jobs:
77150
with:
78151
tag_name: ${{ env.release_tag }}
79152
name: Release ${{ env.release_tag }}
80-
body: ${{ steps.extract-release-notes.outputs.release_notes }}
81-
generate_release_notes: true
153+
body_path: ${{ steps.release_body.outputs.body_path }}
82154
draft: false
83155
prerelease: false
84156
files: ${{ env.jar_path }}

0 commit comments

Comments
 (0)