A method, apparatus, device, and medium for automated building, packaging, and deployment of mobile applications.

By encapsulating the build toolchain within a container image and receiving a single command for automated building, the problem of insufficient consistency and error-prone configuration in mobile application build environments is solved, achieving efficient and reliable build, packaging, and deployment.

CN123114531APending Publication Date: 2026-11-17赛美特信息集团股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611306195.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-26
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In the current mobile application building process, the lack of consistency in the build environment, the inability to reproduce results, the strong dependence on the network, and the cumbersome and error-prone configuration modifications make it difficult to guarantee the quality of the build.

Method used

The build toolchain and dependencies are encapsulated as a self-contained archive and built into the container image. A streaming one-time restoration is achieved through a flag directory criterion. Single commands are received for parameter parsing and configuration injection. Compilation and artifact collection are executed automatically, achieving consistency throughout the process and offline availability.

Benefits of technology

It improves the reproducibility and reliability of build results, reduces reliance on manual operations, increases build efficiency and the accuracy of configuration modifications, and ensures the consistency of the build environment and the standardization of outputs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114531A_ABST
    Figure CN123114531A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, device, and medium for automated building, packaging, and deployment of mobile applications. The method includes: encapsulating the complete build toolchain and dependencies into a self-contained archive embedded in a container image; using a flag directory as the idempotency criterion during container startup; restoring the build environment once via streaming decompression on the first run, and skipping this process on subsequent startups, thus ensuring environment consistency and supporting fully offline building; receiving and parsing a single command containing actions and environment parameters; automatically evolving the version number according to the actions; and performing differentiated configuration injection for heterogeneous project configuration files of different formats; calling the restored toolchain to execute source code compilation and generate artifacts; finally, aggregating the artifacts to a specified directory; and writing back the evolved version number to form an iterative closed loop, achieving full automation of the mobile application building and packaging process. Using this method, the consistency, reliability, and execution efficiency of mobile application building, packaging, and deployment are significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of mobile application development and continuous integration technology, and more specifically, to a method, apparatus, device and medium for automated construction, packaging and deployment of mobile applications. Background Technology

[0002] With the widespread application of mobile hybrid development technologies, building, packaging, and hot-updating mobile applications have become core components of the application development process. The stability, consistency, and execution efficiency of the build process directly determine the application's iteration speed and release quality. Under the demand for rapid business iteration, the standardization and reusability of the build process are becoming increasingly important.

[0003] Currently, the common approach for building and releasing hybrid mobile applications is to build them directly in the developer's local environment. Developers need to independently install and configure a complete set of interlocking build toolchains on their respective work devices, covering a specified version of the Java SDK, Android SDK, Gradle build tool, Node.js runtime environment, Cordova framework, and various front-end and native build plugins. After the environment is configured, developers manually perform operations such as modifying configuration items, adjusting version numbers, compiling front-end resources, compiling native installers, packaging hot-update resources, renaming and archiving artifacts, etc., to complete the final release artifact.

[0004] This implementation method suffers from insufficient consistency in the build environment and poor reproducibility of build results. Because the build environment for each device is set up independently by hand, there is a strict version coupling between different tool components. Differences in system environment, tool version deviations, environment variable configurations, and local cache states can all lead to variations in compilation behavior. This easily results in inconsistent build results for the same source code on different devices, and some devices may fail to complete the build correctly. The consistency of build results cannot be guaranteed by a mechanism, which is detrimental to the quality control and troubleshooting of application releases. Summary of the Invention

[0005] In view of this, the purpose of this application is to provide a method, apparatus, device and medium for automated building, packaging and deployment of mobile applications, which effectively reduces the dependence on manual operation in the entire building process and significantly improves the consistency, reliability and execution efficiency of mobile application building, packaging and deployment.

[0006] In a first aspect, embodiments of this application provide a method for automated building, packaging, and deployment of mobile applications, the method comprising: The build toolchain and build dependencies are encapsulated into a self-contained archive and built into the container image. When the container starts, the existence of a flag directory is used as a criterion. If the flag directory does not exist, the archive is restored to the target path in a streaming manner all at once. If the flag directory exists, the restoration is skipped. Receive a single command containing action parameters and environment parameters, and parse the action parameters and environment parameters from the parameter list of the command; Based on the evolution version number of the action parameters and according to the different formats of the target files, configuration injection is performed on multiple heterogeneous project configuration files respectively; The project source code is compiled using the restored build toolchain and build dependencies to generate compilation artifacts, and the output directory is specified. The compiled artifacts are collected into the output directory, and the evolved version number is written back for use in subsequent builds.

[0007] Optionally, in the action of encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it in the container image, the self-contained archive is an archive file compressed using a high compression ratio algorithm; The action of restoring the archive to the target path in a streaming manner in one go includes: The archive is decompressed using a multi-threaded approach to obtain a decompressed data stream. The decompressed data stream is fed directly into the de-archive tool through a pipeline, and the de-archive tool reads the decompressed data stream from the pipeline and expands it locally to the target path; If any step fails, the restoration will be aborted and the system will exit with a non-zero exit code.

[0008] Optionally, in the action of evolving the version number according to the action parameters, the version number includes segments A, B, C and D arranged in sequence, wherein segments A and B constitute the major version identifier of the installation package, and segments C and D constitute the hot update count; The version number evolution includes: When the action parameter is a construction action, segment B is carried over. If segment B exceeds the threshold, segment A is carried over, and segments C and D are forced to zero. When the action parameter is a hot-up action, segment D carries over; if segment D exceeds the threshold, then segment C carries over.

[0009] Optionally, the action that evolves the version number according to the action parameters further includes: Based on the evolved A segment and B segment, a hot update configuration file name is generated, so that the hot update configuration file and the major version of the installation package are associated at the naming level.

[0010] Optionally, in the action of injecting configuration into multiple heterogeneous project configuration files according to different formats of the target file, the configuration injection includes: For JavaScript constant files, use regular expressions with paired backreferences in quotes to replace and rewrite them; For XML format configuration files, a defensive XML-AST parsing method is used to rewrite them; For JSON format configuration files, JSON parsing is used to rewrite them; For Gradle build files, rewrite the application package name using regular expressions with global flags.

[0011] Optionally, the action of parsing the action parameters and the environment parameters from the parameter list of the command further includes: After filtering out the identified action parameters, environment parameters, and flag parameters from the parameter list, the first remaining parameter is taken as the project suffix parameter. The input file path and output directory path are dynamically constructed based on the project suffix parameter to achieve isolation between different projects.

[0012] Optionally, in the action of compiling the project source code using the restored build toolchain and build dependencies: The complete compilation mode executes the following steps in sequence: project cleanup, front-end resource compilation, resource copying, front-end build tool compilation, and hot update resource packaging. The fast compilation mode skips the compilation of the front-end resources and only performs the project cleanup, resource copying, and hot update resource packaging.

[0013] Secondly, embodiments of this application provide an automated mobile application building, packaging, and deployment apparatus, comprising: The container image is used to encapsulate the build toolchain and build dependencies into a self-contained archive and embed it within the container image; and is used to, when the container starts, use the existence of a flag directory as a criterion, if the flag directory does not exist, restore the archive to the target path in a streaming manner all at once, and if the flag directory exists, skip the restoration. A receiving module is used to receive a single command containing action parameters and environment parameters, and to parse the action parameters and environment parameters from the parameter list of the command; The configuration injection and version evolution module is used to evolve the version number according to the action parameters and inject configuration into multiple heterogeneous project configuration files according to different formats of the target files. The compilation module is used to compile the project source code using the restored build toolchain and the build dependencies, generate compilation artifacts, and specify the output directory; The product collection module is used to collect the compiled products into the output directory and write back the evolved version number for subsequent builds.

[0014] Optionally, in the action of encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it in the container image, the self-contained archive is an archive file compressed using a high compression ratio algorithm; When the container image performs a one-time streaming restoration of the archive to the target path, it is specifically used for: The archive is decompressed using a multi-threaded approach to obtain a decompressed data stream. The decompressed data stream is fed directly into the de-archive tool through a pipeline, and the de-archive tool reads the decompressed data stream from the pipeline and expands it locally to the target path; If any step fails, the restoration will be aborted and the system will exit with a non-zero exit code.

[0015] Optionally, when the configuration injection and version evolution module executes the version number evolution according to the action parameters, the version number includes segments A, B, C and D arranged in sequence, wherein segments A and B constitute the major version identifier of the installation package, and segments C and D constitute the hot update count. The version number evolution includes: When the action parameter is a construction action, segment B is carried over. If segment B exceeds the threshold, segment A is carried over, and segments C and D are forced to zero. When the action parameter is a hot-up action, segment D carries over; if segment D exceeds the threshold, then segment C carries over.

