-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdeploy-to-gh-pages.sh
More file actions
executable file
·145 lines (123 loc) · 4.55 KB
/
deploy-to-gh-pages.sh
File metadata and controls
executable file
·145 lines (123 loc) · 4.55 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash
# Deploy to gh-pages branch
# This script copies the built WebAssembly files and web UI to the gh-pages branch
# without committing builds/ to the master branch
set -eu
echo "========================================="
echo "Deploying to gh-pages"
echo "========================================="
# Check if builds directory exists
if [ ! -d "builds" ]; then
echo "Error: builds/ directory not found!"
echo "Please run ./build-multi.sh first to build the WebAssembly files."
exit 1
fi
# Check if we're on master/main
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" != "master" ] && [ "$CURRENT_BRANCH" != "main" ]; then
echo "Warning: You're on branch '$CURRENT_BRANCH', not 'master' or 'main'"
read -p "Do you want to continue? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Deployment cancelled."
exit 1
fi
fi
# Check if we have uncommitted changes and abort if so
if ! git diff-index --quiet HEAD --; then
echo "Error: You have uncommitted changes in the current branch."
echo "Please commit or stash your changes before deploying."
git status --short
exit 1
fi
# Save builds/, phar files, and stub files (they're untracked on master)
TEMP_DIR=$(mktemp -d)
echo "Saving builds/ directory to temp..."
cp -r builds/ "$TEMP_DIR/" 2>/dev/null || true
cp *.phar "$TEMP_DIR/" 2>/dev/null || true
cp *.phar.info "$TEMP_DIR/" 2>/dev/null || true
cp *.phar.commit "$TEMP_DIR/" 2>/dev/null || true
echo "Saving .phan/stubs/ directory to temp..."
cp -r .phan/ "$TEMP_DIR/" 2>/dev/null || true
cp manifest.json "$TEMP_DIR/" 2>/dev/null || true
cp *.phar.br "$TEMP_DIR/" 2>/dev/null || true
# Remove untracked files that would conflict with gh-pages checkout
echo "Removing untracked files that exist on gh-pages..."
rm -rf builds 2>/dev/null || true
rm -f manifest.json *.phar.br 2>/dev/null || true
# Checkout gh-pages
echo "Checking out gh-pages branch..."
git checkout gh-pages
# Pull latest from origin
echo "Pulling latest gh-pages..."
git pull origin gh-pages
# Copy web files from master
echo "Copying web files..."
git checkout $CURRENT_BRANCH -- index.html favicon.ico
git checkout $CURRENT_BRANCH -- static/demo.js static/demo.css static/gist-auth.js static/loading.js
# Ensure .nojekyll exists (required to serve .phan/ directory on GitHub Pages)
if [ ! -f .nojekyll ]; then
touch .nojekyll
echo "Created .nojekyll file"
fi
# Restore builds/, phar files, and stub files from temp
echo "Restoring builds/ directory..."
if [ -d "$TEMP_DIR/builds" ]; then
rm -rf builds/
cp -r "$TEMP_DIR/builds" .
fi
echo "Restoring .phan/stubs/ directory..."
if [ -d "$TEMP_DIR/.phan" ]; then
rm -rf .phan/
cp -r "$TEMP_DIR/.phan" .
fi
cp "$TEMP_DIR"/*.phar . 2>/dev/null || true
cp "$TEMP_DIR"/*.phar.info . 2>/dev/null || true
cp "$TEMP_DIR"/*.phan.commit . 2>/dev/null || true
cp "$TEMP_DIR"/manifest.json . 2>/dev/null || true
cp "$TEMP_DIR"/*.phar.br . 2>/dev/null || true
rm -rf "$TEMP_DIR"
# Show status
echo ""
echo "Files to be committed:"
git status --short
echo ""
read -p "Do you want to commit and push these changes to gh-pages? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Commit
echo "Committing changes..."
git add index.html favicon.ico builds/
git add static/demo.js static/demo.css static/gist-auth.js static/loading.js
# Also add phar files and metadata if they exist
git add *.phar 2>/dev/null || true
git add *.phar.info *.phar.commit 2>/dev/null || true
git add manifest.json 2>/dev/null || true
git add *.phar.br 2>/dev/null || true
# Add stub files
git add .phan/stubs/ 2>/dev/null || true
# Create commit message with version info
COMMIT_MSG="Deploy multi-version support
- PHP versions: 8.1.33, 8.2.30, 8.3.29, 8.4.16, 8.5.1
- Phan versions: 5.5.2, v6-dev
- php-ast versions: 1.1.2, 1.1.3
- User-selectable PHP, Phan, and ast versions"
git commit -m "$COMMIT_MSG"
# Push
echo "Pushing to origin/gh-pages..."
git push origin gh-pages
echo ""
echo "========================================="
echo "Deployment complete!"
echo "========================================="
echo "The site should be updated at https://phan.github.io/demo/ shortly."
echo "(GitHub Pages may take a few minutes to build and deploy)"
else
echo "Deployment cancelled. Changes have been staged but not committed."
echo "You can commit them manually or reset with: git reset --hard"
fi
# Return to original branch
echo ""
echo "Returning to $CURRENT_BRANCH..."
git checkout $CURRENT_BRANCH
echo "Done!"