Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 41c00ad

Browse files
committed
feat(workflow): refactor package.yml for improved platform configuration and version management
1 parent 17aaa28 commit 41c00ad

File tree

2 files changed

+158
-51
lines changed

2 files changed

+158
-51
lines changed

.github/workflows/package.yml

Lines changed: 156 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -88,60 +88,167 @@ jobs:
8888
cd ..
8989
9090
- name: Mach configure
91+
shell: zx --verbose {0}
92+
env:
93+
FORCE_COLOR: 3
94+
BUILD_PLATFORM: ${{ inputs.platform }}
95+
IS_BETA: ${{ inputs.beta }}
9196
run: |
92-
if [ "${{inputs.platform}}" == "Windows-x64" ]; then
93-
cp ./.github/workflows/mozconfigs/win64.mozconfig mozconfig
94-
elif [ "${{inputs.platform}}" == "Linux-x64" ]; then
95-
cp ./.github/workflows/mozconfigs/linux64.mozconfig mozconfig
96-
else
97-
cp ./.github/workflows/mozconfigs/macosx64-x86_64.mozconfig mozconfig
98-
fi
97+
// Copy appropriate mozconfig based on platform
98+
const mozconfigs = {
99+
'Windows-x64': './.github/workflows/mozconfigs/win64.mozconfig',
100+
'Linux-x64': './.github/workflows/mozconfigs/linux64.mozconfig',
101+
'macOS-x64': './.github/workflows/mozconfigs/macosx64-x86_64.mozconfig'
102+
};
99103
100-
# Copy Noraneko Branding
101-
cp -r ./floorp/gecko/branding/* ./browser/branding/
102-
103-
mkdir floorp/gecko/config/autogenerated
104-
echo "$(cat browser/config/version.txt)@$(cat floorp/gecko/config/version.txt)" >> floorp/gecko/config/autogenerated/version.txt
105-
echo "$(cat browser/config/version_display.txt)@$(cat floorp/gecko/config/version_display.txt)" >> floorp/gecko/config/autogenerated/version_display.txt
106-
echo "ac_add_options --with-version-file-path=floorp/gecko/config/autogenerated" >> mozconfig
107-
# sed -i 's|ac_add_options --disable-maintenance-service|#ac_add_options --disable-maintenance-service|g' ./mozconfig
108-
sed -i 's|ac_add_options --disable-updater||g' ./mozconfig
109-
sed -i 's|ac_add_options --enable-unverified-updates||g' ./mozconfig
110-
111-
echo "ac_add_options --enable-release" >> mozconfig
112-
echo "ac_add_options --disable-tests" >> mozconfig
113-
echo "ac_add_options --enable-artifact-builds" >> mozconfig
114-
echo "mk_add_options MOZ_OBJDIR=./obj-artifact-build-output" >> mozconfig
115-
116-
if [ "${{inputs.beta}}" == "true" ]; then
117-
sed -i 's|MOZ_BRANDING_DIRECTORY=browser/branding/unofficial|MOZ_BRANDING_DIRECTORY=browser/branding/floorp-daylight|g' ./browser/confvars.sh
118-
echo "ac_add_options --enable-update-channel=beta" >> mozconfig
119-
else
120-
sed -i 's|MOZ_BRANDING_DIRECTORY=browser/branding/unofficial|MOZ_BRANDING_DIRECTORY=browser/branding/floorp-official|g' ./browser/confvars.sh
121-
echo "ac_add_options --enable-update-channel=release" >> mozconfig
122-
fi
104+
await $`cp ${mozconfigs[process.env.BUILD_PLATFORM]} mozconfig`;
123105
124-
sed -i 's|ac_add_options --enable-chrome-format=flat||g' ./mozconfig
106+
// Copy Noraneko Branding
107+
await $`cp -r ./floorp/gecko/branding/* ./browser/branding/`;
125108
126-
if [ "${{inputs.platform}}" == "macOS-x64" ]; then
127-
# Extract macOS .dmg tools
128-
mkdir -p ~/tools
129-
curl -L https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/ceSQWV1AS76UlhYJ0_PfJQ/artifacts/public/build/dmg.tar.zst -o dmg.tar.zst
130-
tar -I zstd -xf dmg.tar.zst -C ~/tools
131-
sudo chmod 777 ~/tools/dmg
132-
133-
curl -L https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/N2SwCRLrRw2l-UWP4N7dhQ/artifacts/public/build/hfsplus.tar.zst -o hfsplus.tar.zst
134-
tar -I zstd -xf hfsplus.tar.zst -C ~/tools
135-
sudo chmod 777 ~/tools/hfsplus
136-
137-
# write mozconfig
138-
echo "DMG_TOOL=$(echo ~/tools/dmg/dmg)" >> mozconfig
139-
echo "HFS_TOOL=$(echo ~/tools/dmg/hfsplus)" >> mozconfig
140-
echo "MKFSHFS=$(echo ~/tools/hfsplus/newfs_hfs)" >> mozconfig
141-
fi
109+
// Create and setup version files
110+
await $`mkdir -p floorp/gecko/config/autogenerated`;
111+
const version = await $`cat browser/config/version.txt`;
112+
const geckoVersion = await $`cat floorp/gecko/config/version.txt`;
113+
await $`echo "${version}@${geckoVersion}" > floorp/gecko/config/autogenerated/version.txt`;
114+
115+
const versionDisplay = await $`cat browser/config/version_display.txt`;
116+
const geckoVersionDisplay = await $`cat floorp/gecko/config/version_display.txt`;
117+
await $`echo "${versionDisplay}@${geckoVersionDisplay}" > floorp/gecko/config/autogenerated/version_display.txt`;
118+
119+
// Configure for beta or release
120+
// Helper function to run sed command
121+
const sedReplace = async (pattern, replacement, file) => {
122+
console.log(`Replacing ${pattern} with ${replacement} in ${file}`);
123+
await $`sed -i 's|${pattern}|${replacement}|g' ${file}`;
124+
};
125+
126+
// Helper function to add mozconfig options
127+
const addMozConfig = async (option) => {
128+
console.log(`Adding ${option} to mozconfig`);
129+
await $`echo "ac_add_options ${option}" >> mozconfig`;
130+
};
131+
132+
133+
// Append base configuration to mozconfig
134+
const baseConfig = [
135+
'--with-version-file-path=floorp/gecko/config/autogenerated',
136+
'--enable-release',
137+
'--disable-tests',
138+
'--enable-artifact-builds'
139+
];
140+
141+
for (const option of baseConfig) {
142+
await $`echo "ac_add_options ${option}" >> mozconfig`;
143+
}
144+
145+
// Remove mozconfig options for flat chrome and branding
146+
const removeConfig = [
147+
'--disable-updater',
148+
'--enable-chrome-format=flat',
149+
'--enable-unverified-updates',
150+
];
151+
152+
for (const option of removeConfig) {
153+
await $`sed -i '/ac_add_options ${option}/d' mozconfig`;
154+
}
155+
156+
// Common paths/files
157+
const confvarsPath = './browser/confvars.sh';
158+
const updateUtilsPath = './toolkit/modules/UpdateUtils.sys.mjs';
159+
160+
await $`sed -i 's|return encodeURIComponent(replacement);|return name === "NORA_UPDATE_HOST" ? replacement : encodeURIComponent(replacement);|' ${updateUtilsPath}`;
161+
162+
if (process.env.IS_BETA === 'true') {
163+
// Beta configuration
164+
await sedReplace(
165+
'MOZ_BRANDING_DIRECTORY=browser/branding/unofficial',
166+
'MOZ_BRANDING_DIRECTORY=browser/branding/floorp-daylight',
167+
confvarsPath
168+
);
169+
await addMozConfig('--enable-update-channel=beta');
170+
await addMozConfig('--with-branding=browser/branding/floorp-daylight');
171+
172+
// Set update URL based on platform
173+
const baseUrl = 'github.com/Floorp-Projects/Floorp-12/releases/download/beta/';
174+
const platformUrls = {
175+
'Windows-x64': `${baseUrl}WINNT_x86_64-msvc-x64.`,
176+
'Linux-x64': `${baseUrl}Linux_x86_64.`,
177+
'macOS-x64': `${baseUrl}Darwin_x86_64.`
178+
};
179+
180+
if (platformUrls[process.env.BUILD_PLATFORM]) {
181+
await sedReplace(
182+
'REPLACE_THIS_NORA_UPDATE_HOST_TARGET_PLACEHOLDER',
183+
platformUrls[process.env.BUILD_PLATFORM],
184+
updateUtilsPath
185+
);
186+
} else {
187+
console.error('Unsupported platform: ' + process.env.BUILD_PLATFORM);
188+
}
189+
} else {
190+
// Release configuration
191+
await sedReplace(
192+
'MOZ_BRANDING_DIRECTORY=browser/branding/unofficial',
193+
'MOZ_BRANDING_DIRECTORY=browser/branding/floorp-official',
194+
confvarsPath
195+
);
196+
await addMozConfig('--enable-update-channel=release');
197+
await addMozConfig('--with-branding=browser/branding/floorp-official');
198+
199+
// Read version from version_display.txt to use in update URLs
200+
const versionFromFile = (await $`cat ./browser/config/version_display.txt`).toString().trim();
201+
console.log(`Using version from file: ${versionFromFile}`);
202+
203+
// Set update URL based on platform
204+
const baseUrl = `floorp-update.ablaze.one/browser/${versionFromFile}/`;
205+
const platformUrls = {
206+
'Windows-x64': `${baseUrl}WINNT/x86_64/`,
207+
'Linux-x64': `${baseUrl}Linux/x86_64/`,
208+
'macOS-x64': `${baseUrl}Darwin/x86_64/`
209+
};
210+
211+
if (platformUrls[process.env.BUILD_PLATFORM]) {
212+
await sedReplace(
213+
'REPLACE_THIS_NORA_UPDATE_HOST_TARGET_PLACEHOLDER',
214+
platformUrls[process.env.BUILD_PLATFORM],
215+
updateUtilsPath
216+
);
217+
} else {
218+
console.error('Unsupported platform: ' + process.env.BUILD_PLATFORM);
219+
}
220+
}
221+
222+
await $`echo "mk_add_options MOZ_OBJDIR=./obj-artifact-build-output" >> mozconfig`;
223+
224+
// Special configuration for macOS
225+
if (process.env.BUILD_PLATFORM === 'macOS-x64') {
226+
await $`mkdir -p ~/tools`;
227+
228+
// Download and extract DMG tools
229+
await $`curl -L https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/ceSQWV1AS76UlhYJ0_PfJQ/artifacts/public/build/dmg.tar.zst -o dmg.tar.zst`;
230+
await $`tar -I zstd -xf dmg.tar.zst -C ~/tools`;
231+
await $`sudo chmod 777 ~/tools/dmg`;
232+
233+
await $`curl -L https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/N2SwCRLrRw2l-UWP4N7dhQ/artifacts/public/build/hfsplus.tar.zst -o hfsplus.tar.zst`;
234+
await $`tar -I zstd -xf hfsplus.tar.zst -C ~/tools`;
235+
await $`sudo chmod 777 ~/tools/hfsplus`;
236+
237+
// Add macOS specific mozconfig options
238+
const macConfig = [
239+
`DMG_TOOL=${os.homedir()}/tools/dmg/dmg`,
240+
`HFS_TOOL=${os.homedir()}/tools/dmg/hfsplus`,
241+
`MKFSHFS=${os.homedir()}/tools/hfsplus/newfs_hfs`
242+
];
243+
244+
for (const option of macConfig) {
245+
await $`echo "${option}" >> mozconfig`;
246+
}
247+
}
142248
143-
./mach configure
144-
git apply --ignore-space-change --ignore-whitespace .github/patches/packaging/*.patch
249+
// Run configure and apply patches
250+
await $`./mach configure`;
251+
await $`git apply --ignore-space-change --ignore-whitespace .github/patches/packaging/*.patch`;
145252
146253
- name: Possibly retrieve run ID if not provided
147254
run: |

src/apps/settings/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vite";
1+
import { defineConfig, PluginOption } from "vite";
22
import tsconfigPaths from "vite-tsconfig-paths";
33
import react from "@vitejs/plugin-react-swc";
44
import tailwindcss from "@tailwindcss/vite";
@@ -23,7 +23,7 @@ export default defineConfig({
2323
},
2424
},
2525
plugins: [
26-
tsconfigPaths(),
26+
tsconfigPaths() as PluginOption,
2727
react(),
2828
tailwindcss(),
2929
{

0 commit comments

Comments
 (0)