mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 04:14:57 +00:00
fix(ci): close dev-released issues on stable release (#1396)
This commit is contained in:
1 parent
aecd8beb54
commit
52a427a7a3
4 files changed
+332
-71
No files matched your search
@@ -102,74 +102,4 @@ jobs:
|
||||
if: success() && steps.release.outputs.released == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
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 "")
|
||||
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 '#' || 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 '#' || 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}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for NUM in $RELEASE_ISSUES; do
|
||||
echo "Cleaning release state on issue #$NUM"
|
||||
gh issue edit "$NUM" \
|
||||
--remove-label "released-dev" \
|
||||
--remove-label "pending-release" \
|
||||
--repo "${{ github.repository }}" 2>/dev/null || true
|
||||
|
||||
HAS_RELEASED=$(gh issue view "$NUM" --repo "${{ github.repository }}" --json labels --jq '[.labels[].name | select(. == "released")] | length' 2>/dev/null || echo "0")
|
||||
if [[ "$HAS_RELEASED" -gt 0 ]] && printf '%s\n' "$RESOLVED_ISSUES" | grep -qx "$NUM"; then
|
||||
gh issue close "$NUM" \
|
||||
--comment "[bot] Closing issue because this fix/feature is now in stable release (@latest)." \
|
||||
--repo "${{ github.repository }}" || true
|
||||
fi
|
||||
done
|
||||
run: node scripts/github/stable-release-issue-cleanup.mjs
|
||||
Reference in new issue
Block a user