[0016] Optionally, the configuration injection and version evolution module is further used for: Based on the evolved A segment and B segment, a hot update configuration file name is generated, so that the hot update configuration file and the major version of the installation package are associated at the naming level.

[0017] Optionally, when the configuration injection and version evolution module performs configuration injection on multiple heterogeneous project configuration files according to different formats of the target file, it is specifically used for: For JavaScript constant files, use regular expressions with paired backreferences in quotes to replace and rewrite them; For XML format configuration files, a defensive XML-AST parsing method is used to rewrite them; For JSON format configuration files, JSON parsing is used to rewrite them; For Gradle build files, rewrite the application package name using regular expressions with global flags.

[0018] Optionally, the receiving module is further configured to: After filtering out the identified action parameters, environment parameters, and flag parameters from the parameter list, the first remaining parameter is taken as the project suffix parameter. The input file path and output directory path are dynamically constructed based on the project suffix parameter to achieve isolation between different projects.

[0019] Optionally, when the compilation module performs compilation on the project source code, it is specifically used for: In full compilation mode, the following steps are executed sequentially: project cleanup, front-end resource compilation, resource copying, front-end build tool compilation, and hot update resource packaging. In the fast compilation mode, the compilation of the front-end resources is skipped, and only the project cleanup, resource copying, and hot update resource packaging are performed.

[0020] Thirdly, embodiments of this application provide a computer device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the mobile application automated building, packaging, and deployment method described in any of the optional embodiments of the first aspect above are performed.

[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the mobile application automated building, packaging, and deployment method described in any of the optional embodiments of the first aspect.

[0022] The technical solution provided in this application includes, but is not limited to, the following beneficial effects: By encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it within the container image, and using a flag directory existence criterion to implement streaming one-time restoration and skip logic, the entire build environment can be standardized and solidified. This completely eliminates differences in tool versions and configuration parameters caused by manual environment setup, ensuring that the build environment is completely consistent across different runtime nodes, and fundamentally improving the reproducibility of build results. At the same time, the design of dependencies being built into the archive eliminates the need to access resources online during the build process, supporting complete builds in offline scenarios. The streaming restoration and idempotent determination mechanism take into account both the lightweight distribution of container images and the efficiency of environment readiness, avoiding unnecessary overhead caused by repeated restoration operations.

[0023] It receives and parses single commands carrying action and environment parameters, enabling a single entry point to drive the entire build process. This replaces the manual execution of multiple build instructions, reducing the execution threshold and the risk of human error. The parameterized command format standardizes the transmission of build control information, allowing the build process to be triggered by standardized parameters, ensuring consistency of execution logic and improving the overall efficiency of the build operation.

[0024] The version number is automatically evolved based on action parameters, and configuration injection is performed separately for heterogeneous project configuration files of different formats. This can replace manual adjustment of version numbers and file-by-file modification of configurations, reducing manual intervention in the build process and lowering the probability of version increment errors, configuration omissions, or incorrect modifications. At the same time, it can complete the synchronous update of multiple heterogeneous configuration files at one time, ensuring the consistency of values ​​for the same configuration items in different files and improving the efficiency and accuracy of configuration modification.

[0025] By using the restored build toolchain and build dependencies to compile the project source code and specify the output directory, the full compilation process can be completed in a unified and stable solidified environment. All compilation dependencies are taken from the pre-packaged built-in environment, which is not affected by external network fluctuations or local cache differences, ensuring that the running conditions of each compilation are completely consistent, and further ensuring the reproducibility of the compilation products. The unified specification of the output directory also provides a standard path basis for the standardized processing of subsequent products.

[0026] By collecting compiled artifacts into a specified output directory and writing back the evolved version number, standardized output of build artifacts can be achieved, eliminating the need for manual sorting and collection of artifacts and avoiding oversights caused by manual operation. Automatic version number writing and persistence can form an automated closed loop of version iteration, eliminating the need for manual maintenance of the current version state and ensuring that subsequent builds can continue to evolve based on the latest version, avoiding version confusion caused by manual version management.

[0027] In summary, the above-mentioned links are sequentially connected and cooperate with each other, forming a complete automated chain from environment provisioning, command triggering, configuration version management, compilation and execution to output. This effectively reduces the dependence on manual operation in the entire build process, significantly improves the consistency, reliability and execution efficiency of mobile application building, packaging and deployment, and improves the problems of large environmental differences, cumbersome manual operation and easy error in configuration and version in the existing technology from the mechanism level.

[0028] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0029] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 A flowchart of a mobile application automated building, packaging and deployment method provided in Embodiment 1 of this application is shown; Figure 2 A flowchart of a one-time flow cytometry reduction method provided in Embodiment 1 of this application is shown; Figure 3 A flowchart of a project isolation method provided in Embodiment 1 of this application is shown; Figure 4 This document shows a flowchart illustrating a one-click automated packaging and hot update process for mobile applications provided in Embodiment 1 of this application. Figure 5 This illustration shows a structural schematic diagram of a mobile application automated building, packaging, and deployment device provided in Embodiment 2 of this application; Figure 6 A schematic diagram of the structure of a computer device provided in Embodiment 3 of this application is shown. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0032] Example 1 When mobile hybrid applications release Android installation packages and hot update resource packages, their construction and release process typically relies on two existing technical solutions.

[0033] Specifically, mobile hybrid applications are based on the WebView container system represented by Apache Cordova / PhoneGap, and the released products include two types: APK (Android Package) and Hot Code Push hot update resource packages. Existing solutions cannot simultaneously guarantee environment consistency, offline availability and automated configuration version management.

[0034] Specifically, the first type of solution involves building directly in the developer's local environment, while the second type involves building on an online continuous integration server. Both types of solutions share common problems such as poor environment consistency, cumbersome manual operations, and reliance on the network.

[0035] The first type of solution involves building directly in the developer's local environment. Each developer needs to install and configure a complete set of interlocking build toolchains on their own work computer.

[0036] Specifically, the build toolchain includes at least a specific major version of the Java SDK, an Android SDK (Software Development Kit) with specified API (Application Programming Interface) level platform build-tools, a specified version of the Gradle builder, a Node.js runtime, the Cordova / cordova-hcp command-line tool, and dozens of front-end and native build plugins.

[0037] Specifically, once the environment is ready, developers need to enter the project directory and manually execute a long series of commands and manual operations, including setting environment variables, manually modifying the backend interface address, manually incrementing the version number, manually modifying the application name and application package name, compiling frontend resources, compiling natively with cordovabuild android, packaging the hot update resource directory, manually renaming by version number and collecting APKs and hot update packages. The process is tedious and highly dependent on human proficiency.

[0038] The second type of solution is online continuous integration server build. Pipeline scripts are written on servers such as Jenkins, GitLab CI (Continuous Integration), and GitHub Actions. When a build is triggered, the server pulls various dependencies online and then performs compilation and packaging steps equivalent to local builds.

[0039] Specifically, the dependencies that the server needs to pull include the Gradle distribution package, Android dependencies, native dependencies in Maven / Google repositories, and npm (Node Package Manager) dependencies. The build process is highly dependent on network connectivity and the stability of remote repositories.

[0040] Specifically, the common processing flow of the two existing technologies can be summarized as follows: preparing to set up the build environment, connecting to the network to obtain dependencies, manually modifying configuration items scattered in multiple project files, calling the front-end and native compilation toolchain, and manually organizing the artifacts and archiving them by version.

[0041] Specifically, in the existing process, the consistency of the built environment relies on manual assurance, the acquisition of a strongly dependent network, and the configuration modification and product naming are mainly completed manually item by item, which has led to a number of inherent defects that are difficult to solve through manual optimization.

[0042] The existing technology has six core objective shortcomings, all of which can be solved or improved by the corresponding technical means of this application.

[0043] Specifically, the first drawback is that the setup environment is complex, inconsistent, and the results are not reproducible.

[0044] Specifically, there is a strict version coupling relationship between JDK (Java Development Kit), Android SDK, Gradle, Cordova, and various plugins. Even slight differences in the version of any component, environment variables, or local cache can lead to inconsistent compilation behavior, resulting in situations where machine A can package the code, machine B cannot, or the output is inconsistent.

[0045] Specifically, since the environment is built manually on each machine, its consistency cannot be guaranteed by mechanism and can only be constrained by development specifications and manual verification, which is not reliable enough.

