Skip to content

Commit 7b4b057

Browse files
Merge pull request #16 from FrozenLemonTee/pre-0.1.5
Fix deploy doc workflow logic
2 parents bbcc714 + 0028a92 commit 7b4b057

7 files changed

Lines changed: 150 additions & 41 deletions

File tree

.github/workflows/basic-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ name: Test Branch CI - Basic Tests
55
on:
66
push:
77
branches: [ test ]
8-
pull_request:
9-
branches: [ test ]
108

119
jobs:
1210
build-and-test:

.github/workflows/deploy-docs-latest.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ jobs:
5656
git clone -b master https://${{ secrets.GH_PAT }}@github.com/FrozenLemonTee/original_docs.git deploy-repo
5757
cd deploy-repo
5858
59-
# Clean up old files (keep the .git directory)
60-
find . -maxdepth 1 ! -name '.git' ! -name '.' ! -name 'CNAME' -exec rm -rf {} + 2>/dev/null || true
61-
62-
# Copy the new document to directory latest
59+
# Only update latest directory
60+
rm -rf latest
6361
mkdir -p latest
6462
cp -r ../../original_docs/docs/html/* latest/
6563

.github/workflows/deploy-docs-stable.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ name: Deploy Documentation - Stable
55
on:
66
push:
77
branches: [ master ]
8-
tags: [ 'v*' ]
98

109
jobs:
1110
build-and-deploy:
@@ -17,19 +16,6 @@ jobs:
1716
with:
1817
fetch-depth: 0
1918

20-
- name: Determine documentation version
21-
id: version
22-
run: |
23-
if [[ $GITHUB_REF == refs/tags/* ]]; then
24-
TAG=${GITHUB_REF#refs/tags/}
25-
echo "docs-version=$TAG" >> $GITHUB_OUTPUT
26-
echo "is-tag=true" >> $GITHUB_OUTPUT
27-
else
28-
echo "docs-version=stable" >> $GITHUB_OUTPUT
29-
echo "is-tag=false" >> $GITHUB_OUTPUT
30-
fi
31-
echo "Version: ${{ steps.version.outputs.docs-version }}"
32-
3319
- name: Install dependencies
3420
run: |
3521
sudo apt-get update
@@ -58,8 +44,8 @@ jobs:
5844
echo '</head>' >> ../original_docs/docs/html/version.html
5945
echo '<body>' >> ../original_docs/docs/html/version.html
6046
echo ' <h1>Documentation Version</h1>' >> ../original_docs/docs/html/version.html
61-
echo " <p>Version: ${{ steps.version.outputs.docs-version }}</p>" >> ../original_docs/docs/html/version.html
62-
echo ' <p>Branch: master</p>' >> ../original_docs/docs/html/version.html
47+
echo ' <p>Version: stable</p>' >> ../original_docs/docs/html/version.html
48+
echo ' <p>Branch: master</p>' >> index.html
6349
echo " <p>Build Date: $(date -u)</p>" >> ../original_docs/docs/html/version.html
6450
echo " <p>Commit: ${{ github.sha }}</p>" >> ../original_docs/docs/html/version.html
6551
echo '</body>' >> ../original_docs/docs/html/version.html
@@ -78,20 +64,10 @@ jobs:
7864
7965
cd deploy-repo
8066
81-
# Clean up old files (keep the .git directory)
82-
find . -maxdepth 1 ! -name '.git' ! -name '.' ! -name 'CNAME' -exec rm -rf {} + 2>/dev/null || true
83-
84-
if [[ "${{ steps.version.outputs.is-tag }}" == "true" ]]; then
85-
# Tag Version: Create Version Directory
86-
mkdir -p versions/${{ steps.version.outputs.docs-version }}
87-
cp -r ../../original_docs/docs/html/* versions/${{ steps.version.outputs.docs-version }}/
88-
echo "Deployed tag version: ${{ steps.version.outputs.docs-version }}"
89-
else
90-
# Branch master: update stable version
91-
mkdir -p stable
92-
cp -r ../../original_docs/docs/html/* stable/
93-
echo "Deployed stable version from master"
94-
fi
67+
# Only update stable directory
68+
rm -rf stable
69+
mkdir -p stable
70+
cp -r ../../original_docs/docs/html/* stable/
9571
9672
# Create index.html redirection
9773
echo '<!DOCTYPE html>' > index.html
@@ -117,5 +93,5 @@ jobs:
11793
else
11894
git commit -m "Deploy ${{ steps.version.outputs.docs-version }} documentation from ${{ github.sha }}"
11995
git push origin master
120-
echo "Documentation deployed successfully"
96+
echo "✅ Stable documentation deployed successfully"
12197
fi
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# .github/workflows/deploy-docs-tags.yml
2+
3+
name: Deploy Documentation - Tag Versions
4+
5+
on:
6+
push:
7+
tags:
8+
- 'v*.*.*'
9+
10+
jobs:
11+
build-and-deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Extract version from tag
21+
id: version
22+
run: |
23+
VERSION=${GITHUB_REF#refs/tags/v}
24+
echo "docs-version=$VERSION" >> $GITHUB_OUTPUT
25+
echo "Detected version: $VERSION"
26+
27+
- name: Install dependencies
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y doxygen graphviz plantuml
31+
32+
- name: Build documentation
33+
run: |
34+
# Create the necessary directory structure
35+
mkdir -p ../original_docs
36+
37+
# Run doxygen
38+
doxygen Doxyfile
39+
40+
# Check whether the document was generated successfully
41+
if [ ! -d "../original_docs/docs/html" ]; then
42+
echo "Error: Documentation was not generated in expected location"
43+
ls -la ../original_docs/docs/ || echo "Docs directory not found"
44+
exit 1
45+
fi
46+
47+
# Create version information file
48+
echo '<!DOCTYPE html>' > ../original_docs/docs/html/version.html
49+
echo '<html>' >> ../original_docs/docs/html/version.html
50+
echo '<head>' >> ../original_docs/docs/html/version.html
51+
echo ' <title>Version Info</title>' >> ../original_docs/docs/html/version.html
52+
echo '</head>' >> ../original_docs/docs/html/version.html
53+
echo '<body>' >> ../original_docs/docs/html/version.html
54+
echo ' <h1>Documentation Version</h1>' >> ../original_docs/docs/html/version.html
55+
echo " <p>Version: ${{ steps.version.outputs.docs-version }}</p>" >> ../original_docs/docs/html/version.html
56+
echo " <p>Tag: ${{ github.ref_name }}</p>" >> ../original_docs/docs/html/version.html
57+
echo " <p>Build Date: $(date -u)</p>" >> ../original_docs/docs/html/version.html
58+
echo " <p>Commit: ${{ github.sha }}</p>" >> ../original_docs/docs/html/version.html
59+
echo '</body>' >> ../original_docs/docs/html/version.html
60+
echo '</html>' >> ../original_docs/docs/html/version.html
61+
62+
- name: Deploy to original_docs repository
63+
env:
64+
GH_PAT: ${{ secrets.GH_PAT }}
65+
run: |
66+
# Configure git
67+
git config --global user.name "github-actions[bot]"
68+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
70+
# Clone document repository
71+
git clone -b master https://${{ secrets.GH_PAT }}@github.com/FrozenLemonTee/original_docs.git deploy-repo
72+
cd deploy-repo
73+
74+
# Create versions directory if it doesn't exist
75+
mkdir -p versions
76+
77+
# Update specific version directory
78+
VERSION_DIR="versions/${{ steps.version.outputs.docs-version }}"
79+
rm -rf "$VERSION_DIR"
80+
mkdir -p "$VERSION_DIR"
81+
cp -r ../../original_docs/docs/html/* "$VERSION_DIR"/
82+
83+
# Update main index.html to include this version
84+
echo '<!DOCTYPE html>' > index.html
85+
echo '<html>' >> index.html
86+
echo '<head>' >> index.html
87+
echo ' <meta http-equiv="refresh" content="0; url=stable/index.html">' >> index.html
88+
echo '</head>' >> index.html
89+
echo '<body>' >> index.html
90+
echo ' <p>Redirecting to <a href="stable/index.html">stable documentation</a>...</p>' >> index.html
91+
echo ' <p>Available versions:</p>' >> index.html
92+
echo ' <ul>' >> index.html
93+
echo ' <li><a href="stable/index.html">Stable (master branch)</a></li>' >> index.html
94+
echo ' <li><a href="latest/index.html">Latest (test branch)</a></li>' >> index.html
95+
echo ' <li><a href="versions/">Tag versions</a></li>' >> index.html
96+
echo ' </ul>' >> index.html
97+
echo ' <p>Recent tag versions:</p>' >> index.html
98+
echo ' <ul>' >> index.html
99+
100+
# List recent tag versions (last 5)
101+
for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -5); do
102+
echo " <li><a href=\"versions/$dir/index.html\">Version $dir</a></li>" >> index.html
103+
done
104+
105+
echo ' </ul>' >> index.html
106+
echo '</body>' >> index.html
107+
echo '</html>' >> index.html
108+
109+
# Create versions/index.html to list all available versions
110+
echo '<!DOCTYPE html>' > versions/index.html
111+
echo '<html>' >> versions/index.html
112+
echo '<head>' >> versions/index.html
113+
echo ' <title>Versioned Documentation</title>' >> versions/index.html
114+
echo '</head>' >> versions/index.html
115+
echo '<body>' >> versions/index.html
116+
echo ' <h1>Versioned Documentation</h1>' >> versions/index.html
117+
echo ' <p>Select a version:</p>' >> versions/index.html
118+
echo ' <ul>' >> versions/index.html
119+
120+
# List all versions in reverse order (newest first)
121+
for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r); do
122+
echo " <li><a href=\"$dir/index.html\">Version $dir</a></li>" >> versions/index.html
123+
done
124+
125+
echo ' </ul>' >> versions/index.html
126+
echo ' <p><a href="../stable/index.html">Stable (master branch)</a></p>' >> versions/index.html
127+
echo ' <p><a href="../latest/index.html">Latest (test branch)</a></p>' >> versions/index.html
128+
echo '</body>' >> versions/index.html
129+
echo '</html>' >> versions/index.html
130+
131+
# Submit and push
132+
git add .
133+
if git diff-index --quiet HEAD --; then
134+
echo "No changes to deploy"
135+
else
136+
git commit -m "Deploy ${{ steps.version.outputs.docs-version }} documentation from tag ${{ github.ref_name }}"
137+
git push origin master
138+
echo "✅ Tag documentation version ${{ steps.version.outputs.docs-version }} deployed successfully"
139+
fi

.github/workflows/full-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
name: Master Branch CI - Full Tests
44

55
on:
6-
push:
7-
branches: [ master ]
86
pull_request:
97
branches: [ master ]
108

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(ORIGINAL_VERSION 0.1.5)
66
set(CMAKE_CXX_STANDARD 23)
77
set(CMAKE_CXX_STANDARD_REQUIRED True)
88
if (NOT CMAKE_BUILD_TYPE)
9-
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (default Debug)" FORCE)
9+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (default Release)" FORCE)
1010
endif()
1111

1212
include(CMakePackageConfigHelpers)

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Original是一个C++基础工具库,也是本人的第一个正式项目,用
3030

3131
### 📋 历史版本 (Historical Versions)
3232
- **版本**: 按发布标签
33-
- [查看所有历史版本](../versions/)
33+
- [查看所有历史版本](../versions/index.html)
3434

3535
---
3636

0 commit comments

Comments
 (0)