Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update generate-release-notes.sh with reporter attribution
Leendert de Borstae19a50e7f76
diff --git a/scripts/generate-release-notes.sh b/scripts/generate-release-notes.shindex 2da73370a..f1fda1c0d 100755--- a/scripts/generate-release-notes.sh+++ b/scripts/generate-release-notes.sh@@ -5,6 +5,7 @@# ./generate-release-notes.sh --new NEW_TAG --previous PREVIOUS_TAG# ./generate-release-notes.sh --new NEW_TAG --prev PREVIOUS_TAG# ./generate-release-notes.sh (interactive mode)+# ./generate-release-notes.sh --no-credits (skip adding reporter attribution to PR lines)# Color codesBLUE='\033[0;34m'@@ -14,9 +15,14 @@ RED='\033[0;31m'CYAN='\033[0;36m'RESET='\033[0m'+# Repository the release notes are generated for+REPO_OWNER="aliasvault"+REPO_NAME="aliasvault"+# Parse command-line argumentsNEW_TAG=""PREVIOUS_TAG=""+ADD_CREDITS=truewhile [[ $# -gt 0 ]]; docase $1 in@@ -28,9 +34,13 @@ while [[ $# -gt 0 ]]; doPREVIOUS_TAG="$2"shift 2;;+ --no-credits)+ ADD_CREDITS=false+ shift+ ;;*)echo "Unknown option: $1"- echo "Usage: ./generate-release-notes.sh --new NEW_TAG --previous PREVIOUS_TAG"+ echo "Usage: ./generate-release-notes.sh --new NEW_TAG --previous PREVIOUS_TAG [--no-credits]"echo " or: ./generate-release-notes.sh (interactive mode)"exit 1;;@@ -73,13 +83,123 @@ elseTARGET_BRANCH="main"fi+# Query a batch of PRs for the authors of the issues they close. Prints one+# "<pr number><tab><space separated logins>" line per PR that has reporters.+query_reporters() {+ local fields="$1"+ local query response++ query="query { repository(owner: \"$REPO_OWNER\", name: \"$REPO_NAME\") {$fields+ } }"++ # gh exits non-zero on partial GraphQL errors+ response=$(gh api graphql -f query="$query" 2>/dev/null)+ [ -z "$response" ] && return 0++ printf '%s' "$response" | jq -r '+ (.data.repository // {})+ | to_entries[]+ | .value+ | select(. != null)+ | . as $pr+ | [ .closingIssuesReferences.nodes[]? | .author.login? // empty ]+ | map(select(. != ($pr.author.login // "")))+ | unique+ | select(length > 0)+ | "\($pr.number)\t\(join(" "))"+ ' 2>/dev/null+}++# Append "(reported by @user)" to every PR line in the release notes, based on the issues each PR closes.+add_reporter_credits() {+ local notes="$1"+ local pr_numbers map_file fields count pr++ pr_numbers=$(printf '%s\n' "$notes" | grep -oE '/pull/[0-9]+' | grep -oE '[0-9]+' | sort -un)+ if [ -z "$pr_numbers" ]; then+ printf '%s' "$notes"+ return 0+ fi++ map_file=$(mktemp "${TMPDIR:-/tmp}/release-reporters.XXXXXX")+ fields=""+ count=0++ for pr in $pr_numbers; do+ fields="$fields+ p${pr}: pullRequest(number: ${pr}) { number author { login } closingIssuesReferences(first: 10) { nodes { author { login } } } }"+ count=$((count + 1))++ # Keep each GraphQL query within a sane size+ if [ "$count" -ge 50 ]; then+ query_reporters "$fields" >> "$map_file"+ fields=""+ count=0+ fi+ done++ if [ -n "$fields" ]; then+ query_reporters "$fields" >> "$map_file"+ fi++ printf '%s\n' "$notes" | awk -v mapfile="$map_file" '+ BEGIN {+ FS = "\t"+ while ((getline line < mapfile) > 0) {+ split(line, parts, "\t")+ if (parts[1] != "") reporters[parts[1]] = parts[2]+ }+ close(mapfile)+ }+ # Skip the "New Contributors" section+ /^#+ New Contributors/ { skip = 1 }+ {+ if (!skip && match($0, /\/pull\/[0-9]+[ \t]*$/)) {+ num = substr($0, RSTART + 6, RLENGTH - 6)+ gsub(/[ \t]/, "", num)+ if (num in reporters) {+ sub(/[ \t]+$/, "")+ total = split(reporters[num], logins, " ")+ credit = "@" logins[1]+ for (i = 2; i <= total; i++) {+ credit = credit (i == total ? " and @" : ", @") logins[i]+ }+ $0 = $0 " (reported by " credit ")"+ }+ }+ }+ '++ rm -f "$map_file"+}+# Generate release notes-RELEASE_NOTES=$(gh api repos/aliasvault/aliasvault/releases/generate-notes \+RELEASE_NOTES=$(gh api "repos/$REPO_OWNER/$REPO_NAME/releases/generate-notes" \-f tag_name="$NEW_TAG" \-f previous_tag_name="$PREVIOUS_TAG" \-f target_commitish="$TARGET_BRANCH" \--jq .body)+if [ -z "$RELEASE_NOTES" ]; then+ echo -e "${RED}Error: Failed to generate release notes${RESET}"+ exit 1+fi++# Enrich the notes with reporter attribution from linked issues+if [ "$ADD_CREDITS" = true ]; then+ echo -e "${BLUE}Looking up issue reporters for linked pull requests...${RESET}"+ ENRICHED_NOTES=$(add_reporter_credits "$RELEASE_NOTES")++ if [ -n "$ENRICHED_NOTES" ]; then+ RELEASE_NOTES="$ENRICHED_NOTES"+ CREDITS_ADDED=$(printf '%s\n' "$RELEASE_NOTES" | grep -c "(reported by " | tr -d ' ')+ echo -e "${GREEN}Added reporter attribution to $CREDITS_ADDED pull request(s)${RESET}"+ else+ echo -e "${YELLOW}Warning: Could not resolve issue reporters, using notes as-is${RESET}"+ fi+fi+# Display the generated notes with visual separatorecho -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"echo -e "${CYAN}Generated Release Notes:${RESET}"