[0046] Specifically, the second drawback is its strong dependence on the network, making it impossible to build in intranet isolation or weak network environments.

[0047] Specifically, the Gradle distribution package, Android native dependencies, and npm packages are downloaded online during the build process. If the build fails in a scenario where the network is physically isolated, the dependency repository is unreachable, or the network quality is poor, the build will fail.

[0048] Specifically, the same dependencies are downloaded repeatedly for each build, which consumes extra time and bandwidth, and the build efficiency is significantly constrained by the network environment.

[0049] Specifically, the third drawback is that manually modifying configurations in multiple files leads to a high error rate and the risk of omissions.

[0050] Specifically, configuration items such as version number, backend interface address, hot update distribution address, application display name, and native application package name are scattered in various files of different formats, including .env environment files, frontend JS (JavaScript, frontend scripting language) constant files, Cordova's config.xml, cordova-hcp.json, and native build.gradle.

[0051] Specifically, manually locating and modifying each version is tedious, prone to omissions or errors, and makes it difficult to guarantee the correct correspondence between the APK version and the hot update version through a mechanism.

[0052] Specifically, the fourth drawback is that switching between multiple environments and projects is cumbersome and prone to cross-contamination.

[0053] Specifically, the same source code often needs to be packaged separately for multiple server addresses such as development, testing, and production, and may be packaged in parallel for multiple customer projects at the same time.

[0054] Specifically, existing solutions require repeated modifications to the same batch of configuration files. Intermediate products and configurations from different environments and projects are prone to overlap and crosstalk, leading to incorrect releases.

[0055] Specifically, the fifth drawback is that the generation of the build version number and the binding key encoding rely on manual intervention, and hot updates and installation packages are prone to mismatch.

[0056] Specifically, if hot-update resources are distributed to an incompatible version of the installation package, it can cause serious problems such as white screens and crashes.

[0057] Specifically, while existing hot update frameworks provide runtime checks on the device side to apply hot updates only when the versions are compatible, the effectiveness of these checks depends on the correctness of the version number and its compatibility binding identifier generated by the build process.

[0058] Specifically, in the existing process, the incrementing of version numbers and the encoding and correspondence between the binding identifiers between the installation package and hot update resources still mainly rely on manual maintenance in multiple configuration files, lacking a mechanism to automatically complete version evolution, segmented coding, and binding key generation at the build end.

[0059] Specifically, if there is a manual increment or labeling error, even if there is a verification on the device side, it will be meaningless due to the error of the binding key itself, which will still cause mismatch or failure to update when it should.

[0060] Specifically, the sixth drawback is that the build environment is large and difficult to distribute and deploy quickly with the project.

[0061] Specifically, a complete build environment can be several gigabytes in size, making it impractical and slow to distribute directly with the project.

[0062] Specifically, if the conventional approach of directly tiling the image layer is adopted, the image layer becomes bloated, and the process of pulling and initial startup is slow, which further exacerbates the problems of environment consistency and rapid readiness.

[0063] The core concept of this application is to institutionalize and determinize the two aspects of the build environment and build process, which have traditionally relied on manual guarantees, through toolchain solidification and encapsulation, first-run delayed restoration, and automated orchestration pipeline driven by single command parameters.

[0064] Specifically, the solution is supplemented by differentiated configuration injection of heterogeneous project files, segmented encoding and automatic carry evolution of four-segment version numbers, isolation of suffixes for multiple environments and projects, and fully offline compilation, which fundamentally solves the above-mentioned shortcomings of existing technologies.

[0065] Specifically, compared with existing technologies, its substantial differences are reflected in four key shifts.

[0066] Specifically, the first point is to shift the environment from being manually built by various robots and relying on their own initiative for consistency to being fixed once, restored as needed, and consistent everywhere.

[0067] Specifically, the second point is that the build process has changed from manually executing dozens of commands sequentially and modifying configurations one by one to a single command carrying parameters and the entire process being automatically orchestrated by the program.

[0068] Specifically, the third point is that configuration and version management has evolved from manual, decentralized maintenance that is prone to mismatches to automatic injection based on file type, segmented encoding of version numbers, and automatic carry-over.

[0069] Specifically, the fourth point changes the dependency acquisition process from downloading from the network during the build process to offline built-in and on-site access.

[0070] To facilitate understanding of this application, the following is combined with... Figure 1 The flowchart illustrating the automated construction, packaging, and deployment method for mobile applications provided in Embodiment 1 of this application will be described in detail for Embodiment 1 of this application.

[0071] See Figure 1 As shown, Figure 1 The flowchart illustrates a method for automated building, packaging, and deployment of mobile applications according to Embodiment 1 of this application, wherein the method includes steps S101 to S105: S101: Encapsulate the build toolchain and build dependencies into a self-contained archive and embed it in the container image; when the container starts, use the existence of the flag directory as a criterion. If the flag directory does not exist, restore the archive to the target path in a streaming manner all at once. If the flag directory exists, skip the restoration.

[0072] Specifically, the container image adopts a layered encapsulation design, with a general system base layer image as the foundation. The top layer only fixes environment variables, offline Gradle distribution address, working directory and startup entry metadata. Toolchain and dependencies are encapsulated in the lower layer image, realizing a layered structure of "toolchain in the lower layer and metadata in the upper layer". When iterating the top layer metadata, there is no need to re-encapsulate the huge toolchain layer, which improves the efficiency of image iteration.

[0073] Specifically, the self-contained archive packages the JDK, Android SDK, Gradle builder, Node.js runtime, Cordova command-line tools, all front-end and native build dependencies, and the project skeleton into a single, highly compressed archive file. It is preferably archived in tar (Tape Archive) format compressed with zstd (Zstandard, a high-efficiency compression algorithm), named as env_bundle.tar.zst, and is built into the container image and distributed along with the image. The host machine does not need to pre-install any build tools, nor does it need to download dependencies online during the build process.

[0074] Specifically, the components and their corresponding versions in this embodiment are all fixed versions, including JDK 8, Android SDK with android-29 platform and build-tools 30.0.3, Gradle 6.7, Cordova 11.1.0, cordova-hcp, gulp, polymer-cli and corresponding node_modules dependencies. The versions are fixed throughout the process and do not change dynamically with the build.

[0075] Specifically, the flag directory is a preset fixed path, which is / opt / jdk8 in this embodiment. Its existence is the idempotency criterion for the completion of environment restoration. This restoration mechanism works at the application layer and is executed locally by the container startup script on the self-contained archive. It does not rely on FUSE (Filesystem in Userspace) file system agents, snapshotters, or any container runtime extensions. It can be equivalently implemented on any container engine that is compatible with the OCI (Open Container Initiative) specification, or even on bare metal or virtual machines.

[0076] Specifically, after the container starts, the entry script will first explicitly solidify environment variables such as JAVA_HOME, ANDROID_HOME, and GRADLE_HOME, as well as the system PATH, to prevent the loss of environment variables at runtime. At the same time, it will pre-configure build tuning parameters for the "one-time use" feature of the container, including disabling the Gradle daemon, enabling parallel builds and on-demand configuration, expanding JVM heap memory and metaspace, and enabling Gradle offline mode to adapt to offline builds and one-time run scenarios.

[0077] Specifically, after the environment is restored, the entry script promotes the build orchestrator to the container master process through the exec instruction, ensuring that system signals can be passed through to the orchestrator and that the lifecycle of the orchestrator is consistent with the lifecycle of the container.

[0078] Specifically, the idempotency criterion for the existence of the marker directory can be equivalently replaced by methods such as verifying a dedicated marker file, comparing version stamps, comparing content checksums, or comparing mirror layer identifiers, all of which can achieve a self-healing environment supply effect of "first restoration, subsequent skipping".

[0079] S102: Receive a single command containing action parameters and environment parameters, and parse the action parameters and environment parameters from the parameter list of the command.

[0080] Specifically, a single command is received by the host script and uses the concatenation format of "action:environment", such as build:dev, update:uat, etc. The action parameter includes types such as build and hot update, and the environment parameter includes types such as dev (development, development environment), uat (user acceptance test, user acceptance test environment), and prod (production, production environment).

[0081] Specifically, after the host script completes parameter validation, it concatenates the parameters into a single action string and injects it into the build orchestration program inside the container through the container environment variables. Users only need to execute one command to trigger the entire build process, without having to manually execute dozens of commands sequentially.

[0082] Specifically, the host machine provides cross-platform one-click scripts, including mobile-build.sh for Linux / macOS and mobile-build.bat for Windows, which encapsulate container startup parameter concatenation and mount directory verification, shielding command differences between different operating systems and lowering the barrier to entry for users.

