forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·164 lines (142 loc) · 4.84 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·164 lines (142 loc) · 4.84 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
set -e
VERSION=${1:-$(node -p "require('./package.json').version")}
PLATFORMS=${2:-"all"}
echo "========================================="
echo "Codea Studio Code Release Builder"
echo "========================================="
echo "Version: ${VERSION}"
echo "Platforms: ${PLATFORMS}"
echo ""
# Auto-install Docker if not present
if ! command -v docker &>/dev/null; then
echo ">>> Docker not found. Installing..."
curl -fsSL https://get.docker.com | sh
echo ">>> Docker installed successfully"
fi
# Auto-install GitHub CLI if not present
if ! command -v gh &>/dev/null; then
echo ">>> GitHub CLI not found. Installing..."
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
echo ">>> GitHub CLI installed successfully"
fi
# Check gh authentication
if ! gh auth status &>/dev/null; then
echo ""
echo "========================================="
echo "GitHub CLI needs authentication"
echo "========================================="
echo ""
gh auth login
# Set default repo
gh repo set-default OxyHQ/CodeaStudioCode
fi
# Build Docker image if not exists
if ! docker images | grep -q "codea-builder"; then
echo ""
echo ">>> Building Docker image (first time only, ~10 min)..."
docker build -t codea-builder .
echo ">>> Docker image built successfully"
fi
# Run build inside Docker
echo ""
echo ">>> Starting Docker build container..."
docker run --rm \
-v "$(pwd):/workspace" \
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
codea-builder \
bash -c "
set -e
echo '>>> Installing dependencies...'
npm ci
echo ''
echo '>>> Compiling base code...'
npm run compile-build
npm run compile-extensions-build
npm run minify-vscode
# Function for build and upload
build_and_upload() {
local platform=\$1
local gulp_task=\$2
local file_pattern=\$3
local file_ext=\$4
echo ''
echo '========================================='
echo \">>> Building \${platform}...\"
echo '========================================='
npm run gulp -- \${gulp_task} || true
# Find output directory
local output_dir=\$(find .. -maxdepth 1 -type d -name \"VSCode-*\" | grep -E \"\${file_pattern}\" | head -1)
if [ -d \"\${output_dir}\" ]; then
cd \"\${output_dir}\"
local filename=\"CodeaStudioCode-\${platform}-v${VERSION}.\${file_ext}\"
if [ \"\${file_ext}\" = \"zip\" ]; then
zip -r \"/workspace/\${filename}\" *
else
tar czf \"/workspace/\${filename}\" *
fi
echo \">>> \${platform} compiled: \$(du -h /workspace/\${filename} | cut -f1)\"
cd /workspace
# Upload to GitHub
if ! gh release view v${VERSION} &>/dev/null; then
gh release create v${VERSION} \
--title \"Codea Studio Code ${VERSION}\" \
--notes \"Release ${VERSION}\" \
--prerelease \
\"\${filename}\"
else
gh release upload v${VERSION} \"\${filename}\" --clobber
fi
echo \">>> \${platform} uploaded to GitHub\"
rm -rf \"\${output_dir}\"
rm -f \"/workspace/\${filename}\"
else
echo \">>> WARNING: \${platform} build not found\"
fi
}
# Build according to selected platforms
case \"${PLATFORMS}\" in
all)
build_and_upload 'win32-arm64' 'vscode-win32-arm64-min' 'win32-arm64' 'zip'
build_and_upload 'win32-x64' 'vscode-win32-x64-min' 'win32-x64' 'zip'
build_and_upload 'linux-x64' 'vscode-linux-x64-min' 'linux-x64' 'tar.gz'
build_and_upload 'linux-arm64' 'vscode-linux-arm64-min' 'linux-arm64' 'tar.gz'
build_and_upload 'darwin-arm64' 'vscode-darwin-arm64-min' 'darwin-arm64' 'tar.gz'
;;
windows)
build_and_upload 'win32-arm64' 'vscode-win32-arm64-min' 'win32-arm64' 'zip'
build_and_upload 'win32-x64' 'vscode-win32-x64-min' 'win32-x64' 'zip'
;;
linux)
build_and_upload 'linux-x64' 'vscode-linux-x64-min' 'linux-x64' 'tar.gz'
build_and_upload 'linux-arm64' 'vscode-linux-arm64-min' 'linux-arm64' 'tar.gz'
;;
macos)
build_and_upload 'darwin-arm64' 'vscode-darwin-arm64-min' 'darwin-arm64' 'tar.gz'
;;
*)
echo \"ERROR: Invalid platform. Use: all, windows, linux, macos\"
exit 1
;;
esac
echo ''
echo '========================================='
echo '>>> Release complete!'
echo '========================================='
"
echo ""
echo "========================================="
echo ">>> DONE!"
echo "========================================="
echo ""
echo "Release URL: https://github.com/OxyHQ/CodeaStudioCode/releases/tag/v${VERSION}"
echo ""
echo "To turn off droplet and save money:"
echo " doctl compute droplet-action power-off <droplet-id>"
echo " or use DigitalOcean web interface"
echo ""