Skip to content

Commit 150bb60

Browse files
committed
ci: streamline documentation build process and enhance release information retrieval
1 parent d7fccdb commit 150bb60

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

.github/workflows/pages.yml

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,49 +37,43 @@ jobs:
3737

3838
- name: Build documentation
3939
run: |
40-
# Create all required directories first
40+
# Create directories
4141
mkdir -p docs/{guide,downloads}
4242
43-
# Create index from README
43+
# Copy docs
4444
cp README.md docs/index.md || echo "# NetworkMonitor" > docs/index.md
45-
46-
# Copy or create developer guide
4745
cp DEVELOPER.md docs/guide/developer.md || echo "# Developer Guide" > docs/guide/developer.md
4846
49-
# Get version info
50-
if [ -n "${{ github.event.release.tag_name }}" ]; then
51-
VERSION="${{ github.event.release.tag_name }}"
52-
DATE=$(date -d "${{ github.event.release.published_at }}" +%Y-%m-%d)
53-
else
54-
# Fetch latest release info
55-
LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \
56-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
57-
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
58-
VERSION=$(echo "$LATEST_RELEASE" | jq -r .tag_name)
59-
DATE=$(echo "$LATEST_RELEASE" | jq -r .published_at | cut -d'T' -f1)
60-
fi
47+
# Get release info using GitHub API with authentication
48+
LATEST_RELEASE=$(curl -s \
49+
-H "Accept: application/vnd.github+json" \
50+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
51+
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
6152
62-
cat > docs/downloads/index.md << 'EOL'
63-
# Downloads
53+
# Extract version and date, fallback to defaults if not found
54+
VERSION=$(echo "$LATEST_RELEASE" | jq -r '.tag_name // "0.1.0"' | sed 's/^v//')
55+
DATE=$(echo "$LATEST_RELEASE" | jq -r '.published_at // ""' | cut -d'T' -f1)
6456
65-
## Latest Release
66-
EOL
57+
if [ -z "$DATE" ]; then
58+
DATE=$(date +%Y-%m-%d)
59+
fi
6760
68-
cat >> docs/downloads/index.md << EOL
61+
cat > docs/downloads/index.md << EOL
62+
# Downloads
6963
70-
Version: ${VERSION} (Released: ${DATE})
64+
## Latest Release (v${VERSION})
7165
72-
### Download Links
66+
Released: ${DATE}
7367
74-
#### Windows
75-
- [NetworkMonitor Setup (Installer)](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Windows-Setup-${VERSION#v}.zip)
76-
- [NetworkMonitor Portable](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Windows-${VERSION#v}.zip)
68+
### Windows
69+
- [NetworkMonitor Setup (Installer)](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Windows.zip)
70+
- [NetworkMonitor Portable](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Windows-Setup.zip)
7771
78-
#### Linux
79-
- [NetworkMonitor for Linux](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Linux-${VERSION#v}.tar.gz)
72+
### Linux
73+
- [NetworkMonitor for Linux](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-Linux.tar.gz)
8074
81-
#### macOS
82-
- [NetworkMonitor for macOS](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-macOS-${VERSION#v}.zip)
75+
### macOS
76+
- [NetworkMonitor for macOS](https://github.com/${{ github.repository }}/releases/latest/download/NetworkMonitor-macOS.zip)
8377
8478
## System Requirements
8579

0 commit comments

Comments
 (0)