[0083] Specifically, the parameter parsing uses a subtraction filtering parsing logic. After filtering out the identified action parameters, environment parameters, and flag parameters from the parameter list, the first remaining parameter is taken as the optional item suffix. It does not depend on the arrangement of parameters in the command, and can be robustly parsed even if the order of parameters changes.

[0084] Specifically, after the parameters are parsed, the orchestration program will perform workspace preparation operations: dynamically construct the input configuration file, source code package and output directory path according to the parsed parameters, and perform a pre-existence check on the input files.

[0085] Specifically, a read-only pre-scan is then performed on the source code compressed package to remove system noise files such as __MACOSX and .DS_Store, and the top-level structure of the archive is determined. If the top-level is uniquely an app directory, it is decompressed in place; otherwise, a new app directory is created, the package is wrapped, and then it is decompressed, adapting to different source code compression habits.

[0086] Specifically, file permission bits are preserved during decompression, and the fsync disk synchronization call can be intercepted through the eatmydata tool to accelerate the expansion speed of a large number of small files. This disk acceleration method can be equivalently replaced by other I / O (Input / Output) acceleration methods such as tmpfs (Temporary File System) and RAM disk, without affecting the core performance.

[0087] Specifically, the adaptive criteria for source code compressed packages can be generalized to determine the characteristics of any agreed-upon top-level flag directory or manifest file, adapting to different project packaging specifications.

[0088] S103: Based on the evolution version number of the action parameters and according to the different formats of the target files, configure and inject the configurations of multiple heterogeneous project configuration files respectively.

[0089] Specifically, the orchestration program first parses the .env environment file line by line using regular expressions to extract basic configuration information such as the current backend interface address, hot update distribution address, current version number, application display name, and application package name, which serve as the baseline data for version evolution and configuration injection.

[0090] Specifically, configuration injection covers all build configuration items scattered across multiple file formats, replacing the manual operation of locating and modifying each item one by one. A single driver can complete configuration synchronization across multiple files and formats, avoiding omissions and errors caused by manual modifications and significantly reducing the probability of configuration errors.

[0091] Specifically, the rewriting methods for various types of files can be equivalently replaced by AST rewriting, XPath (XML Path Language) / JSONPath (JSON Path Language) positioning, DOM (Document Object Model) operations, template engine rendering, or line-level patching, etc., without affecting the core effect of "one-time driver to complete cross-file and multi-format configuration synchronization".

[0092] Specifically, after the version evolution is completed, it will first be written to the runtime environment variables for subsequent compilation, hot update configuration generation and other stages to read and use. This stage is a memory-level configuration update and is not directly persisted to the mount file.

[0093] S104: Compile the project source code using the restored build toolchain and build dependencies to generate compilation artifacts and specify the output directory.

[0094] Specifically, the compilation process is executed entirely offline, with all dependencies coming from a restored, solidified environment. The Gradle distribution package is referenced via a local file: / / path, eliminating the need to connect to the internet to pull the Gradle distribution package, native Android dependencies, or npm packages. It can complete the build normally even in environments with physical isolation within an intranet, unreachable dependency repositories, or weak network conditions, thus solving the problem of existing technologies heavily relying on the network.

[0095] Specifically, the pre-compilation program dynamically modifies the application package name in the native build file based on the configuration, enabling a single source code to dynamically generate installation packages with different package names according to the configuration, thus adapting to the parallel package generation needs of multiple customers and multiple projects.

[0096] Specifically, the compilation process supports two branches: full mode and fast mode, which can be switched using the --fast flag parameter to adapt to different build scenarios. Both modes use the same front-end source files, and the only difference is whether or not to perform the component-based build step. The other file reading and copying logic is completely the same.

[0097] Specifically, if a build action is performed, the native compilation process will be entered after the front-end resources are compiled. The Cordova tool will be called to compile the Android installation package, generating the APK installation package artifact and the hot update resource artifact. If only the hot update action is performed, only the hot update resource artifact will be generated, and the native compilation steps will not be performed.

[0098] Specifically, this solution is implemented using the Android platform as an example, but its core concept can be equivalently migrated to other mobile platforms such as iOS.

[0099] Specifically, considering the one-time use characteristic of containers, a complete set of performance optimizations is provided during the compilation phase. In addition to offline mode, daemon process shutdown, and parallel compilation configuration on the Gradle side, it also includes expanding the memory of the Node.js old generation heap to avoid memory overflow during the build of large projects.

[0100] S105: The compiled output is collected into the output directory, and the evolved version number is written back for use in subsequent builds.

[0101] Specifically, before the products are collected, a clean output directory is created according to the environment and project suffix. If the directory already exists, it is cleared and then rebuilt to avoid interference from historical product residues.

[0102] Specifically, during the build process, the generated debug APK file is located, renamed to "application_name_v_version_number.apk", and output to the target directory. Hot update resources are packaged into "www_v_version_number.zip" after removing the general chcp.json configuration file and output synchronously.

[0103] Specifically, the system will automatically identify illegal characters in the application name and remove or replace them to avoid path resolution errors caused by special characters in the application name, without the need for manual processing in advance.

[0104] Specifically, the evolved version number will be written back to the .env file in the mount area for persistent storage, forming a complete automated closed loop of "reading the old version → version evolution → building and using → writing back the new version". The next build can directly increment based on the written-back version number without the need for manual maintenance of the version status.

[0105] Specifically, version evolution and write-back are divided into two stages: the configuration injection stage evolves the version number and writes it into the runtime environment variables for subsequent compilation stages to read and use; the artifact collection stage writes back the final version number to the mount area configuration file. The target objects of the two operations are different, so there is no problem of version duplication and overwriting conflict.

[0106] Specifically, the orchestration program is upgraded to the container master process via exec, ensuring signal penetration and lifecycle consistency. If the program crashes abnormally or exits voluntarily, the container exit code can be used in conjunction with the build log to determine the build status. Logs are continuously output throughout the build process, and the CI system can accurately identify the build success or failure status through the log content.

[0107] In an alternative implementation, the action of encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it within the container image is included, wherein the self-contained archive is an archive file compressed using a high compression ratio algorithm.

[0108] Specifically, the preferred high compression ratio algorithm is zstd, which features high compression ratio and high-speed decompression via multi-threading. It can compress a complete build environment with a restored size of approximately 1.2GB to a few hundred MB, effectively reducing the image size and improving image distribution and transmission efficiency.

[0109] Specifically, the compression algorithm can be replaced with other compression algorithms such as gzip, xz, bzip2, lz4, and 7z. The archive format can adopt a multi-volume or layered structure. The restoration method can also be replaced with first storing and then unpacking. None of these will affect the core effects of solidified packaging and offline restoration.

[0110] Specifically, the components archived in this embodiment and their restored size are approximately 190MB of JDK 8, approximately 420MB of Android SDK, approximately 360MB of Gradle 6.7, and approximately 290MB of project skeleton and Node dependencies. The restored overall environment is approximately 1.2GB. All components are the complete toolchain and dependencies required for building, and can be used directly after restoration.

[0111] See Figure 2 As shown, Figure 2 The flowchart of a one-time streaming restoration method provided in Embodiment 1 of this application is shown, wherein the action of restoring the archive to the target path in a streaming manner in one go includes steps S201~S203: S201: Decompress the archive using a multi-threaded approach to obtain a decompressed data stream.

[0112] Specifically, decompression is enabled by using the -T0 parameter of zstd to enable full-core multi-threaded decompression, which can make full use of the host machine's CPU computing power, significantly shorten the decompression time of large archives, and adapt to the restoration needs of multi-GB build environments.

[0113] Specifically, the decompression process directly outputs a continuous stream of decompressed data, eliminating the need to generate complete intermediate decompressed files first, thus reducing disk I / O overhead.

[0114] S202: The decompressed data stream is fed directly into the de-archiving tool through the pipeline, and the de-archiving tool reads the decompressed data stream from the pipeline and expands it to the target path on the spot.

[0115] Specifically, the decompression tool is the tar program. The decompressed data stream is directly transferred to the tar program through the operating system pipe, without leaving large intermediate files on the disk. This saves temporary disk storage space and avoids the additional performance loss caused by reading and writing intermediate files.

[0116] Specifically, the restored files are expanded to the system target directory according to a preset path. In this embodiment, they are expanded to the / opt directory to form a complete and usable build environment.

