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

add new parameter #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Initialize CodeQL
uses: github/codeql-action/init@v1


# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ The name of the head reference. Default `${{github.sha}}`.

The name of the second branch. Defaults to the `tag_name` of the latest release.

## `firstRelease`

The flag of base-ref setting when no release. Default `"commit"`.

If your repository has never published a release,
you can set the base reference through this parameter.

When this parameter is set to "commit", the base reference will be set to initial commit.
When this parameter is set to "tag", the base reference will be set to the latest tag.

## Outputs

### `changelog`
Expand Down
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ inputs:
description: 'The name of the base reference'
default: ''
required: false
firstRelease:
description: >
The flag of base-ref setting when no release. Default `"commit"`.

If your repository has never published a release,
you can set the base reference through this parameter.

When this parameter is set to "commit", the base reference will be set to initial commit.
When this parameter is set to "tag", the base reference will be set to the latest tag.
default: 'commit'
required: false
outputs:
changelog:
description: 'Markdown formatted changelog'
Expand Down
18 changes: 13 additions & 5 deletions changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ git fetch --depth=1 origin +refs/tags/*:refs/tags/* 1>&2
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 1>&2
git fetch --prune --unshallow 1>&2

# if folks don't have a base ref to compare against just use the initial
# commit. This will show all the changes since the beginning but I can't
# think of a better default.
if [ -z "$base_ref" ]
# If there is no release for comparison, the initial commit is used when "$commit"
# is obtained, This will show all the changes since the beginning.
# the latest tag is used when "$tag" is obtained, and the default is "$commit".
if [ "$base_ref" = "\$commit" ]
then
base_ref=$(git rev-list --max-parents=0 HEAD)
flag=$head_ref # Include the first commit
elif [ "$base_ref" = "\$tag" ]
then
tagName=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 --skip=1))
base_ref=$(git rev-list ${tagName} --max-count=1)
flag="${base_ref}...${head_ref}"
else
flag="${base_ref}...${head_ref}"
fi

log=$(git log "${base_ref}...${head_ref}" \
log=$(git log "${flag}" \
--pretty=format:"* [\`%h\`](http://github.com/${repo_url}/commit/%H) - %s" \
--reverse)

Expand Down
18 changes: 13 additions & 5 deletions dist/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ git fetch --depth=1 origin +refs/tags/*:refs/tags/* 1>&2
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 1>&2
git fetch --prune --unshallow 1>&2

# if folks don't have a base ref to compare against just use the initial
# commit. This will show all the changes since the beginning but I can't
# think of a better default.
if [ -z "$base_ref" ]
# If there is no release for comparison, the initial commit is used when "$commit"
# is obtained, This will show all the changes since the beginning.
# the latest tag is used when "$tag" is obtained, and the default is "$commit".
if [ "$base_ref" = "\$commit" ]
then
base_ref=$(git rev-list --max-parents=0 HEAD)
flag=$head_ref # Include the first commit
elif [ "$base_ref" = "\$tag" ]
then
tagName=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 --skip=1))
base_ref=$(git rev-list ${tagName} --max-count=1)
flag="${base_ref}...${head_ref}"
else
flag="${base_ref}...${head_ref}"
fi

log=$(git log "${base_ref}...${head_ref}" \
log=$(git log "${flag}" \
--pretty=format:"* [\`%h\`](http://github.com/${repo_url}/commit/%H) - %s" \
--reverse)

Expand Down