Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With "COMMIT" mode the commit link is not displayed #1400

Closed
MMarcus95 opened this issue Dec 3, 2024 · 8 comments
Closed

With "COMMIT" mode the commit link is not displayed #1400

MMarcus95 opened this issue Dec 3, 2024 · 8 comments

Comments

@MMarcus95
Copy link

Hello,

thanks for this useful and rich tool!

I was trying to use the mode "COMMIT" but I found out that it is displayed only the name of the commit, without a reference to it.

Would it be possible to add also the link to the commit?

@mikepenz
Copy link
Owner

mikepenz commented Dec 3, 2024

@MMarcus95 you can probably already achieve this as you can use the short hash in a URL.

For example 4337894

or 4337894

Screenshot 2024-12-03 at 12 15 23

@MMarcus95
Copy link
Author

The issue happens when generating the changelog automatically, because only the commit name is added, without URL. When using the "PR" more instead, you have the url added automatically. Should I use a specific configuration to have the commit url added when generating the changelog?

@mikepenz
Copy link
Owner

mikepenz commented Dec 3, 2024

Can you perhaps provide a more complete example.

What configuration do you use? and which template is what you'd like to see different.

For commit mode this is the default template: https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts#L109
You can change the template to whatever combination you'd like to have in your changelog

@mikepenz
Copy link
Owner

mikepenz commented Dec 3, 2024

And here are the placeholders you can use within a PR template: https://github.com/mikepenz/release-changelog-builder-action?tab=readme-ov-file#pr-template-placeholders

@MMarcus95
Copy link
Author

Thanks for the links. I'm triggering the action each time I push on the main branch and I would like to add a ChangeLog file in the new release that is automatically generated by the push. So I would like to see a list of commits and PR between the latest tag (which always points to the latest commit that triggers the action) and the previous tag. I'm trying now to see the commits with their URL and I'm using the action as follows

- name: Build Changelog
  id: build_changelog
  uses: mikepenz/[email protected]
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    fromTag: v${{ steps.semantic_version.outputs.previous_version }}
    toTag: ${{ steps.tag_version.outputs.new_tag }}
    mode: "COMMIT"
    fetchReviewers: true
    fetchViaCommits: true
    configurationJson: |
        {
          "template": "#{{CHANGELOG}}",
          "categories": [
            {
                "title": "## Change log",
                "labels": []
            }
          ],
          "label_extractor": [
            {
              "pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
              "target": "$1"
            }
          ],
          "pr_template": "- #{{TITLE}}\n  : ##{{NUMBER}}",
          "empty_template": "- no commit found",
        }

@mikepenz
Copy link
Owner

mikepenz commented Dec 3, 2024

I do believe that there is some miss-understanding on how the action works.

While there is a HYBRID mode, in general you construct your changelog either via commits or via PRs.

However if in commit mode, the commit is not associated with a PR - which is also why you won't have a PR Number in commit mode - so you probably can't do the exact format you are looking for.

You can for a single commit however get its SHA1 and look at that specific commits change.

@giacomocarrozzo
Copy link

I’m sharing my configuration here, hoping it’s the right approach. Hopefully, it can be helpful to others as well:

      - name: Get Repository URL
        id: get_repo_url
        run: echo "REPO_URL=https://github.com/${{ github.repository }}" >> $GITHUB_OUTPUT

      - name: Generate Changelog
        id: generate_changelog
        uses: mikepenz/release-changelog-builder-action@v5
        with:
          mode: "COMMIT"
          configurationJson: |
            {
              "template": "#{{CHANGELOG}}",
              "categories": [
                {
                  "title": "## 🚀 Features",
                  "labels": ["feat"]
                },
                {
                  "title": "## 🛠 Fixes",
                  "labels": ["fix", "bug"]
                },
                {
                  "title": "## 🧹 Maintenance",
                  "labels": ["chore", "refactor", "cleanup"]
                },
                {
                  "title": "## 📦 Build",
                  "labels": ["build", "ci"]
                },
                {
                  "title": "## 📝 Documentation",
                  "labels": ["docs"]
                },
                {
                  "title": "## ⚡️ Performance Improvements",
                  "labels": ["perf"]
                },
                {
                  "title": "## 🧪 Tests",
                  "labels": ["test"]
                },
                {
                  "title": "## ⏪ Reverts",
                  "labels": ["revert"]
                },
                {
                  "title": "## 🎨 Styling",
                  "labels": ["style"]
                },
                {
                  "title": "## 🎯 Other Changes",
                  "labels": []
                }
              ],
              "label_extractor": [
                {
                  "pattern": "^(build|chore|ci|docs|feat|fix|bug|perf|cleanup|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
                  "target": "$1"
                }
              ],
              "pr_template": "- [#{{TITLE}}](${{ steps.get_repo_url.outputs.REPO_URL }}/commit/#{{MERGE_SHA}}) by @#{{AUTHOR}}"
            }
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@mikepenz
Copy link
Owner

Closing due to inactivity.

Thanks @giacomocarrozzo for providing your configuration for others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants