afterAutomatic output changelog – Section I: specification submission codeAndAutomatic output changelog – Section II: automatic outputAfter two sections of content are recorded, the log can achieve one key output. If continuous deployment is not connected in small projects, the process of version marking, log output, GIT and NPM push can be simply realized by running the release it command locally, which can be said to be in place in one step. Under the R & D process of the company’s project based on the drone continuous deployment tool, the steps mentioned above need to be combined with the continuous deployment tool.
Briefly explain my current development process based on drone:
- The master branch is the branch of code summary. After PR / MR, continuous deployment is triggered and automatically deployed to the test service.
- The production branch is the production branch. After the push code, continuous deployment is triggered and automatically deployed to online services.
Operation process from R & D to release:
- Fork a code to your name, and then develop it locally.
- When the development needs to be tested, initiate PR / MR and push it to the main warehouse, team leader or team member
code reviewConsolidated to main warehouse after approval
- Merge the master into production, update the log and version number, and then submit
productionBranch for publishing
In the above process, there will be a great risk of misoperation in the process of manual version updating. Therefore, we intend to use tools to realize automatic version updating. This is the ultimate purpose of the three sections of the article “automatic generation changelog”.
The contents mentioned in this article are highly bound with the workflow of our company using the drone continuous delivery tool. It is not recommended to copy mechanically. The overall reference idea is roughly the same. It is recommended to learn from it.
The following is about continuous deployment
release-itIn the details of the use of the continuous deployment tool drone.
Details of combined use
The process of continuous deployment is divided into three parts: pulling warehouse, building code and deploying push. Now you need to add “version update” in this process. The following is a reference example of drone deployment configuration:
kind: pipeline name: releases steps: - name: release image: tarampampam/node:12.13-alpine environment: SSH_KEY: from_secret: ssh_key commands: - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $SSH_KEY" - git config --global user.email "[email protected]" - git config --global user.name "in_boot" - npm ci - npm run build - npm run test:unit - npm run release -- --ci --no-git.requireUpstream --git.pushRepo=origin - name: release2npm image: plugins/npm settings: username: in_boot email: [email protected] password: from_secret: npm_password registry: http://self.uxfeel.com/ trigger: branch: - production event: - push
Although the code is a few simple lines, the details and ideas behind it are complicated, which need to be mentioned in detail.
release-itThe following behaviors are performed by default:
- Compare the last version tag with the latest history and output the log to the log file;
- Update version number of parsing log content;
- Submit content changes and attach version labels;
- Push to the far end;
- Push to NPM service;
The push NPM service is obviously unnecessary. Here, I turn off its function in the release it configuration. But there are many problems in GIT.
Encounter problem 1: no Git
When it is used in the continuous deployment tool, the part about git in the first step is stuck, indicating that there is no GIT. Since there is no git in the docker image officially provided by node, I replaced it with this image: tarampampam / node: 12.13-alpine.
Problem 2: SSH is not authorized
How to provide credentials to git push code in the container? There are two situations where HTTP is different from SSH:
HTTP, write the account password in drone’s
secretAnd used as a system variable. Then close the GIT push link of release it and push the GIT part manually to support the account and password.
environment: USERNAME: from_secret: username PASSWORD: from_secret: password commands: - git config --global user.email "[email protected]" - git config --global user.name "in_boot" - npm ci - npm run release -- --ci --no-git.requireUpstream --git.pushRepo=origin - git push "https://$USERNAME:[email protected]/file.git"
In the case of SSH, the GIT needs to be modified_ SSH_ Command (GIT version higher than 2.7.0), in drone’s
secretAdding SSH to_ The key (private key) is used as a system variable and can be added in the git_ssh_command setting.
environment: SSH_KEY: from_secret: ssh_key commands: - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $SSH_KEY" - git config --global user.email "[email protected]" - git config --global user.name "in_boot" - npm ci - npm run release -- --ci --no-git.requireUpstream --git.pushRepo=origin
Encounter problem 3: release it prompt: upstream branch is not set
ERROR No upstream configured for current branch. Please set an upstream branch. Documentation: https://git.io/release-it-git
In this case, it is used directly
--no-git.requireUpstream --git.pushRepo=originThe release it check is avoided.
Encounter problem 4: package lock will be changed after NPM install JSON file
Changed package lock The GIT state of the JSON file is affected,
releaset-itSubsequent operations cannot be performed. Here you can use another command of NPM to solve this problem:
$ npm ci
Users of yarn can achieve the same effect by using the following command:
$ yarn install --frozen-lockfile
Finally, I would like to thank our front-end partners for accompanying me to toss about this set of things. Since the end of 2019, the R & D process has iterated several versions. From the initial git flow to the current gitlab flow, I never know why to use continuous deployment tools to learn Devops, continuous delivery and lean ideas, so as to learn and make progress together. Thanks to the support of the operation and maintenance brother and the release of the technical director, we have the opportunity to deploy to the cloud and have the time and energy to implement so far.