Giter Club home page Giter Club logo

gitlab-release-note-generator's Introduction

CircleCI codecov

Gitlab Release Note Generator

A Gitlab release note generator that generates release note on latest tag

Feature

  • Generate release note on the latest tag based on merge requests and issues

  • Distinguished title with issues or merge requests that have the following labels: enhancement, breaking change, feature and bug

    (Note. if an issue or merge request that has 2 or more labels, that issue or merge request will be displayed again under the corresponding title)

  • Can be integrated as a CD service. Tutorial below

How it works

  1. Find the latest tag
  2. Find the previous tag that is on the same branch as the latest tag.
  3. Locate the date range between the latest and the previous tag. If there is only a tag in the project, then the from date will be the project creation date and the to date will be that tag's creation date.
  4. Find all Merged merge requests and Closed issues within that time range
  5. Generate a release note/changelog based on the findings above.

Software requirement

  • NodeJS ^10.x.x OR docker
  • A gitlab personal access token with api permission. How to Tutorial

How to run this app

Docker method

docker container run -e GITLAB_PERSONAL_TOKEN=gitlabSampleToken -e GITLAB_PROJECT_ID=12345678 -e TARGET_BRANCH=sampleTargetBranch -e TARGET_TAG_REGEX=sampleRegex 00freezy00/gitlab-release-note-generator

Nodejs Method

  • Fill in the parameters mainly GITLAB_PERSONAL_TOKEN, GITLAB_PROJECT_ID, TARGET_BRANCH(optional. Use it only if you want to find tags in the same specific branch) and TARGET_TAG_REGEX (optional. Can use it to distinguish master or develop branch version bump) in app/env.js or feed it in process.env through npm
  • npm install
  • npm start
  • After couple seconds, latest tag should have a release note

Gitlab CI method

  1. Need to pass in gitlab personal access token as a CI variable

  2. c/p the .sample.gitlab-ci.yml to your gitlab ci.

    What's included in the sample gitlab CI script

    • generate-release-note job. Generates a release note on the tag after detecting tag push with this regex /^[0-9]+.[0-9]+.[0-9]+(-[0-9]+)?$/
    • tag-after-deployment job (optional). Tag the commit that contains a version bump with this regex /^[0-9]+.[0-9]+.[0-9]+(-[0-9]+)?$/. Require ssh key to work.
  3. Customise the gitlab ci script to your need

Reference gitlab repo: generator test

Options

These can be specified using environment variables

  • GITLAB_API_ENDPOINT: Your gitlab instaqnce's endpoint
  • GITLAB_PERSONAL_TOKEN: Grant api read/access permission
  • GITLAB_PROJECT_ID: Your project id that is located under settings > general
  • TARGET_BRANCH: The branch to look for release tags (ie master)
  • TARGET_TAG_REGEX: Regular expression of the release tags to search (ie: ^release-.*$)
  • TZ: The timezone for your release notes
    • Default "Australia/Melbourne"
  • ISSUE_CLOSED_SECONDS: The amount of seconds to search after the last commit, useful for Merge Requests that close their tickets a second after the commit.
    • Default 0

Building and Running locally

export GITLAB_PERSONAL_TOKEN=MYGITLABACCESSTOKEN
export GITLAB_PROJECT_ID=99
export GITLAB_API_ENDPOINT=https://my.gitlab.com/api/v4

// run docker to build my local version
docker build -t local-gitlab-release-note-generator .

// run my local version
docker container run \
  -e TZ=America/New_York \
  -e GITLAB_API_ENDPOINT=$GITLAB_API_ENDPOINT \
  -e GITLAB_PERSONAL_TOKEN=$GITLAB_PERSONAL_TOKEN \
  -e GITLAB_PROJECT_ID=$GITLAB_PROJECT_ID \
  -e TARGET_BRANCH=master \
  -e TARGET_TAG_REGEX=^release-.*$ \
  local-gitlab-release-note-generator

TODO:

Feature

  • Release notes generation on selected tag
  • Customise template for the release note

Credits

Thanks to github-changelog-generator for inspiring me to make this app. Sorry, I couldn't wait any longer for that gitlab feature to be merged in.

gitlab-release-note-generator's People

Contributors

dependabot[bot] avatar dovetailjohn avatar jk1z avatar vrtak-cz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gitlab-release-note-generator's Issues

Add option to ignore prereleases?

I use prerelease tags when I deploy to stage, and normal tags when deploying to production.
In my releases I only want the normal tags to be there, and the changelog should also consider the last normal tag and ignore any prerelease tags.

Eg.

  • release v1.0.0
  • prerelease v1.1.0-0 (ignored)
  • prerelease v1.1.0-1 (ignored)
  • release v1.1.0

And changelog should generated should be b/w v1.0.0 and v1.1.0

Create new release fails

Hello.

I have found this software and it is wonderful. Thank you.
It's 2022 and Gitlab still doesn't have a button in the UI to generate the changelog automatically.

I've tested it and there seems to be a problem when creating new releases. It gives error 400 bad request.
According to the documentation, when a release is created a parameter "tag_name" (underscore) must be sent

