LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub
Star

ChangeLog Command

For release-docker and release-maven tasks, we need to generate the changelog for the release and update CHANGELOG.md in the release branch. Previously, we were using github-changelog-generator; however, it doesn’t support changelog generation per release branch after we introduced the maintenance branch.

After searching on the Internet for other alternative tools, we decided to build a command component in the light-bot. Most existing tools don’t support release branches and leverage the GitHub v3 Rest API with a lot of extra data fetched from the server. We need release branch support and want to use the V4 GraphQL API to fetch exactly what we need.

Commit Logs

The idea is very simple. First, we need to get the commit log within the release branch from the previous tag to the HEAD. This list contains all the changes in the branch since the last release.

As git log only supports DateTime to specify the beginning of the commit log to retrieve. We create one method to get the DateTime of the previous tag with the following git CLI.

git log -1 --format=%aI 1.5.32

The above command will be executed on the current branch and returned the timestamp of the tag 1.5.33. Here is an example of the returned value.

2019-03-19T18:46:58-04:00

Now we can use the timestamp to get all the commit log from the timestamp to the latest.

git log --since=2019-03-19T18:46:58-04:00

The above command will return the commit logs in the following format per entry.

commit 915efccf2cbdaa9805271c14c906c60871234b9a
Author: BalloonWen <[email protected]>
Date:   Wed Mar 20 10:20:20 2019 -0400

    -fixed issue for consul's ttl check, now the ttl interval will be still the same as "checkInterval", but the heartbeat will be 2/3 of "checkInterval" (#428)

What we need is to parse each entry to get the pull request number. In the above case, it is 428 at the end of the 5th line.

After parsing the commit log, we will get a list of pull request numbers that merged into the current release branch since the last release.

Pull Requests

With a list of pull request numbers, we need some detailed info for each pull request to generate the formatted changelog for the release.

We will be using the V4 GitHub API to retrieve the 100 latest pull requests. Here is the GraphQL query.

query {
    repository(owner:"networknt", name:"light-4j") {
    pullRequests(last:100, states:MERGED) {
      edges {
        node {
          number,
          title,
          url,
          author {
            login,
            url
          }
        }
      }
    }
  }
}

You can run it from the GitHub explore website after logging in with your GitHub account.

With all the info available, we generate a map from the result of the query. From the pull request list in the first step, we can retrieve the detail from the map and generate the changelog entries for the release.

Merge with CHANGELOG.md

Once the entries for the current release are generated, we need to save them into the existing CHANGELOG.md file. This is done by just merging two lists at a certain index.

Summary

There are a lot of tools implemented in different languages from GitHub, but none of them are suitable for our needs. With this command, we have full control over the format and logic so that we can customize if necessary. Also, this built-in command will help our users if they are leveraging the light-bot for their DevOps pipeline.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“ChangeLog Command” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute