Table of Contents
Semantic version control
Major version changes (Major)
Minor version changes (Minor)
Patch version change
Submit information format
Submit title
Submit footnotes
Enforce submission information format
Generate and publish
Post a party!
Home Web Front-end CSS Tutorial How to Automate Project Versioning and Releases with Continuous Deployment

How to Automate Project Versioning and Releases with Continuous Deployment

Apr 01, 2025 am 04:16 AM

How to Automate Project Versioning and Releases with Continuous Deployment

Using semantic version control can make it easier to maintain and communicate software changes, but manual operations are cumbersome. Even if you manually merge PR, mark the submission and push the release, you still need to write a release description. There are many steps, high repetition, time-consuming and labor-intensive.

This article will explain how to achieve more efficient processes and fully automate release processes by integrating semantic versioning into the continuous deployment process.

Semantic version control

A semantic version is a version number consisting of three numbers, such as 1.4.10. Each number has a specific meaning:

Major version changes (Major)

The first number indicates a major version change, meaning there is a destructive change.

Minor version changes (Minor)

The second number indicates a minor version change, meaning that new features have been added.

Patch version change

The third number indicates a patched version change, which means a bug is fixed.

The semantic version can be understood more concisely as: destructive changes, functional changes, and bug fixes. This description is more precise and avoids ambiguity.

Submit information format

To ensure that the semantic version number is correctly incremented and the correct version is released, a standardized submission information format is required. A standardized submission information format helps determine when to increment which number and easily generate publishing instructions. Here, Angular will be used to submit information conventions, and of course it can also be changed as needed.

The format is as follows:

<code></code>
Copy after login

Each submission contains the title , body , and footnote .

Submit title

The title is a must, it has a special format including type , optional scope and topic .

The title type is a required field to illustrate the impact of the submission on the next version. It must be one of the following types:

  • feat : New features
  • fix : bug fix
  • docs : Document changes
  • style : Changes that do not affect the meaning of the code (for example: spaces, formats, missing semicolons, etc.)
  • Refactor : Code refactoring, neither fixing bugs nor adding functions
  • perf : Performance improvements
  • test : Add or correct test
  • chore : Changes to build processes or auxiliary tools and libraries, such as generating documents

A scope is a grouping property that specifies subsystems that submit related to subsystems, such as APIs, application dashboards, or user accounts, etc. If multiple subsystems are modified by the commit, an asterisk (*) can be used instead.

The title topic should briefly describe the changes made. The following rules are required when writing a topic:

  • Use imperative sentences, present tense (e.g., "changed" instead of "changed" or "changed").
  • Lowercase of the initial letter.
  • No period (.) is added at the end.
  • Avoid topic lengths exceeding 80 characters. Submit the body.

Like the title theme, the main text should also use imperative sentences, present tense. It should include the motivation for the change and compare it to previous behavior.

Submit footnotes

The footnote should contain any information about the destructive changes and is also where the question cited for this submission is closed.

Destructive change information should start with BREAKING CHANGE: followed by a space or two new lines. The remaining submission information is here.

Enforce submission information format

In teamwork, standardizing anything that everyone needs to follow is always a challenge. To make sure everyone uses the same submission criteria, we will use Commitizen.

Commitizen is a command line tool that simplifies the process of using a consistent commit message format. Making the repository compatible with Commitizen means that anyone on the team can run git cz and get detailed prompts to fill in the submission information.

Generate and publish

Now that we know that our submissions follow consistent standards, we can start generating releases and release notes. To do this, we will use a package called semantic-release. This is a well-maintained package with good support for a variety of Continuous Integration (CI) platforms.

semantic-release is key to our journey, as it will perform all the steps required for release, including:

  1. Confirm the last version you released
  2. Determine the publish type based on the submissions added since the last release
  3. Generate publish instructions for submissions added since the last release
  4. Update the package.json file and create a Git tag corresponding to the newly released version
  5. Push new version

Any CI is OK. In this article, we use GitHub Action because I like to use the existing features of the platform before seeking a third-party solution.

There are many ways to install semantic-release, but we will use semantic-release-cli because it provides step-by-step operations. Let's run npx semantic-release-cli setup in the terminal and fill in the interactive wizard.

The script will do the following:

  • Run npm adduser with the provided NPM information to generate .npmrc.
  • Create a GitHub personal access token.
  • Update package.json.

Once the CLI is finished, it adds semantic-release to package.json, but it won't actually install it. Run npm install to install it and other project dependencies.

The only thing left is to configure CI through GitHub Actions. We need to manually add a workflow that will run semantic-release. Let's create a publishing workflow in .github/workflows/release.yml.

 <code>name: Release on: push: branches: - main jobs: release: name: Release runs-on: ubuntu-18.04 steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: 12 - name: Install dependencies run: npm ci - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If you need an NPM release, you can add the NPM_TOKEN # NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: npm run release</code>
Copy after login

Steffen Brewersdorff has done a great job of introducing CI with GitHub Actions, but let's briefly review what's going on here.

This will wait for a push to the main branch to occur before the pipeline is run. You can change this setting as you like to run on one, two, or all branches.

 <code>on: push: branches: - main</code>
Copy after login

It then uses checkout to pull the repository and install Node so that npm can be used to install project dependencies. If this is something you prefer, you can add a test step.

 <code>- name: Checkout uses: actions/checkout@v2 - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: 12 - name: Install dependencies run: npm ci # You can add a test step here # - name: Run Tests # run: npm test</code>
Copy after login

Finally, let semantic-release do all the magical operations:

 <code>- name: Release run: npm run release</code>
Copy after login

Push changes and view actions:

Now, each time a specified branch is committed (or merged), the operation is run and published with a release note.

Post a party!

We have successfully created a CI/CD semantic release workflow! Isn't it that painful? The setup is relatively simple, and there are no disadvantages to having a semantic publishing workflow. It just makes tracking changes much easier.

semantic-release There are many plug-ins that can enable more advanced automation. For example, there is even a Slack release bot that can be published to the project channel after the project is successfully deployed. No need to go to GitHub to find updates!

The above is the detailed content of How to Automate Project Versioning and Releases with Continuous Deployment. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It&#039;s out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

Can you get valid CSS property values from the browser? Can you get valid CSS property values from the browser? Apr 02, 2025 pm 06:17 PM

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That&#039;s like this.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I&#039;d say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Stacked Cards with Sticky Positioning and a Dash of Sass Stacked Cards with Sticky Positioning and a Dash of Sass Apr 03, 2025 am 10:30 AM

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

Using Markdown and Localization in the WordPress Block Editor Using Markdown and Localization in the WordPress Block Editor Apr 02, 2025 am 04:27 AM

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Comparing Browsers for Responsive Design Comparing Browsers for Responsive Design Apr 02, 2025 pm 06:25 PM

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

See all articles