Skip to content

Commit c1f9826

Browse files
author
Codesphere Developer
committed
ci: add patch generation step to workflows
Updated generate-brand-patch.sh to support --in-place execution for CI. Added 'Generate Branding Patch' step to linux/windows/macos workflows to ensure the codesphere-brand.patch is created dynamically during build.
1 parent 0a6de4c commit c1f9826

File tree

4 files changed

+76
-32
lines changed

4 files changed

+76
-32
lines changed

.github/workflows/linux-build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ jobs:
7777
VSCODE_ARCH: ${{ matrix.arch }}
7878
VSCODE_LATEST: no
7979

80-
- name: Apply Script/Asset Branding
80+
VSCODE_LATEST: no
81+
82+
- name: Generate Branding Patch
8183
run: |
8284
chmod +x ci/*.sh
85+
./ci/generate-brand-patch.sh --in-place
86+
87+
- name: Apply Script/Asset Branding
88+
run: |
8389
./ci/ci-branding.sh
8490
env:
8591
OS_NAME: linux

.github/workflows/macos-build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ jobs:
7272
VSCODE_ARCH: ${{ matrix.arch }}
7373
VSCODE_LATEST: no
7474

75-
- name: Apply Script/Asset Branding
75+
VSCODE_LATEST: no
76+
77+
- name: Generate Branding Patch
7678
run: |
7779
chmod +x ci/*.sh
80+
./ci/generate-brand-patch.sh --in-place
81+
82+
- name: Apply Script/Asset Branding
83+
run: |
7884
./ci/ci-branding.sh
7985
env:
8086
OS_NAME: osx

.github/workflows/windows-build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,17 @@ jobs:
7373
VSCODE_ARCH: ${{ matrix.arch }}
7474
VSCODE_LATEST: no
7575

76-
- name: Apply Script/Asset Branding
76+
VSCODE_LATEST: no
77+
78+
- name: Generate Branding Patch
7779
shell: bash
7880
run: |
7981
chmod +x ci/*.sh
82+
./ci/generate-brand-patch.sh --in-place
83+
84+
- name: Apply Script/Asset Branding
85+
shell: bash
86+
run: |
8087
./ci/ci-branding.sh
8188
env:
8289
OS_NAME: windows

ci/generate-brand-patch.sh

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,63 @@ if [ -f "$REPO_ROOT/ci/env.sh" ]; then
1515
. "$REPO_ROOT/ci/env.sh"
1616
fi
1717

18-
# Temporary workspace vars
18+
# Temporary workspace vars (default)
1919
TEMP_ROOT="$REPO_ROOT/build_temp"
2020
TEMP_VSCODIUM="$TEMP_ROOT/vscodium"
2121
TEMP_VSCODE="$TEMP_VSCODIUM/vscode"
2222

23-
echo "🔧 Codesphere Brand Patch Generator"
24-
echo "===================================="
25-
echo "Working directory: $TEMP_ROOT"
23+
# Default to using temp dir
24+
USE_TEMP_DIR=true
25+
TARGET_VSCODE="$TEMP_VSCODE"
2626

27-
# Cleanup any previous run
28-
rm -rf "$TEMP_ROOT"
29-
mkdir -p "$TEMP_VSCODIUM"
30-
31-
# 1. Copy VSCodium scripts to temp dir (so we can fix CRLF safely)
32-
echo "📦 Copying VSCodium scripts to temp workspace..."
33-
cp -r "$VSCODIUM_SUBMODULE/"* "$TEMP_VSCODIUM/"
34-
35-
# 2. Fix CRLF line endings in the temp scripts (crucial for Windows/WSL)
36-
echo "🔧 Fixing CRLF line endings in temp scripts..."
37-
find "$TEMP_VSCODIUM" -name "*.sh" -type f -exec sed -i 's/\r$//' {} +
27+
# Check arguments
28+
if [[ "$1" == "--in-place" ]] || [[ "$CI_BUILD" == "yes" ]]; then
29+
echo "⚙️ CI/In-Place mode detected."
30+
USE_TEMP_DIR=false
31+
TARGET_VSCODE="$REPO_ROOT/vendor/vscodium/vscode"
32+
fi
3833

39-
# 3. Fetch VS Code source using the temp scripts
40-
echo "📥 Fetching VS Code source (this may take time)..."
41-
cd "$TEMP_VSCODIUM" || exit 1
42-
# Force bash usage to ensuring expected behavior
43-
bash ./get_repo.sh
34+
if [ "$USE_TEMP_DIR" = true ]; then
35+
echo "Working directory: $TEMP_ROOT"
4436

45-
# 4. Verify fetch success
46-
if [ ! -d "$TEMP_VSCODE/.git" ]; then
47-
echo "❌ Error: Failed to fetch vscode source in temp dir"
48-
exit 1
37+
# Cleanup any previous run
38+
rm -rf "$TEMP_ROOT"
39+
mkdir -p "$TEMP_VSCODIUM"
40+
41+
# 1. Copy VSCodium scripts to temp dir (so we can fix CRLF safely)
42+
echo "📦 Copying VSCodium scripts to temp workspace..."
43+
cp -r "$VSCODIUM_SUBMODULE/"* "$TEMP_VSCODIUM/"
44+
45+
# 2. Fix CRLF line endings in the temp scripts (crucial for Windows/WSL)
46+
echo "🔧 Fixing CRLF line endings in temp scripts..."
47+
find "$TEMP_VSCODIUM" -name "*.sh" -type f -exec sed -i 's/\r$//' {} +
48+
49+
# 3. Fetch VS Code source using the temp scripts
50+
echo "📥 Fetching VS Code source (this may take time)..."
51+
cd "$TEMP_VSCODIUM" || exit 1
52+
# Force bash usage to ensuring expected behavior
53+
bash ./get_repo.sh
54+
55+
# 4. Verify fetch success
56+
if [ ! -d "$TEMP_VSCODE/.git" ]; then
57+
echo "❌ Error: Failed to fetch vscode source in temp dir"
58+
exit 1
59+
fi
60+
61+
echo "✅ Clean vscode checkout ready in temp dir"
62+
else
63+
echo "📂 Using existing source at: $TARGET_VSCODE"
64+
if [ ! -d "$TARGET_VSCODE/.git" ]; then
65+
echo "❌ Error: $TARGET_VSCODE is not a git repository"
66+
echo "Please ensure get_repo.sh has been run."
67+
exit 1
68+
fi
4969
fi
5070

51-
echo "✅ Clean vscode checkout ready in temp dir"
5271
echo ""
5372
echo "🎨 Applying Codesphere branding changes..."
5473

55-
cd "$TEMP_VSCODE" || exit 1
74+
cd "$TARGET_VSCODE" || exit 1
5675

5776
# Apply branding replacements (Regex logic from original enforce-branding.sh)
5877

@@ -107,9 +126,15 @@ if [ -s "$PATCH_OUTPUT" ]; then
107126
echo " Lines: $PATCH_LINES"
108127

109128
# Cleanup
110-
echo "🧹 Cleaning up temp workspace..."
111-
cd "$REPO_ROOT"
112-
rm -rf "$TEMP_ROOT"
129+
if [ "$USE_TEMP_DIR" = true ]; then
130+
echo "🧹 Cleaning up temp workspace..."
131+
cd "$REPO_ROOT"
132+
rm -rf "$TEMP_ROOT"
133+
else
134+
echo "🧹 Resetting source directory..."
135+
git reset --hard HEAD
136+
git clean -fd
137+
fi
113138
echo "✨ Done."
114139
else
115140
echo "❌ No changes detected - patch file is empty"

0 commit comments

Comments
 (0)