-
Notifications
You must be signed in to change notification settings - Fork 16
130 lines (115 loc) · 4.27 KB
/
release-docs.yml
File metadata and controls
130 lines (115 loc) · 4.27 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: 📝 Build and Deploy Release Docs
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to deploy (e.g., v1.2.0)"
required: true
type: string
permissions:
contents: write
jobs:
build-and-deploy-release-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.release.tag_name || inputs.version }}
- name: Fetch version selector scripts from develop 📝
run: |
# Fetch and checkout the scripts from develop branch
git fetch origin develop
mkdir -p .github/scripts
git checkout origin/develop -- .github/scripts/inject-version-selector.sh .github/scripts/version-selector.html || echo "Scripts not found in develop, will skip version selector"
- name: Install Doxygen
uses: ssciwr/doxygen-install@329d88f5a303066a5bd006db7516b1925b86350e # v2.0.1
with:
version: "1.15.0"
- name: Install and Build 🔧
run: |
cmake -S . -B build -DBUILD_QDMI_DOCS=ON
cmake --build build --target qdmi-docs
mv build/docs/html/ static
- name: Set version variable
id: version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ inputs.version }}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Inject version selector
run: |
if [ -f .github/scripts/inject-version-selector.sh ]; then
chmod +x .github/scripts/inject-version-selector.sh
.github/scripts/inject-version-selector.sh static
else
echo "Version selector script not found, skipping..."
fi
- name: Deploy versioned docs 🚀
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
with:
folder: static
target-folder: ${{ steps.version.outputs.version }}
clean: false
force: false
- name: Checkout gh-pages branch 🛎️
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: gh-pages
path: gh-pages
persist-credentials: true
fetch-depth: 0
- name: Update versions.json and redirect 🔗
working-directory: gh-pages
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
# Get all version directories (excluding 'latest' and 'pr-preview')
VERSIONS=$(find . -maxdepth 1 -type d -name 'v*' | sed 's|./||' | sort -V -r)
# Create versions.json
cat > versions.json << EOF
{
"stable": "${VERSION}",
"releases": [
EOF
# Add versions to JSON
if [ -n "$VERSIONS" ]; then
FIRST=true
for v in $VERSIONS; do
if [ "$FIRST" = true ]; then
echo " \"$v\"" >> versions.json
FIRST=false
else
echo " ,\"$v\"" >> versions.json
fi
done
fi
cat >> versions.json << EOF
]
}
EOF
# Create an index.html that redirects to the latest stable version
cat > index.html << EOF
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting to latest stable documentation</title>
<meta http-equiv="refresh" content="0; url=${VERSION}/">
<link rel="canonical" href="${VERSION}/">
</head>
<body>
<p>Redirecting to <a href="${VERSION}/">latest stable documentation (${VERSION})</a>...</p>
</body>
</html>
EOF
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add versions.json index.html
git commit -m "Update versions.json and stable docs redirect to ${VERSION}" || echo "No changes to commit"
git push origin gh-pages