[0117] Specifically, the actual measured time of this streaming restoration process is on the order of tens of seconds, with the specific duration affected by the number of CPU cores and storage I / O performance of the host machine. After the restoration is completed, the environment directory is fixed and can be reused directly when the container starts in the future, without having to repeat the restoration operation, thus achieving "one-time restoration, multiple reuses".

[0118] S203: If any step fails, the restoration will be aborted and the system will exit with a non-zero exit code.

[0119] Specifically, this design incorporates a failure safety mechanism. If an exception occurs in any step of the decompression or unarchiving process, the entire process will immediately terminate and return a non-zero exit code, preventing the partially corrupted build environment from being misused in subsequent build processes.

[0120] Specifically, this mechanism ensures that the restored build environment is complete and usable, avoiding build anomalies caused by incomplete environments.

[0121] Specifically, in conjunction with the idempotent judgment logic of "skipping if the flag directory exists", the entire environment supply mechanism has self-healing idempotent characteristics, and the results of multiple runs are completely consistent, eliminating the environment difference problem of "different results for the same code, and others can attack but I can't" caused by manually built environments.

[0122] In an optional implementation, in the action of evolving the version number according to the action parameters, the version number includes segments A, B, C and D arranged in sequence, wherein segments A and B constitute the major version identifier of the installation package, and segments C and D constitute the hot update count.

[0123] Specifically, the version number uses a four-segment dotted-point coding system, and the complete formula is: Version number = ABCD The unique definition of each character in the formula is as follows: A: The main version number of the installation package represents a major architectural iteration or disruptive update of the application, and is a non-negative integer; B: Package version number, representing regular function iterations or new features added to the application, and is a non-negative integer; C: Hot Update Master Count, representing the number of hot update master iterations under the same major version, and is a non-negative integer; D: Hot update counter, representing the number of hot update iterations under the same major version, and is a non-negative integer; Segment A and segment B together form the major version compatibility key of the installation package, which is used to identify the compatibility boundary of the installation package; segment C and segment D together form the hot update count, which is used to count the number of hot update releases under the same major version.

[0124] Specifically, the four-segment version encoding is the preferred solution, which can be equivalently replaced by other versions with three or five segments, or by other version systems such as semantic versioning (SemVer). As long as the core constraint of "hot updates are strongly bound to the major version of the installation package and hot updates are only allowed if the major version is consistent" is retained, it is acceptable.

[0125] The version number evolution includes: When the action parameter is a construction action, segment B is carried over. If segment B exceeds the threshold, it is carried over to segment A, and segments C and D are forced to zero.

[0126] Specifically, in the scenario where the build action corresponds to generating a new installation package, the carry threshold is preferably set to 99. That is, when the value of segment B increases to more than 99, segment B is reset to 0, and the value of segment A is incremented by 1 to complete the high-order carry.

[0127] Specifically, when the build action is triggered, segments C and D are forcibly reset to 0, so that the hot update count is re-accumulated from the new major version base point, and the coding rules ensure that hot update resources are only compatible with installation packages of the same major version.

[0128] Specifically, the version evolution logic under the build action can be represented by the following processing formula and process: Let the current version's split numerical array be parts = [A, B, C, D], and the carry threshold be T (default T = 99), then: 1. Minor version number carry: parts[1] = parts[1] + 1 2. High-order overflow determination: If parts[1] > T, then parts[1] = 0, parts[0] = parts[0] + 1 3. Reset the heat exchange counter to zero: parts[2] = 0, parts[3] = 0 4. Concatenate the new version: The new version number is parts[0].parts[1].parts[2].parts[3] In the above formula, parts[0] corresponds to segment A, parts[1] corresponds to segment B, parts[2] corresponds to segment C, and parts[3] corresponds to segment D. Each variable corresponds one-to-one with the four-segment encoding definition.

[0129] The parts are uniquely defined as the numerical array obtained after splitting the version number, corresponding to the four version bits in index order; T is uniquely defined as the version number carry-over threshold, and has no other meaning reused throughout.

[0130] When the action parameter is a hot-up action, segment D carries over; if segment D exceeds the threshold, then segment C carries over.

[0131] Specifically, the hot update action corresponds to the scenario of only releasing hot update resource packages. The carry threshold is consistent with the build action, preferably 99. That is, when the value of segment D is greater than 99 after incrementing, segment D is reset to 0, and the value of segment C is incremented by 1 to complete the high-order carry of the hot update count.

[0132] Specifically, the hot update action only modifies the low-level hot update counter segment, without changing the major version identifier of the installation package in segments A and B.

[0133] Specifically, the version evolution logic under a hot update can be represented by the following processing formula and flow: Let the numeric array after splitting in the current version be parts = [A, B, C, D], and the carry threshold be T (consistent with the build action definition, default T=99), then: 1. Hot-changing carry over the next bit: parts[3] = parts[3] + 1 2. High-order overflow determination: If parts[3] > T, then parts[3] = 0, parts[2] = parts[2] + 1 3. Concatenate the new version: The new version number is parts[0].parts[1].parts[2].parts[3] In the above formula, parts[0]-parts[3] correspond to version numbers A, B, C, and D respectively, which are completely consistent with the variable definitions of the construction action formula, without any new additions or reuses.

[0134] In an optional implementation, the action that evolves the version number according to the action parameter further includes: Based on the evolved A segment and B segment, a hot update configuration file name is generated, so that the hot update configuration file and the major version of the installation package are associated at the naming level.

[0135] Specifically, the naming format for hot-update configuration files is as follows: chcp_vA.B.json Both A and B use the unified definition of the four-segment version number, corresponding to the A and B segment values ​​of the evolved version number, respectively, without adding any new variables or semantic ambiguity.

[0136] Specifically, during the build process, the project's www directory is scanned, and existing general hot-update configuration files are copied to generate corresponding major version hot-update configuration files, so that the hot-update configuration file names and the major versions of the installation packages explicitly correspond one-to-one at the naming level.

[0137] Specifically, this naming rule works in conjunction with the four-segment version encoding and the mechanism of resetting the hot update count to zero when a major version is carried over, so that the version correspondence between the installation package and the hot update package is automatically guaranteed by the encoding rule itself, without the need for manual judgment and maintenance of compatibility relationships.

[0138] Specifically, this mechanism, on top of the device-side runtime compatibility verification of the existing hot-update framework, further reduces the probability of human mismatch from the build stage, thereby reducing white screen and crash issues caused by hot-update mismatches from the source.

[0139] In an optional implementation, the configuration injection process, which involves injecting configuration into multiple heterogeneous project configuration files according to different target file formats, includes: For JavaScript constant files, use regular expressions with paired backreferences in quotes to replace and rewrite them.

[0140] Specifically, JavaScript constant files are usually front-end constant definition files such as const.js, and the modified content includes configuration items such as back-end interface address, version identifier, and East 8 time zone release time.

[0141] Specifically, regular expressions with backreferences in quotes can accurately match constant assignment statements with single or double quotes, replacing only the configuration value within the quotes without changing the variable name or code logic, thus avoiding accidental modification of business code and adapting to the text format characteristics of JS files.

[0142] The XML (Extensible Markup Language) format configuration file is rewritten using defensive XML-AST (Abstract Syntax Tree) parsing.

[0143] Specifically, the XML format configuration file is mainly the core configuration file config.xml of the Cordova framework. The modified content includes the application display name, the hot update distribution address named according to the major version, etc.

[0144] Specifically, defensive parsing refers to traversing level by level to check for empty nodes before rewriting. If the target node is missing, the corresponding node and level are created as needed. After the modification is completed, the file is beautified, serialized, and written back to the original file. This can avoid configuration failure caused by XML tag mismatch and missing nodes, and ensure the structural legality of the configuration file.

[0145] The JSON (JavaScript Object Notation) formatted configuration file is rewritten using JSON parsing.

[0146] Specifically, the JSON format configuration file is mainly the cordova-hcp.json hot update configuration file, and its content is rewritten to include the hot update resource distribution address.

[0147] Specifically, by parsing and reading the entire content of the file using structured JSON, modifying the corresponding fields, and then re-serializing it into standard JSON format for writing back, this method completely avoids JSON syntax errors compared to regular expression rewriting, ensuring that the configuration file format is always compliant.

[0148] For Gradle build files, rewrite the application package name using regular expressions with global flags.

[0149] Specifically, the Gradle build file is the build.gradle file that is built natively in Android, and its content is modified to include the applicationId, which is the native application package name.

[0150] Specifically, regular expressions with global flags can match all applicationId declaration lines in the file, avoiding only hitting related content in comments without modifying the actual effective configuration.

