unpub publish atomic processing

Currently unpub hosts numerous pubs as our important pub private service. In the daily development process, we will also make some constraints on pub. for example

  • Only allow releases on master or release/* branches
  • Branches that do not meet the above criteria are not allowed to publish.

The focus of our discussion today is not the above-mentioned problem, but the atomicity of publishing unpub.

Two steps of deatomicization

Before discussing atomicity, we need to make it clear that there are two steps.

  • We need to execute flutter packages pub publish --server=https://pub.aaa.com/ --verbose to publish
  • Before and after publishing unpub, we need to push the code to the remote gitlab server

non-atomic problem

Then if we forget, the last step of push work may cause serious problems

  • A certain code A has not been pushed, and subsequent changes are published in unpub, resulting in the loss of the function of code A
  • After the subsequent discovery of the loss, the retrieval of Code A is likely to be unable to determine the content of the code modification at that time (may contain other modifications, which are not always reliable in human memory)
  • After recovery, it is often necessary to invest a certain amount of testing resources to verify that it is more secure.

Therefore, it is particularly important to combine the above two parts in one step as an atomic operation.

Atomic a script

Here’s a simple, yet extremely practical way, which is this code

 1 2 3 
#!/bin/bash git push origin "$(git symbolic-ref -q HEAD 2>/dev/null | cut -d'/' -f 3)" flutter packages pub publish --server = https://pub.aaa.com/ --verbose

After downloading to the local, set the file to be executable (add environment variables), and then do this when publishing unpub again.

 1 
unpubUpload.sh 

droidyue_gzh_green_png.png

This article is reprinted from https://droidyue.com/blog/2022/08/16/multiple-step-into-one-for-unpub-publish/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment