How to use Zadig to implement automatic publishing of WeChat mini programs

 
Zadig,作为一款全面的 DevOps 平台,致力于简化多样化软件交付环境中的发布流程。它集成了多种功能和工具,适配了广泛的操作系统和部署环境,使得团队可以轻松执行持续交付、自动化测试和灰度发布等关键 DevOps 实践,显著提高了软件开发的效率和质量。Zadig 已经成功支持了 Android 和 iOS 应用的自动化发布,不仅在 Kubernetes 构建基础设施上表现出色,也能在 Linux 、 MacOS 和 Windows 主机上完成应用的编译和发布,证明了其跨平台的兼容性和强大功能。
In this article, we will take an in-depth look at how to automate the release of small programs through Zadig. Zadig extends its automation capabilities to the special application type of mini-programs, providing stable and efficient DevOps support for development teams whether they are traditional mobile applications or emerging mini-programs. Through Zadig, teams can ensure that every aspect of software delivery is smooth and smooth, achieving fast and reliable small program release.

Preliminary work

Apply for APP ID

Apply for an APP ID on the WeChat public platform, which is usually provided by a development engineer.

Make a build image

In order to make code compilation, uploading and previewing of mini programs smoother, we recommend using the miniprogram-ci tool officially provided by WeChat . For detailed introduction of the tool, please refer to WeChat official documentation .
During the build process, in order to be able to use the miniprogram-ci tool, you need to prepare a mirror environment containing the tool. The specific process is as follows:
1. Create an image and push it to the image warehouse. The reference of Dockerfile and image building command is as follows:
Select the corresponding node version according to the actual project dependencies.
Dockerfile reference:
FROM node:14.20.0-buster-slim
RUN apt update && \
    apt install curl  git -y && \
    npm install -g miniprogram-ci --registry=https://registry.npmmirror.com

 

Build the image and push it to the image repository:
$ docker build -t koderover.tencentcloudcr.com/test/node:14.20.0-buster-slim .
$ docker push koderover.tencentcloudcr.com/test/node:14.20.0-buster-slim
2. Configure and use custom images on Zadig. For specific configuration, please refer to Custom Image Management | Zadig Documentation

Configure custom images on Zadig

Administrator configuration

New Project

Enter the Zadig system, select Project- > New Project , fill in the project name, select any project type to create a new project, and skip the wizard.

Prepare workflow

Administrators prepare collaborative workflows for different roles. For specific configuration reference:
role-oriented
Function description
Sample workflow name
Contains steps
R&D/Test Engineer
Test workflow, build test version
test-workflow
Build test version (common task) -> IM notification (code change trigger)
Release Engineer
Publish workflow and upload official version
release-workflow
Build and upload the official version (common task) -> IM notification

Test workflow configuration

1. Create a new workflow, add a "general task", and select the mini program's build image, configuration code information, and build script.

Select build image

Configure build preview script

Build script reference:
#!/bin/bash
set -e

cd ${REPONAME_0}
yarn install
npx gulp -f build/compiler.js buildExample --color # 根据项目实际构建过程修改
miniprogram-ci preview \
    --appid <小程序 APP ID> \
    --project-path ./example \
    --private-key-path ./example/private.key \
    --upload-version $TASK_ID \
    -r 1 --enable-qrcode true% \
    --enable-es6 true%
2. Add notification configuration to notify test engineers to conduct mini program testing. For specific configuration, please refer to Workflow Notification | Zadig document .

Add notification

3. Add a Git trigger. For specific configuration, please refer to Git Trigger | Zadig documentation .

Configure Git triggers

Publish workflow configuration

1. Create a new workflow and add a "general task", select the mini program to build the image, configure the code information, extract the version information as a custom variable, and build the push script.

Select build image

Configure build and push scripts

Build script reference:
#!/bin/bash
set -e

cd ${REPONAME_0}
yarn install
npx gulp -f build/compiler.js buildExample --color # 根据项目实际构建过程修改
miniprogram-ci upload \
    --appid <小程序 APP ID> \
    --project-path ./example \
    --private-key-path ./example/private.key \
    --upload-version $version \
    --enable-es6 true%
2. Add notification configuration to notify the release engineer that the official version has been uploaded.

Add notification

Engineers use

Development engineer self-test and debugging

Mini program development engineers generally use local development tools to complete self-test and debugging.

local development tools

Test engineer integration verification

After the R&D project submits the code, the test-workflow execution is automatically triggered. After the execution is completed, the test engineer can receive a notification on IM and open the mini program for testing by scanning the QR code in the task output.

Workflow task details

Workflow task notifications

Release engineer officially releases

After passing the test, the release project executes release-workflow to build and push the official version.

Execute release-workflow

release-workflow task details

After successfully pushing, go to the WeChat public platform and select the corresponding version to submit for review. Once approved, it can be published.

Mini program submission for review

 
How much revenue can an unknown open source project bring? Microsoft's Chinese AI team collectively packed up and went to the United States, involving hundreds of people. Huawei officially announced that Yu Chengdong's job changes were nailed to the "FFmpeg Pillar of Shame" 15 years ago, but today he has to thank us—— Tencent QQ Video avenges its past humiliation? Huazhong University of Science and Technology’s open source mirror site is officially open for external access report: Django is still the first choice for 74% of developers. Zed editor has made progress in Linux support. A former employee of a well-known open source company broke the news: After being challenged by a subordinate, the technical leader became furious and rude, and was fired and pregnant. Female employee Alibaba Cloud officially releases Tongyi Qianwen 2.5 Microsoft donates US$1 million to the Rust Foundation
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/koderover/blog/11122348