https://docs.gitlab.com/ee/api/releases/#create-a-release

From what I can see in the code, a "tagName" parameter (camelCase) is sent and this seems to be the problem.

I have debugged the code and this is the body that is sent:

{
  "description": "some changelog text",
  "tagName": "v0.0.5"
}

Can you check to see if I'm right?
Thank you.

[Question] Closed issues

Perhaps it's intended behaviour, but it's not entirely clear to me based upon the docs.

Scenario

  • I've merged a MR and had it auto-close the issue.
  • Running the generator adds the issue to the list with the label, e.g. Enhancements.

However, the issue does not show up under Closed issues.

Do closed issues only show up when it has been closed during the release, but:

  • There is no corresponding MR
  • There is a corresponding MR, but issue doesn't have any of the mentioned labels

FYI there's activity on the original repo to finally finish the GitLab integration

Add Merge Requests only from the specified branch

Hi,

I would also like to thank you for this great tool!

I would like to ask, do you guys suffer from having in the Release Notes Merge Requests that do not have as a target branch this branch that is specified as the parameter TARGET_BRANCH(for instance, 'master')? Like it is mentioned in the "How it works" section, today in the release notes are added Merge Requests within the time range defined by the last two tags. However, within this time range can be merged Merge Requests to different branches, and the issue is that in the Release Notes go all of the MRs and not only the one merged into TARGET_BRANCH.

This brings confusion, because I use the tool for the 'master' branch, but we have 'feature branches' for features that are under development and when we release in master, then in the Release Notes are displayed MRs from the feature branches which are not released actually.

Thanks

Ability to filter issues with certain labels from the release notes

Currently, if you want to close an issue without implementing anything, there's no way to exclude it from the release notes. This could happen if you just want to resolve an issue as not a bug, non reproducible, not going to implement, etc.

The only way to do this seems to be to delete the issue, which will of course not retain any information about the issue.

One possible solution would be to add the ability to filter issues marked with a certain label from the results.

Issues and merge requests appear on two consecutive releases

Hi!
Thank you for this library! It's been really useful for us.

I have a quick question: is there a reason to use updated_at (updated_after / updater_before) for issues and MRs? In our case MR gets updated after it gets merged and sometimes the same MR appears on two consecutive releases. Any idea what could be the problem?

TypeError: issue.labels is not iterable

Hello,

We are occasionally getting the following error: TypeError: issue.labels is not iterable. It's rather tricky, since the API returns an empty list for issues which have no labels, so iteration should not be a problem.

Do you by chance know what could cause this?

Last merge request doesn't added to release notes.

Hi! I'm testing your tool and I've noticed something strange - the last merged merge request didn't appear in release notes. Here my gitlab-ci.yaml

stages:
  - deploy
  - post_deploy

tag-after-deployment:
  only:
    refs:
      - master
      - develop
  except:
    refs:
      - tags
  stage: deploy
  image: debian:stable
  before_script:
    - source environments/lab/make.env
    - apt-get clean -qq
    - apt-get update -qq --fix-missing
    - apt-get install -qq --fix-missing jq git
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan git-stage.nordigy.ru >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - export VERSION=$DOCKER_TAG
    - git config --global user.name "${GITLAB_USER_NAME}"
    - git config --global user.email "${GITLAB_USER_EMAIL}"
    - git config -l
    - git remote set-url origin "[email protected]:contact-center/integrations/devops/environments/engage-digital.git"
    - git remote -v
  script:
    - git tag -af "${VERSION}" ${CI_COMMIT_SHA} -m "${VERSION}"
    - git push origin --tags -f

generate-release-note:
  only:
    refs:
      - tags
  stage: post_deploy
  image: docker:18-git
  services:
    - docker:18-dind
  script:
    - docker container run -e GITLAB_PERSONAL_TOKEN=${GITLAB_ACCESS_TOKEN} -e GITLAB_API_ENDPOINT="https://git-stage.nordigy.ru/api/v4" -e GITLAB_PROJECT_ID=${CI_PROJECT_ID} 00freezy00/gitlab-release-note-generator

I compared commits SHA and they are the same in pipeline and in tag.

Only Merge Requests and Release output file

Hello,

First of all thanks for this amazing tool.

It it possible to generate a release note with only merge requests? There are any flag to disable issues?

And how can I download the output file, for example using an artifact in CD, because at this moment I have to open the pipeline, check the step output and copy/paste the content to a file.

Thanks

Ability to Label deployed issues

I would like to be able to add a new label to issues that are added to release notes, ie 'Deployed'

The easiest place would be in issue.js searchIssuesByProjectIdStateStartDateAndEndDate but that seems to be outside the scope of that function.

I'll be glad to submit a PR if you can give me some direction on how you would like it done.

Ability to run a 'dry-run'

As part of our release process we would like to be able to pull a list of issues that would be included in the next release. This would pull the same release notes but not write them to a tag, I guess the tag would not have to exist so we would need to pull all closed issues since the previous tag until an end date of now.

I'll be glad to submit a PR if you can give me some direction/comments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.