[0151] Specifically, if no applicationId declaration is found in the file, the system will fall back to the beginning of the defaultConfig code block to insert the configuration, ensuring that the package name change takes effect. This allows a single source code to dynamically generate installation packages with different package names based on the configuration.

[0152] In an optional implementation, see Figure 3 As shown, Figure 3 The flowchart of a project isolation method provided in Embodiment 1 of this application is shown, wherein the action of parsing the action parameters and the environment parameters from the parameter list of the command further includes steps S301-S302: S301: After filtering out the identified action parameters, environment parameters and flag parameters from the parameter list, take the first remaining parameter as the project suffix parameter.

[0153] Specifically, this parsing method is a subtractive filtering parsing. The identified parameters include action parameters, environment parameters, and flag parameters such as --fast. The parsing does not depend on the order of the parameters in the command. Even if the order of the parameters changes, the item suffix can still be robustly extracted, improving the fault tolerance and flexibility of parameter parsing.

[0154] S302: Dynamically construct the input file path and output directory path based on the project suffix parameter to achieve isolation between different projects.

[0155] Specifically, the input configuration file, source code package, and output directory will all be matched with the corresponding suffix names, such as init[-suffix].env environment configuration file, app[-suffix].zip source code compressed package, and output[-suffix] / output directory.

[0156] Specifically, the build resources for different customers and projects are distinguished by suffixes, so that multiple projects can be processed in parallel under the same mount directory, and the configuration, intermediate products and output results do not contaminate or interfere with each other.

[0157] Specifically, this mechanism also supports parallel deployment of multiple environments such as development, testing, and production. The configurations and artifacts of different environments are independent of each other, eliminating the need to repeatedly modify the same batch of configuration files. This avoids configuration overlay and misdeployment issues between different environments and projects, and greatly improves the efficiency and accuracy of multi-environment and multi-project deployment.

[0158] In an optional implementation, the action of compiling the project source code using the restored build toolchain and build dependencies includes: The complete compilation mode executes the following steps in sequence: project cleanup, front-end resource compilation, resource copying, front-end build tool compilation, and hot update resource packaging.

[0159] Specifically, the complete compilation mode corresponds to the full build scenario of the officially released installation package. The complete execution process is as follows: clean up the project → polymer build the front-end component compilation → resource copy → gulp build the front-end build → cordova-hcp build hot update resource packaging.

[0160] Specifically, during the build process, the Node.js old generation heap memory will be expanded to about 12GB to avoid memory overflow issues when building large projects; if it is a build action, Android native compilation will also be performed later in this mode to generate a publishable APK installation package.

[0161] The fast compilation mode skips the compilation of the front-end resources and only performs the project cleanup, resource copying, and hot update resource packaging.

[0162] Specifically, the fast compilation mode is for debugging and iteration scenarios that only release hot update resources. It skips the time-consuming polymer build component compression build step and only performs gulp clean project cleaning → resource copying → cordova-hcp build hot update packaging.

[0163] Specifically, this mode can significantly shorten the build time of hot-update versions and improve the efficiency of development, debugging, and hot-update iteration.

[0164] Specifically, the quick mode and the full mode use the same front-end source files. The only difference between the two is whether or not the component-based build step is performed. The other file reading and copying logic is completely the same, ensuring that the hot-update resource structure generated in both modes is fully compatible with the installation package environment.

[0165] In combination with the above technical solutions, this application can produce five core beneficial effects compared with the prior art, and each effect corresponds one-to-one with the defects of the prior art.

[0166] Specifically, the first beneficial effect is that the construction results are reproducible, completely eliminating environmental differences.

[0167] Specifically, the toolchain is solidified and restored on demand, and any machine can restore a byte-by-byte consistent environment, eliminating the environment consistency problem of "same code, different results" and "others can do it but I can't", which addresses the first defect of the existing technology.

[0168] Specifically, the second beneficial effect is that it eliminates the need for repeated setup, is ready to use out of the box, is fully offline and self-sufficient, and has a lightweight distribution capability.

[0169] Specifically, the entire build toolchain and dependencies are fixed together, and with idempotent streaming delayed restoration that skips dependencies as they exist, users can obtain deterministic build capabilities that are consistent byte by byte and completely offline without having to repeatedly install, configure and verify this version-sensitive and complex toolchain on each local machine.

[0170] Specifically, this solution compresses the environment preparation work, which originally took several hours and was highly dependent on the engineer's experience, into a one-time automatic restoration triggered by a single command. It can be reused after the first restoration and can be fully built even in physically isolated intranet environments and weak network environments. This mechanism eliminates the dependence on human intervention and network connectivity in the construction environment, and addresses the second and sixth defects of existing technologies.

[0171] Specifically, the third beneficial effect is one-click configuration with zero manual changes, which significantly reduces the error rate.

[0172] Specifically, a single command drives the entire closed-loop process, rewriting according to format differences to replace manual, scattered modifications of multiple files, eliminating omissions and errors, and addressing the third defect of existing technologies.

[0173] Specifically, the fourth beneficial effect is the parallel operation and strict isolation of multiple environments and projects.

[0174] Specifically, suffix parameterization enables the inputs, outputs, and configurations of multiple servers and multiple client projects to be independent and free from interference, thus addressing the fourth defect of existing technologies.

[0175] Specifically, the fifth beneficial effect is that the version order is automatically maintained by the program, significantly reducing the probability of mismatch.

[0176] Specifically, the four version numbers are automatically incremented according to the action, the hot update count is automatically reset to zero when there is a major version change, and the hot update configuration is automatically named according to the major version segment. This ensures that the version correspondence between the installation package and the hot update package is guaranteed by the coding rules and automatic evolution itself, eliminating the need for manual judgment and maintenance of version numbers.

[0177] Specifically, this solution further reduces the probability of human mismatch on top of the existing thermal compatibility capability, thus addressing the fifth defect of the existing technology.

[0178] The core mechanism involved in this solution is fundamentally different from the three mainstream prior technologies. The innovation lies not in the individual technologies themselves, but in the organic integration aimed at a specific goal.

[0179] Specifically, the first type of comparison technology is container image lazy fetching technology, represented by Red Hat related patents, containerd stargz-snapshotter and other solutions.

[0180] Specifically, lazy fetching works at the container runtime layer, pulling and mounting image layering content on demand through the FUSE file system agent or snapshotter, relying on the container runtime's scalability.

[0181] Specifically, the restoration mechanism of this solution operates at the application layer. The container startup script performs a one-time streaming expansion to the local file system based on the idempotent criterion of the existence of the flag directory for the single self-contained business archive pre-built in the image. It does not rely on FUSE, snapshotters or any container runtime extensions and can be equivalently implemented on any OCI-compatible container engine or even bare metal or virtual machine.

[0182] Specifically, the second type of comparison technology is the version compatibility verification mechanism of hybrid application hot update frameworks, represented by solutions such as cordova-hot-code-push and Meteor Cordova hot update.

[0183] Specifically, existing hot update frameworks provide a verification capability on the device runtime side that "hot updates are only applied when the versions are compatible," and this verification applies to the application stage after the hot update resources are distributed; while this solution applies to the version generation stage on the build side, and the two are at different stages of the process and solve different technical problems.

[0184] Specifically, this solution advocates a version generation mechanism on the build side, which uses a four-segment coding system, forces the hot update count to zero during the build process, and names the hot update configuration according to the major version segment. During the build process, the version number evolution, segmented coding, and binding identifier generation are automatically completed, so that the version correspondence is guaranteed by the coding rules themselves, without the need for manual judgment each time.

[0185] Specifically, the third category of comparison technologies consists of online CI packaging platforms, such as Jenkins, GitLab CI, and GitHub Actions.

[0186] Specifically, online CI platforms pull dependencies over the network during the build process and do not have full offline capability; their environment is usually dynamically installed in the pipeline script, and the consistency of each build depends on the stability of the remote dependency repository.

[0187] Specifically, this solution pre-packages the entire toolchain within the image archive, integrating it with the orchestration logic of the build process. It can still complete end-to-end compilation and packaging even in a completely offline environment, and the environmental consistency is guaranteed by the solidified archive mechanism.

[0188] The innovation of this application is an integrated solution for deterministic, offline, and automated mobile application packaging and hot update management.

[0189] Specifically, the Apache Cordova hybrid application framework, cordova-hot-code-push hot update framework, Polymer / Gulp front-end build system, Gradle and Android SDK native build system, zstd compression algorithm, OCI container specification, etc. involved in the solution are all publicly available existing technologies.

[0190] Specifically, the innovation of this application lies not in the individual technologies mentioned above, but in the organic integration of various key technical means toward a specific goal, forming a complete solution that is difficult for a person skilled in the art to obtain without creative labor, and possessing outstanding substantive features and significant progress.

