mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 14:15:56 +00:00
fix(ci): close release automation edge cases
This commit is contained in:
1 parent
5616c68471
commit
e06e13ad0d
4 files changed
+102
-36
No files matched your search
@@ -93,12 +93,54 @@ jobs:
|
||||
run: |
|
||||
VERSION=$(jq -r '.version' package.json)
|
||||
RELEASE_BODY=$(gh release view "v${VERSION}" --repo "${{ github.repository }}" --json body --jq '.body' 2>/dev/null || echo "")
|
||||
RELEASE_ISSUES=$(printf '%s\n' "$RELEASE_BODY" | \
|
||||
PREVIOUS_STABLE_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]" --sort=-v:refname | \
|
||||
grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \
|
||||
grep -vx "v${VERSION}" | head -1 || echo "")
|
||||
RANGE="${PREVIOUS_STABLE_TAG:+${PREVIOUS_STABLE_TAG}..HEAD~1}"
|
||||
if [[ -z "$RANGE" ]]; then
|
||||
RANGE="HEAD~50..HEAD~1"
|
||||
fi
|
||||
|
||||
COMMIT_TEXT=$(git log $RANGE --pretty=format:"%s%n%b" 2>/dev/null || true)
|
||||
PR_CANDIDATES=$(printf '%s\n' "$COMMIT_TEXT" | \
|
||||
grep -oE "Merge pull request #[0-9]+|\\(#[0-9]+\\)" | \
|
||||
grep -oE "[0-9]+" | sort -u || true)
|
||||
|
||||
PR_TEXT=""
|
||||
for PR_NUM in $PR_CANDIDATES; do
|
||||
DETAILS=$(gh pr view "$PR_NUM" --repo "${{ github.repository }}" --json title,body --jq '.title + "\n" + (.body // "")' 2>/dev/null || true)
|
||||
if [[ -n "$DETAILS" ]]; then
|
||||
PR_TEXT="${PR_TEXT}"$'\n'"${DETAILS}"
|
||||
fi
|
||||
done
|
||||
|
||||
RELEASE_ISSUES_FROM_BODY=$(printf '%s\n' "$RELEASE_BODY" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves|refs?)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' | sort -u || true)
|
||||
RESOLVED_ISSUES=$(printf '%s\n' "$RELEASE_BODY" | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RELEASE_ISSUES_FROM_COMMITS=$(printf '%s\n' "$COMMIT_TEXT" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves|refs?)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RELEASE_ISSUES_FROM_PRS=$(printf '%s\n' "$PR_TEXT" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves|refs?)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RELEASE_ISSUES=$(printf '%s\n%s\n%s\n' \
|
||||
"$RELEASE_ISSUES_FROM_BODY" \
|
||||
"$RELEASE_ISSUES_FROM_COMMITS" \
|
||||
"$RELEASE_ISSUES_FROM_PRS" | sort -u || true)
|
||||
|
||||
RESOLVED_ISSUES_FROM_BODY=$(printf '%s\n' "$RELEASE_BODY" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' | sort -u || true)
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RESOLVED_ISSUES_FROM_COMMITS=$(printf '%s\n' "$COMMIT_TEXT" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RESOLVED_ISSUES_FROM_PRS=$(printf '%s\n' "$PR_TEXT" | \
|
||||
perl -ne 'if (/(fixes|closes|resolves)(.*)/i) { print "$2\n"; }' | \
|
||||
grep -oE '#[0-9]+' | tr -d '#' || true)
|
||||
RESOLVED_ISSUES=$(printf '%s\n%s\n%s\n' \
|
||||
"$RESOLVED_ISSUES_FROM_BODY" \
|
||||
"$RESOLVED_ISSUES_FROM_COMMITS" \
|
||||
"$RESOLVED_ISSUES_FROM_PRS" | sort -u || true)
|
||||
|
||||
if [[ -z "$RELEASE_ISSUES" ]]; then
|
||||
echo "No release-scoped issues found for v${VERSION}"
|
||||
|
||||
Reference in new issue
Block a user