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

Duplicated PRs in the releases #1395

Open
dimofeev opened this issue Nov 15, 2024 · 4 comments
Open

Duplicated PRs in the releases #1395

dimofeev opened this issue Nov 15, 2024 · 4 comments

Comments

@dimofeev
Copy link

Hi Mike,

First of all I would like to thank you for the great tool! I would like to give it a try and ended with the following configuration:

name: Create release note

on:
  workflow_call:

jobs:
  generate_release:
    runs-on: ubuntu-latest
    steps:
      - name: Build Changelog
        id: github_release
        uses: mikepenz/release-changelog-builder-action@v5
        with:
          configurationJson: |
            {
              "template": "#{{CHANGELOG}}",
              "pr_template": "- #{{TITLE}} (##{{NUMBER}})",
              "categories": [
                {
                  "title": "## 🚀 Features",
                  "labels": [
                    "feat",
                    "feature",
                    "Feature"
                  ]
                },
                {
                  "title": "## 🐛 Fixes",
                  "labels": [
                    "fix",
                    "bug",
                    "Fix"
                  ]
                },
                {
                  "title": "## 🛠️ Chores",
                  "labels": [
                    "chore",
                    "Chore"
                  ]
                },
                {
                  "title": "## 🧪 Testing",
                  "labels": [
                    "test",
                    "qa",
                    "automation",
                    "unit",
                    "integration"
                  ]
                },
                {
                  "title": "## 📦 Dependencies",
                  "labels": [
                    "deps",
                    "Auto update"
                  ]
                },
                {
                  "title": "## ✨ Other",
                  "labels": []
                }
              ],
              "tag_resolver": {
                "method": "sort"
              },
              "label_extractor": [
                {
                  "method": "regexr",
                  "pattern": "^(chore|feat|fix|bug|test|unit|integration|Auto update)",
                  "target": "$1",
                  "on_property": "title"
                }
              ]
            }

      - name: Create Release
        uses: mikepenz/action-gh-release@v1
        with:
          body: ${{steps.github_release.outputs.changelog}}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

However I noted that a single PR was included in several different tags (i.e. releases). And this seems to be valid for a lot of the PRs - they are part of different sequential releases, not in a single one. Do you know what might be the reason for this behaviour?

Thank you in advance for your help.

@mikepenz
Copy link
Owner

Good day

Can you provide some logs please. Specifically which from and to tags were identified by the action.

Based on the pasted snippet I can see that the workflow is neither triggered by a tag, nor does the action checkout the sources for the action to find the git tag locally, nor is the tag provided via the config to the action.

There's a chance that wrong from->to ranges are identified

@dimofeev
Copy link
Author

dimofeev commented Nov 15, 2024

Thank you for the reply, Mike.

The snipped above is triggered from this action:

name: Create release note

on:
  push:
    # The regex should match only prod-123 (prod tags) or prod-123.4 (patch tags)
    tags:
      - 'prod-[0-9]+'
      - 'prod-[0-9]+.[0-9]+'

jobs:
  generate_release:
      name: Generate release
      uses: .github/workflows/generate_release.yml@master

Almost all of the PRs appears duplicated - they are present for example in both prod-104 and prod-105 releases. Please, note that I have and other tags, like for example v1.100.0, which are not in interest and I do not want releases generated for them (do not know if might be an issue, so decided to mention it at all). So a typical arrangement of the tags might be prod-104, v1.100.0, v1.101.0, prod-104.1, prod-105, etc, where 104.1 indicates a patch and might or might not be a present at all.

In the logs seems that the previous tag is not correctly applied:

  🔖 Resolved current tag (prod-105) from the 'github.context.ref'
  🔖 Resolved previous tag (v1.99.0) from the tags git API

In my case I want the previous tag to be prod-104 or prod-104.x (in case there is a patch tag)

Once again thank you for looking into this problem.

@mikepenz
Copy link
Owner

So there are a few things at play.

The first part, I am not 100% sure if the context is fully forwarded for a workflow dispatch, that said. It seems to be the case based on your example.

But then the main item which causes problem is. the Action uses SemVer to identify the prior tag. In your case you don't follow semver so the action will actually find the last tag which matches semver, all other tags are filtered out.

You will have to change the configuration more to tell the action how it can identify the prior tag. Which seems to be quite complicated as you don't seem to follow a consistent naming approach, neither semver nor different.

The "easiest" for the action would be if you pass in the fromTag manually, so the action just builds the changelog for the diff.

otherwise, you can configure the logic to filter tags, you can use regex to transform tags. and you acn use the sort mechanism (instead of semver) for normal sorting to be used to identify the prior tag.

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

2 participants