[0191] This solution has been developed into a complete and runnable software implementation. It has been verified by actual projects and can run on any container engine that supports the OCI specification. The host machine does not need to pre-install any build toolchain and does not need to be connected to the internet.

[0192] Specifically, the complete implementation includes six core components, each with clearly defined responsibilities, working together to complete the entire construction process.

[0193] Specifically, the first component is a layered container image, with the corresponding file name being mobile-builder v1.4. It is based on the system base layer, with the top layer containing fixed environment variables, offline Gradle distribution address, working directory, and startup entry point. The toolchain is encapsulated at the bottom layer, so there is no need to rebuild the huge toolchain layer during top-level iterations.

[0194] Specifically, the second component is the startup entry script, with the corresponding file name entrypoint.sh. It is responsible for the secondary solidification of runtime environment variables and tuning parameters, and determines whether restoration is needed based on the existence of the flag directory. On the first run, it performs streaming decompression and restoration, and skips it in subsequent runs. Finally, it promotes the orchestration program to the main process using exec.

[0195] Specifically, the third component is the build orchestration program, with the corresponding file name build.js. It implements the complete logic of the five-step build pipeline and is the core of the automated process execution.

[0196] Specifically, the fourth component is the environment solidification package, with the corresponding file name env_bundle.tar.zst. It encapsulates the entire toolchain, dependencies, and project skeleton into a single zstd compressed archive, which is built into the image and expanded to the / opt directory after restoration.

[0197] Specifically, the fifth component is a cross-platform one-click script, with corresponding filenames mobile-build.sh and mobile-build.bat. As the host machine entry point, it encapsulates container startup parameter concatenation and mount directory verification, allowing users to trigger a complete build with just one command.

[0198] Specifically, the sixth component is the user manual, with the corresponding file name being Mobile One-Click Packaging User Manual_V1.4.md. It records parameter descriptions, directory conventions, configuration examples for multiple environments and multiple project suffixes, and solutions to common problems.

[0199] The core terms and abbreviations involved in this plan have clear and unified definitions.

[0200] Specifically, solidified encapsulation refers to packaging the entire build toolchain and dependencies into a single self-contained archive, built into the image, and not relying on runtime network access to obtain it.

[0201] Specifically, delayed restoration and idempotent restoration refer to the process of decompressing and expanding the solidified archive to the target path on the first run, and skipping it directly if the marked directory already exists in subsequent runs, thus ensuring consistent results across multiple runs.

[0202] Specifically, the flag directory refers to the target path used to determine whether restoration is needed. In this implementation, it is / opt / jdk8, and its existence is the idempotent criterion for restoration completion.

[0203] Specifically, the major version key, which is the AB segment of the four version numbers, identifies the major version compatibility of the installation package, and the hot update configuration file is named according to this segment.

[0204] Specifically, the hot update count is a CD segment of four version numbers, which automatically increments with each hot update release, but is forcibly reset to zero and re-accumulated from the new major version when a build occurs.

[0205] Specifically, differential configuration injection refers to selecting the corresponding rewriting strategy according to the target file format: regular expressions for JS constants, AST parsing for XML, structured parsing for JSON, and regular expressions with global flags for Gradle.

[0206] Specifically, subtraction filtering parsing refers to filtering out identified actions, environments, and flags from the parameter list and taking the first remaining one as an optional suffix, regardless of the parameter position.

[0207] Specifically, the project suffix is ​​an optional parameter that drives the overall naming of input files and output directories, enabling isolation between multiple projects.

[0208] Specifically, CHCP (Cordova Hot Code Push) is short for cordova-hot-code-push, a hot update plugin for Cordova hybrid applications that supports pushing www resource packages to devices and automatically applying them when the versions are compatible.

[0209] Specifically, eatmydata is a utility library that intercepts disk synchronization calls such as fsync / fdatasync, used to accelerate I / O throughput when decompressing a large number of small files.

[0210] See Figure 4 As shown, Figure 4 This diagram illustrates the overall process flow of one-click automated packaging and hot update of a mobile application provided in Embodiment 1 of this application, corresponding to the entire execution chain of the automated building, packaging, and deployment method for mobile applications described in this application. The process begins with a single user command as the trigger entry point, sequentially proceeding through container environment initialization, self-healing environment delayed restoration, and a five-step core build pipeline, ultimately achieving standardized output and version status closure. The complete content and technical meaning of each step in the diagram are as follows: 1. Command Trigger Entry Point. When a user executes a single command `. / mobile-build.sh build:dev [mea]`, the host script receives the command, appends the ACTION parameter, and injects it into the container via the container environment variables. This passes the user's action, environment, project suffix, and other parameters to the build process within the container.

[0211] 2. Step Zero: Container entry point.sh. After the container starts, it first enters the entry point script execution phase, completing the preparatory operations of secondary solidification of environment variables and Gradle / JVM tuning to ensure the stability of runtime environment parameters, and then enters the environment restoration determination phase.

[0212] 3. Environment Delayed Restore Idempotency Determination. The idempotency criterion for whether to restore is "Does the flag directory / opt / jdk8 already exist?", resulting in two branches: If the result is no (first run), a one-time streaming restore of `zstd -d -T0 | tar -x` is executed, without leaving intermediate files on the disk, completing the in-situ unpacking of the entire build toolchain and dependencies; if the result is yes (cache hit), the restore step is skipped, and the already ready build environment is reused.

[0213] 4. Start the core orchestration program. Once the environment is ready, start the build orchestration program using the command `exec npm run ${ACTION}`. The actual execution is `node build.js<action><environment>[suffix]`, which passes the parsed action, environment, and project suffix parameters to the core orchestration logic, thus officially starting the five-step build pipeline.

[0214] 5. Step 1: Prepare the workspace: This step completes the workspace initialization and source code preprocessing before building: It uses subtraction filtering to parse the project suffix `suffix`, regardless of the order of parameters in the command; it locates and verifies the existence of input files such as `init[-suffix].env` and `app[-suffix].zip`; it performs a read-only pre-scan of the top-level structure of the source code package, adaptively choosing to unzip in place or wrap the app / directory before unzipping, to be compatible with different source code packaging habits.

[0215] 6. Step Two: Configuration Injection and Version Evolution. This step completes the automatic injection of all configuration items and the automatic evolution of version numbers: It parses the .env file, calls the bumpVersion logic to automatically carry over the four version numbers (A, B, C, D), and writes back the runtime environment variables; it rewrites the const.js file using regular expression injection to update configurations such as interface address, version identifier, and release time; it rewrites the config.xml file using AST parsing to update configurations such as application name and CHCP hot update address; and it rewrites the cordova-hcp.json file using structured parsing to update the hot update resource distribution address.

[0216] 7. Step 3: Compile (Dual Mode). This step supports both full and fast compilation modes, and performs native compilation as needed: The execution chain for full compilation mode is: `polymer build → gulp build → cordova-hcp build`; the execution chain for fast compilation mode is: `gulp clean → resource copy → cordova-hcp build`, skipping the component-based build step to improve build speed; if it is a build action, it will also perform the native compilation process of rewriting applicationId and calling `cordova build android`, ultimately producing an APK installation package.

[0217] 8. Action type branch determination. Determine if the current action is build: If the result is yes, execute regular expressions to rewrite the applicationId in Gradle, and then execute `cordova build android` to complete the native compilation and generate the APK; if the result is no (update), skip the native compilation and directly enter the hot update configuration generation stage.

[0218] 9. Step Four: Generate Hot Update Configuration. Generate the corresponding `chcp_vA.B.json` hot update configuration file according to the major versions A and B of the installation packages, so that the hot update configuration and the major versions of the installation packages are explicitly bound together at the naming level.

[0219] 10. Step Five: Product Aggregation and Version Write-back. This step completes the standardized output of products and the persistence of version status, forming an automated closed loop: Create an output directory `output[-suffix]` with the project suffix; if the directory already exists, clear it first and then recreate it; output the installation package product `application_name_v_version.apk` and the hot update resource package `www_v_version.zip` according to the standard naming convention; write the evolved new version number back to the .env file to complete the persistence of version iteration for subsequent builds.

[0220] After all steps in the entire process are completed, the system enters the final state, outputs all build artifacts, and persists the version state.

