Giter VIP home page Giter VIP logo

tag-changelog's Introduction

tag-changelog

tag-changelog

A GitHub Action triggered by a new (valid semver) tag getting pushed. It then fetches all the commits since the previous tag and creates a changelog text using the Conventional Commits format. It will also turn PR numbers into clickable links, and mentions the author.

This action returns the generated changelog text, but doesn't do anything more; you need to for example prepend it to a CHANGELOG.md file, create a GitHub Release with this text, etc.

Example workflow

name: Create Release

on:
  push:
    tags:
      - "*"

jobs:
  create-release:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Create changelog text
        id: changelog
        uses: loopwerk/tag-changelog@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          exclude_types: other,doc,chore

      - name: Create release
        uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: ${{ steps.changelog.outputs.changes }}

Inputs

  • token: Your GitHub token, ${{ secrets.GITHUB_TOKEN }}. Required.
  • exclude_types: A comma separated list of commit types you want to exclude from the changelog, for example: "other,chore". Optional (defaults to nothing). Can also be configured in the config file.
  • config_file: Location of the config file. Optional.

Outputs

  • changelog: Generated changelog for the latest tag, including the version/date header (suitable for prepending to a CHANGELOG.md file).
  • changes: Generated changelog for the latest tag, without the version/date header (suitable for GitHub Releases).

Custom config

- name: Create changelog text
  uses: loopwerk/tag-changelog@v1
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    config_file: .github/tag-changelog-config.js

The config file can be used to map commit types to changelog labels, to override the rendering of changelog sections, and the rendering of the overall changelog. You only need to override the things you want to override. For example, you can leave out renderTypeSection and renderChangelog and only include the types config; the default config will be used for whatever is not overriden.

Example config file:

