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

Use the tag date as the release date #245

Open
sleberknight opened this issue Oct 7, 2024 · 0 comments
Open

Use the tag date as the release date #245

sleberknight opened this issue Oct 7, 2024 · 0 comments
Labels
enhancement A request for change or improvement to an existing feature

Comments

@sleberknight
Copy link
Member

sleberknight commented Oct 7, 2024

Instead of using the date/time that the change log is generated as the release date, we should use the data the (annotated) tag was created. This will be useful if you release software, but don't create the release in GitHub immediately. For example, this happened recently in kiwi-js when 0.12.0 was released but (due to a temporary problem with GitHub not setting headers correctly), the release on GitHub was not until several days later.

This will need to make a REST call to get the release tag using the REST API endpoints for Git tags

Unfortunately, we will need to make two requests:

  1. Get the tag reference information
  2. Use the object URL in the first response to get the tag SHA and from that, get the annotated tag details

For example, GET https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/matching-refs/tags/v1.0.1 returns:

[
    {
        "ref": "refs/tags/v1.0.1",
        "node_id": "MDM6UmVmMzMyMDY3ODY0OnJlZnMvdGFncy92MS4wLjE=",
        "url": "https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/refs/tags/v1.0.1",
        "object": {
            "sha": "e6be73f6bad45cffac32bd8f633ec6125b729b0b",
            "type": "tag",
            "url": "https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/tags/e6be73f6bad45cffac32bd8f633ec6125b729b0b"
        }
    }
]

You then make a request to the object.url to get the annotated tag information

So, from the above you would make a GET https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/tags/e6be73f6bad45cffac32bd8f633ec6125b729b0b which returns:

{
    "node_id": "TA_kwDOE8r0GNoAKGU2YmU3M2Y2YmFkNDVjZmZhYzMyYmQ4ZjYzM2VjNjEyNWI3MjliMGI",
    "sha": "e6be73f6bad45cffac32bd8f633ec6125b729b0b",
    "url": "https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/tags/e6be73f6bad45cffac32bd8f633ec6125b729b0b",
    "tagger": {
        "name": "Scott Leberknight",
        "email": "174812+sleberknight@users.noreply.github.com",
        "date": "2024-09-02T17:38:24Z"
    },
    "object": {
        "sha": "7da1a3dfbdc2d8ac65436d8ccae4d100bbef08df",
        "type": "commit",
        "url": "https://api.github.com/repos/kiwiproject/kiwiproject-changelog/git/commits/7da1a3dfbdc2d8ac65436d8ccae4d100bbef08df"
    },
    "tag": "v1.0.1",
    "message": "[maven-release-plugin] copy for tag v1.0.1\n",
    "verification": {
        "verified": false,
        "reason": "unsigned",
        "signature": null,
        "payload": null
    }
}

This second response contains the date in the tagger object of the annotated tag.

If we fail to get a date, for example if the tag is not an annotated tag, then we should log a warning and fall back to the way it works now, basically the time the change log is generated.

@sleberknight sleberknight added the enhancement A request for change or improvement to an existing feature label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for change or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant