-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfetch-versioned-release-notes.sh
More file actions
executable file
·72 lines (52 loc) · 2.4 KB
/
fetch-versioned-release-notes.sh
File metadata and controls
executable file
·72 lines (52 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# To run: chmod +x fetch-versioned-release-notes.sh && ./fetch-versioned-release-notes.sh
# Dokumentation https://wiki.gecko.hs-heilbronn.de/doc/dokumentation-release-notes-script-45Ex3hoxjB
# GitHub repository details
REPO_OWNER="datasharingframework"
REPO_NAME="dsf"
# Output base directory (this will hold the versioned folders)
OUTPUT_BASE_DIR="../../operations"
# Define the range of versions
VERSIONS=("v1.0.0" "v1.1.0" "v1.2.0" "v1.3.0" "v1.3.1" "v1.3.2" "v1.4.0" "v1.5.0" "v1.5.1" "v1.5.2" "v1.6.0" "v1.7.0" "v1.7.1" "v1.8.0" "v1.9.0" "v2.0.0" "v2.0.1" "v2.0.2" "v2.1.0")
# Fetch all release details
echo "Fetching all releases..."
RELEASES=$(curl -s https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases)
# Loop through each version in the version list
for VERSION in "${VERSIONS[@]}"; do
VERSION_FOUND=$(echo "$RELEASES" | jq -r ".[] | select(.tag_name == \"$VERSION\")")
if [ ! -z "$VERSION_FOUND" ]; then
VERSION_DIR="$OUTPUT_BASE_DIR/$VERSION"
if [ ! -d "$VERSION_DIR" ]; then
echo "Directory $VERSION_DIR does not exist. Skipping $VERSION."
continue
fi
OUTPUT_FILE="$VERSION_DIR/release-notes.md"
# Write frontmatter at the top of the Markdown file
cat <<EOF > "$OUTPUT_FILE"
---
title: Release Notes ($VERSION)
icon: note
---
## [Release Notes for $VERSION](https://github.com/$REPO_OWNER/$REPO_NAME/releases/tag/$VERSION)
::: tip Release Notes
You can access all release notes on our [GitHub](https://github.com/datasharingframework/dsf/releases).
:::
EOF
echo "$RELEASES" | jq -r ".[] | select(.tag_name == \"$VERSION\") | @base64" | while read -r RELEASE; do
RELEASE_JSON=$(echo "$RELEASE" | base64 --decode)
RELEASE_BODY=$(echo "$RELEASE_JSON" | jq -r '.body')
RELEASE_NAME=$(echo "$RELEASE_JSON" | jq -r '.name')
# Convert #issue_number to GitHub issue link
RELEASE_BODY=$(echo "$RELEASE_BODY" | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/datasharingframework\/dsf\/issues\/\1)/g')
# Convert @username to GitHub user link
RELEASE_BODY=$(echo "$RELEASE_BODY" | sed -E 's/@([a-zA-Z0-9_-]+)/[@\1](https:\/\/github.com\/\1)/g')
echo "### $RELEASE_NAME" >> "$OUTPUT_FILE"
echo "$RELEASE_BODY" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
done
echo "Release notes for version $VERSION saved to $OUTPUT_FILE"
else
echo "No release found for version $VERSION"
fi
done
echo "Process completed."