Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Let the user specify a per-commit template #9

Closed
fregante opened this issue Sep 11, 2020 · 9 comments · Fixed by #13
Closed

Let the user specify a per-commit template #9

fregante opened this issue Sep 11, 2020 · 9 comments · Fixed by #13
Labels
enhancement New feature or request

Comments

@fregante
Copy link
Owner

Instead of using include-hash, this could allow a per-commit template so the user can customize it freely

with:
  template: '- {hash} {title}' # Default
with:
  template: '- {title} {hash}'
with:
  template: '{title} [🔗]({url})'
@fregante fregante added the enhancement New feature or request label Sep 11, 2020
@fregante
Copy link
Owner Author

fregante commented Sep 11, 2020

This should be relatively easy to implement:

const line = template
  .replace('{hash}', commit.slice(0, 8))
  .replace('{title}', commit.slice(40))
  .replace('{url}', GITHUB_SERVER_URL + '/'+ GITHUB_REPOSITORY + '/commit/' + commit.slice(0, 40));
releaseBody.push(line);

@notlmn
Copy link
Collaborator

notlmn commented Sep 11, 2020

I suppose we can get GITHUB_SERVER_URL + '/'+ GITHUB_REPOSITORY with git remote get-url origin, unless SSH is being used in remotes.

@fregante
Copy link
Owner Author

fregante commented Sep 11, 2020

GITHUB_SERVER_URL + '/'+ GITHUB_REPOSITORY

Those are ENVs, immediately available, no need to execute git

https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables

@fregante
Copy link
Owner Author

Heck, most options could be replaced by the template:

with:
  header: '### Changelog'
  footer: '❤️'
  include-range: true
with:
  template: |
    ### Changelog

    {commits}

    {range}

    ❤️

The advantage being that it provides real customization instead of just what we allow. Example currently impossible:

with:
  commit-template: '{title} ← {hash}'
  template: |
    {commits}

    Full diff: {range}

@fregante
Copy link
Owner Author

with:
  include-range: false

would become:

with:
  template: '{commits}'

@notlmn
Copy link
Collaborator

notlmn commented Sep 12, 2020

Heck, most options could be replaced by the template

Was thinking about the same, but left it out as commits were variable length, and require template from other variable. Well, this is fine too.

@notlmn
Copy link
Collaborator

notlmn commented Sep 12, 2020

At this point release-with-changelog looks like a wrapper around @actions/create-release with template parts in body, and some other stuff 😅

@fregante
Copy link
Owner Author

fregante commented Sep 12, 2020

To be fair that action is kinda meaningless without a way to create the changelog. Its own example includes a static changelog text.

Also: actions/create-release#64

@notlmn
Copy link
Collaborator

notlmn commented Sep 12, 2020

To be fair that action is kinda meaningless without a way to create the changelog. Its own example includes a static changelog text.

It looks deliberately made generic, so that people input changelog from outputs of their own actions (you see where I'm going), making the workflow file >100 lines in the name of "composability".


Also: actions/create-release#64

About this, I'm not sure if GitHub would be inclined to include an external dependency in their core actions. Or building a changelog parser of their own for that matter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants