Format release notes as a categorized changelog based on PR labels
CI / build-and-scan (push) Successful in 1m0s
CI / build-and-scan (push) Successful in 1m0s
This commit is contained in:
+44
-3
@@ -121,11 +121,52 @@ jobs:
|
|||||||
docker push "$IMAGE:$MINOR_TAG"
|
docker push "$IMAGE:$MINOR_TAG"
|
||||||
docker push "$IMAGE:$VERSION"
|
docker push "$IMAGE:$VERSION"
|
||||||
|
|
||||||
CHANGED_LIST=$(echo "$CHANGED" | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g')
|
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
|
||||||
BODY="Automated release. Image: ${IMAGE}:${VERSION}. Changed files: ${CHANGED_LIST}"
|
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#')
|
||||||
|
|
||||||
|
CATEGORY="🔧 Maintenance"
|
||||||
|
CHANGE_TITLE="$TRIGGER_MSG"
|
||||||
|
|
||||||
|
if [ -n "$PR_NUM" ]; then
|
||||||
|
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
|
||||||
|
"https://git.djeex.fr/api/v1/repos/Djeex/adguard-cidre/pulls/$PR_NUM")
|
||||||
|
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty')
|
||||||
|
LABELS=$(echo "$PR_JSON" | jq -r '.labels[].name' 2>/dev/null)
|
||||||
|
|
||||||
|
[ -n "$PR_TITLE" ] && CHANGE_TITLE="$PR_TITLE"
|
||||||
|
|
||||||
|
if echo "$LABELS" | grep -qx 'bug'; then
|
||||||
|
CATEGORY="⚠️ Hotfix"
|
||||||
|
elif echo "$LABELS" | grep -qx 'major'; then
|
||||||
|
CATEGORY="💥 Breaking change"
|
||||||
|
elif echo "$LABELS" | grep -qx 'minor'; then
|
||||||
|
CATEGORY="✨ Update"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
CHANGED_LIST=$(echo "$CHANGED" | sed 's/^/- /')
|
||||||
|
|
||||||
|
BODY=$(cat <<EOF
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### ${CATEGORY}
|
||||||
|
${CHANGE_TITLE}
|
||||||
|
|
||||||
|
**Image:** \`${IMAGE}:${VERSION}\`
|
||||||
|
|
||||||
|
**Changed files:**
|
||||||
|
${CHANGED_LIST}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
JSON_PAYLOAD=$(jq -n \
|
||||||
|
--arg tag "$VERSION" \
|
||||||
|
--arg name "$VERSION" \
|
||||||
|
--arg body "$BODY" \
|
||||||
|
'{tag_name: $tag, name: $name, target_commitish: "main", body: $body}')
|
||||||
|
|
||||||
curl -s -o /dev/null -w "Release API response: %{http_code}\n" -X POST \
|
curl -s -o /dev/null -w "Release API response: %{http_code}\n" -X POST \
|
||||||
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\": \"${VERSION}\", \"name\": \"${VERSION}\", \"target_commitish\": \"main\", \"body\": \"${BODY}\"}" \
|
-d "$JSON_PAYLOAD" \
|
||||||
"https://git.djeex.fr/api/v1/repos/Djeex/adguard-cidre/releases"
|
"https://git.djeex.fr/api/v1/repos/Djeex/adguard-cidre/releases"
|
||||||
Reference in New Issue
Block a user