module.exports = {
  types: [
    { types: ["feat", "feature"], label: "๐ŸŽ‰ New Features" },
    { types: ["fix", "bugfix"], label: "๐Ÿ› Bugfixes" },
    { types: ["improvements", "enhancement"], label: "๐Ÿ”จ Improvements" },
    { types: ["perf"], label: "๐ŸŽ๏ธ Performance Improvements" },
    { types: ["build", "ci"], label: "๐Ÿ—๏ธ Build System" },
    { types: ["refactor"], label: "๐Ÿชš Refactors" },
    { types: ["doc", "docs"], label: "๐Ÿ“š Documentation Changes" },
    { types: ["test", "tests"], label: "๐Ÿ” Tests" },
    { types: ["style"], label: "๐Ÿ’… Code Style Changes" },
    { types: ["chore"], label: "๐Ÿงน Chores" },
    { types: ["other"], label: "Other Changes" },
  ],

  excludeTypes: ["other"],

  renderTypeSection: function (label, commits) {
    let text = `\n## ${label}\n`;

    commits.forEach(commit => {
      text += `- ${commit.subject}\n`;
      if (commit.body) {
        text += `${commit.body}\n`;
      }
    });

    return text;
  },

  renderChangelog: function (release, changes) {
    const now = new Date();
    return `# ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n";
  },
};

The order in which the types appear also determines the order of the generated sections in the changelog.

Example output

v0.14.0 - 2021-02-22

New Features

  • merge the default config with the user config so that the user config only has to override values it wants, and use the defaults for the others
  • the custom config file is now JS instead of JSON, allow the override of the changelog text templates (#2 by kevinrenskers)
  • commit types to exclude can now also be configured via the config file

Documentation Changes

  • simplified readme

Chores

  • added project logo

BREAKING CHANGES

  • due to bcb876: commit types to exclude can now also be configured via the config file

The exclude input parameter has been renamed to exclude_types.

You can also check out the Releases page for tag-changelog.

Thanks

Thanks to Helmisek/conventional-changelog-generator and ardalanamini/auto-changelog for inspiration. Thanks to nektos/act for making it possible to run GitHub Actions locally, making development and testing a whole lot easier.

tag-changelog's People

Contributors

ipereziriarte avatar kevinrenskers avatar ldicarlo avatar santiagofm 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

Watchers

 avatar  avatar  avatar  avatar

tag-changelog's Issues

Tags from Octokit are sorted alphabetically, possibly causing problems for this action

Hello, and thank you for this github action.
I am not sure, but this line

const { data: tags } = await octokit.rest.repos.listTags({

Seems to take the last 2 tags but not among the 10 last tags ?
When I run locally in a repository ( using gh api /repos/<owner>/<repo>/tags | jq), I get 10 tags but not the last ones.

In one of our projects we have always the same changlelog generated.

I don't have a large set of debugging available, so I am sorry by advance if this is an error.
Thank you

how to get the release notes and send it to an email

Hi,

I am using this workflow and it is working fine. I would like to get the ${{ steps.changelog.outputs.changes }} and send it via email. But I am not getting anything. I am using this code to get the changes:

  • name: Send mail
    uses: dawidd6/action-send-mail@v3
    with:
    # Required mail server address:
    server_address:
    # Required mail server port:
    server_port:
    # Optional (recommended): mail server username:
    username:
    # Optional (recommended) mail server password:
    password:
    # Required mail subject:
    subject:
    # Required recipients' addresses:
    to:
    # Required sender full name (address can be skipped):
    from:
    # Optional whether this connection use TLS (default is true if server_port is 465)
    secure:
    # Optional plain body:
    body: ${{ steps.changelog.outputs.changes }}
    # Optional unsigned/invalid certificates allowance:
    ignore_cert:
    # Optional converting Markdown to HTML (set content_type to text/html too):
    convert_markdown:
    # Optional priority: 'high', 'normal' (default) or 'low'

I hope you can assist me with this one.
Thank you so much.

  • Lisley

Update to node 20

Hi,

Would it be possible to update to node 20 as node 16 is deprecated.

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: loopwerk/tag-changelog@v1. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/

A quesion need help: ChangeLog only has one

I just copy the sample workflow code,but when I push a tag to the github,although the workflow work success,the release page only has a record.

I want this option:

It can generate all of commit messages between the latest tag version and the previous tag version when i push a tag version.

Detail sample:

Now my github repositiy has a tag named 0.2.And I publish a tag named 0.3.And there are 7 commit in two tag version.And the release body message also generate 7 commit message .

You may see my reposity,link is https://github.com/stars-one/kxorm

Hope your help,Thanks!

Workflow code:

name: Create Release

on:
  push:
    tags:
      - '*'

jobs:
  create-release:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Create changelog text
        id: changelog
        uses: loopwerk/tag-changelog@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          exclude_types: other,doc,chore

      - name: Create release
        uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: ${{ steps.changelog.outputs.changes }} 

Error: Validation Failed: "already_exists"

I am running into a bit of a snag when setting up the changelog action on one of my repositories. I had previously created two releases before adding this Action, and it looks like I am hitting the following error:

Error: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"}

I am sure that this is user error. How should I setup the action to handle this? Here is a link to my workflow.

Screen Shot 2022-03-29 at 2 30 16 PM

Update to Node 16

Hi,

I am using your Action, but recently I receive this warning:

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: loopwerk/tag-changelog

So I request if it is possible to go for Node 16 as described here

https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/

Regards,

DK

If I am submitting a tag for the first time, the code logic will throw an exception

Is it possible to be compatible with the first two submissions?

your code

  // Find the two most recent tags
  const { data: tags } = await octokit.repos.listTags({
    owner,
    repo,
    per_page: 10,
  });

  const validSortedTags = tags
    .filter((t) => compareVersions.validate(t.name))
    .sort((a, b) => {
      return compareVersions(a.name, b.name);
    })
    .reverse();

  if (validSortedTags.length < 2) {
    setFailed("Couldn't find previous tag");
    return;
  }

Not working with merge commits?

I like to make a new branch when I start working on a fix or a feature.
And I have the habit of creating Merge Commits when merging a pull request into the active branch when I am done.

But it doesn't seem like it picks up all the commit history of the branch when doing it like this?
I seem to recall that it worked previously.

All my commits follow conventional commit format (except for the merge commit).
bild

And then this is what the changelog ends up as:
bild

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.