Every time I release a new version of my mini program to the preview environment, I need to: build the package => open WeChat Developer Tools => click upload => click submit. The whole process is tedious. This manual publishing workflow is extremely inefficient, so I wanted to automate it with a script. I discovered the official miniprogram-ci npm package, and after some exploration, I finally solved this pain point. However, the official documentation is quite sparse, so I’m documenting my solution here.
My Original Project Setup
I’m using Taro, so before each release I need to run npm run build:weapp to compile and build the project. The built files are located in /dist/weapp, and this is the folder I need to upload and publish.
Implementing Automated Publishing with miniprogram-ci
Here’s the script code for publishing to the development version. Based on this code block, create a publish.js script. Integrating it with the build process is also straightforward.
(async () => {
const project = new ci.Project({
appid: "",
type: "miniProgram",
projectPath: path.resolve(__dirname, "../", "dist"),
privateKeyPath: path.resolve(__dirname, "private.key"),
ignores: ["node_modules/**/*"],
});
// Common compilation settings
const setting = {
// Key: Disable ES6 to ES5 conversion, as Taro already handles this
es6: false,
// Disable enhanced compilation
enhance: false,
// Disable ES7 to ES5 conversion
es7: false,
// Code protection (obfuscation)
minified: true,
// Auto-prefix styles
autoPrefixWXSS: true,
// Compress WXML
minifyWXML: true,
// Compress WXSS
minifyWXSS: true,
// Compile JS to ES5
codeProtect: false,
};
Important Notes
The official documentation lacks many details, so here are some clarifications:
- Note that if the version is already set as the preview version on the WeChat Official Accounts Platform, it will be published as the preview version; otherwise, it will be the development version.
- The private.key file needs to be downloaded from the WeChat Official Accounts Platform. Path: Development -> Development Settings -> Download Developer Tools Configuration File. After extracting, you can find the private.key file.
- The projectPath here is the directory where project.config exists. Since I’m using Taro, which handles compilation to WeChat Mini Program language, I need to disable those compilation switches in the configuration above. If you’re developing natively, I believe you can simply use the project configuration directly.
- The ci tool’s upload function only performs size checks and doesn’t validate syntax. So if you select the wrong directory or enable extra compilation options, the result is that the upload succeeds but the preview fails with errors like
Component is not found in path "wx://not-found"
Final Thoughts
miniprogram-ciisn’t about whether it’s good or not - it’s just barely usable.- WeChat Mini Program documentation is truly terrible, and the community is mediocre at best. Just browse through and you’ll see complaints everywhere. What does this tell you? It’s bad, but you have no choice but to use it. Just make do with it.