[0221] Example 2 See Figure 5 As shown, Figure 5 This illustration shows a structural diagram of a mobile application automated building, packaging, and deployment apparatus provided in Embodiment 2 of this application, which includes: Container image 501 is used to encapsulate the build toolchain and build dependencies into a self-contained archive and embed it in the container image; and is used to, when the container starts, use the existence of a flag directory as a criterion, if the flag directory does not exist, restore the archive to the target path in a streaming manner all at once, and if the flag directory exists, skip the restoration. The receiving module 502 is used to receive a single command containing action parameters and environment parameters, and to parse the action parameters and environment parameters from the parameter list of the command; The configuration injection and version evolution module 503 is used to evolve the version number according to the action parameters and inject configuration into multiple heterogeneous project configuration files according to different formats of the target files. The compilation module 504 is used to compile the project source code using the restored build toolchain and the build dependencies, generate compilation artifacts, and specify the output directory; The product collection module 505 is used to collect the compiled products to the output directory and write back the evolved version number for subsequent builds.

[0222] In an optional implementation, the action of encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it in the container image is included, wherein the self-contained archive is an archive file compressed using a high compression ratio algorithm. When the container image performs a one-time streaming restoration of the archive to the target path, it is specifically used for: The archive is decompressed using a multi-threaded approach to obtain a decompressed data stream. The decompressed data stream is fed directly into the de-archive tool through a pipeline, and the de-archive tool reads the decompressed data stream from the pipeline and expands it locally to the target path; If any step fails, the restoration will be aborted and the system will exit with a non-zero exit code.

[0223] In an optional implementation, when the configuration injection and version evolution module executes the version number evolution according to the action parameters, the version number includes segments A, B, C and D arranged in sequence, wherein segments A and B constitute the major version identifier of the installation package, and segments C and D constitute the hot update count. The version number evolution includes: When the action parameter is a construction action, segment B is carried over. If segment B exceeds the threshold, segment A is carried over, and segments C and D are forced to zero. When the action parameter is a hot-up action, segment D carries over; if segment D exceeds the threshold, then segment C carries over.

[0224] In an optional implementation, the configuration injection and version evolution module is further used for: Based on the evolved A segment and B segment, a hot update configuration file name is generated, so that the hot update configuration file and the major version of the installation package are associated at the naming level.

[0225] In an optional implementation, when the configuration injection and version evolution module performs configuration injection on multiple heterogeneous project configuration files according to different target file formats, it is specifically used for: For JavaScript constant files, use regular expressions with paired backreferences in quotes to replace and rewrite them; For XML format configuration files, a defensive XML-AST parsing method is used to rewrite them; For JSON format configuration files, JSON parsing is used to rewrite them; For Gradle build files, rewrite the application package name using regular expressions with global flags.

[0226] In an optional implementation, the receiving module is further configured to: After filtering out the identified action parameters, environment parameters, and flag parameters from the parameter list, the first remaining parameter is taken as the project suffix parameter. The input file path and output directory path are dynamically constructed based on the project suffix parameter to achieve isolation between different projects.

[0227] In an optional implementation, when the compilation module performs compilation on the project source code, it is specifically used for: In full compilation mode, the following steps are executed sequentially: project cleanup, front-end resource compilation, resource copying, front-end build tool compilation, and hot update resource packaging. In the fast compilation mode, the compilation of the front-end resources is skipped, and only the project cleanup, resource copying, and hot update resource packaging are performed.

[0228] Example 3 Based on the same application concept, see [link / reference] Figure 6 As shown, Figure 6 This illustration shows a structural schematic diagram of a computer device provided in Embodiment 3 of this application, wherein, as shown... Figure 6 As shown, the computer device 600 provided in Embodiment 3 of this application includes: The computer device 600 includes a processor 601, a memory 602, and a bus 603. The memory 602 stores machine-readable instructions that can be executed by the processor 601. When the computer device 600 is running, the processor 601 communicates with the memory 602 through the bus 603. When the machine-readable instructions are executed by the processor 601, the steps of the automated construction, packaging, and deployment method for mobile applications shown in Embodiment 1 are performed.

[0229] Example 4 Based on the same concept, this application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, performs the steps of the mobile application automated building, packaging and deployment method described in any of the above embodiments.

[0230] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0231] The computer program product for automated building, packaging and deployment of mobile applications provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0232] The mobile application automated building, packaging, and deployment system provided in this application embodiment can be specific hardware on a device or software or firmware installed on the device. The device provided in this application embodiment has the same implementation principle and technical effects as the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.

[0233] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0234] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0235] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0236] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0237] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0238] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A method for automated building, packaging, and deployment of mobile applications, characterized in that, include: The build toolchain and build dependencies are encapsulated into a self-contained archive and built into the container image; When the container starts, the existence of the flag directory is used as a criterion. If the flag directory does not exist, the archive is restored to the target path in a streaming manner all at once. If the flag directory exists, the restoration is skipped. Receive a single command containing action parameters and environment parameters, and parse the action parameters and environment parameters from the parameter list of the command; Based on the evolution version number of the action parameters and according to the different formats of the target files, configuration injection is performed on multiple heterogeneous project configuration files respectively; The project source code is compiled using the restored build toolchain and build dependencies to generate compilation artifacts, and the output directory is specified. The compiled artifacts are collected into the output directory, and the evolved version number is written back for use in subsequent builds.

2. The method according to claim 1, characterized in that, In the action of encapsulating the build toolchain and build dependencies into a self-contained archive and embedding it into the container image, the self-contained archive is an archive file compressed using a high compression ratio algorithm; The action of restoring the archive to the target path in a streaming manner in one go includes: The archive is decompressed using a multi-threaded approach to obtain a decompressed data stream. The decompressed data stream is fed directly into the de-archive tool through a pipeline, and the de-archive tool reads the decompressed data stream from the pipeline and expands it locally to the target path; If any step fails, the restoration will be aborted and the system will exit with a non-zero exit code.

3. The method according to claim 1, characterized in that, In the action of evolving the version number according to the action parameters, the version number includes segments A, B, C and D arranged in sequence, wherein segments A and B constitute the major version identifier of the installation package, and segments C and D constitute the hot update count. The version number evolution includes: When the action parameter is a construction action, segment B is carried over. If segment B exceeds the threshold, segment A is carried over, and segments C and D are forced to zero. When the action parameter is a hot-up action, segment D carries over; if segment D exceeds the threshold, then segment C carries over.

4. The method according to claim 3, characterized in that, The action that evolves to the version number based on the action parameters also includes: Based on the evolved A segment and B segment, a hot update configuration file name is generated, so that the hot update configuration file and the major version of the installation package are associated at the naming level.

5. The method according to claim 1, characterized in that, In the action of injecting configuration into multiple heterogeneous project configuration files according to different target file formats, the configuration injection includes: For JavaScript constant files, use regular expressions with paired backreferences in quotes to replace and rewrite them; For XML format configuration files, a defensive XML-AST parsing method is used to rewrite them; For JSON format configuration files, JSON parsing is used to rewrite them; For Gradle build files, rewrite the application package name using regular expressions with global flags.

6. The method according to claim 1, characterized in that, The action of parsing the action parameters and the environment parameters from the parameter list of the command also includes: After filtering out the identified action parameters, environment parameters, and flag parameters from the parameter list, the first remaining parameter is taken as the project suffix parameter. The input file path and output directory path are dynamically constructed based on the project suffix parameter to achieve isolation between different projects.

7. The method according to claim 1, characterized in that, In the action of compiling the project source code using the restored build toolchain and build dependencies: The complete compilation mode executes the following steps in sequence: project cleanup, front-end resource compilation, resource copying, front-end build tool compilation, and hot update resource packaging. The fast compilation mode skips the compilation of the front-end resources and only performs the project cleanup, resource copying, and hot update resource packaging.

8. A mobile application automated building, packaging, and deployment device, characterized in that, include: A container image is used to encapsulate the build toolchain and build dependencies into a self-contained archive and embed them within the container image. And it is used to determine the existence of a flag directory when the container starts. If the flag directory does not exist, the archive is restored to the target path in a streaming manner all at once. If the flag directory exists, the restoration is skipped. A receiving module is used to receive a single command containing action parameters and environment parameters, and to parse the action parameters and environment parameters from the parameter list of the command; The configuration injection and version evolution module is used to evolve the version number according to the action parameters and inject configuration into multiple heterogeneous project configuration files according to different formats of the target files. The compilation module is used to compile the project source code using the restored build toolchain and the build dependencies, generate compilation artifacts, and specify the output directory; The product collection module is used to collect the compiled products into the output directory and write back the evolved version number for subsequent builds.

9. A computer device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the mobile application automated building, packaging, and deployment method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the mobile application automated building, packaging, and deployment method as described in any one of claims 1 to 7.