diff --git a/git-cliff-release/action.yaml b/git-cliff-release/action.yaml index b2cfb49..2900dda 100644 --- a/git-cliff-release/action.yaml +++ b/git-cliff-release/action.yaml @@ -105,14 +105,15 @@ runs: working-directory: ${{ github.action_path }} run: | set -x + enhance_context_args=() + + if (( ${{ inputs.no-github }} )); then + enhance_context_args+=(--no-github) + fi + echo 'release_notes<> $GITHUB_OUTPUT git-cliff --tag "${{ steps.version_number.outputs.tag_name }}" --unreleased --context | - { - if [[ ${{ inputs.no-github }} = true ]]; - then cat; - else python enhance_context.py --repo $GITHUB_REPO --release-notes; - fi; - } | + python enhance_context.py --repo $GITHUB_REPO --release-notes "${enhance_context_args[@]}" | git-cliff --from-context - --strip all | tee -a $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT @@ -145,6 +146,10 @@ runs: print_changelog_args+=(--output "$out_file") fi + if (( ${{ inputs.no-github }} )); then + enhance_context_args+=(--no-github) + fi + if [[ ${{ inputs.release_type }} = prerelease ]]; then enhance_context_args+=(--unreleased-version "${{ steps.version_number.outputs.tag_name }}") else @@ -152,12 +157,7 @@ runs: fi git-cliff --context "${dump_context_args[@]}" | - { - if [[ ${{ inputs.no-github }} = true ]]; - then cat; - else python enhance_context.py --repo $GITHUB_REPO "${enhance_context_args[@]}"; - fi; - } | + python enhance_context.py --repo $GITHUB_REPO "${enhance_context_args[@]}" | git-cliff --from-context - "${print_changelog_args[@]}" sed -i '$a\' $out_file # Make sure there is a newline at the end of the output file diff --git a/git-cliff-release/cliff.toml b/git-cliff-release/cliff.toml index 34165ec..79997e8 100644 --- a/git-cliff-release/cliff.toml +++ b/git-cliff-release/cliff.toml @@ -38,7 +38,7 @@ body = """ {% if commit.extra.commit_link %} ([{{ commit.id | truncate(length = 7, end = "") }}]({{ commit.extra.commit_link }})){% endif %}\ {% if commit.remote.username and extra.is_release_notes %}\ {{" "}}by @{{ commit.remote.username }}\ - {% elif commit.remote.username %}\ + {% elif not extra.no_github and commit.remote.username %}\ {{" "}}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})\ {% if commit.extra.closed_issue_links %}\ , closes {{ commit.extra.closed_issue_links | join(sep = ", ") }}\ diff --git a/git-cliff-release/enhance_context.py b/git-cliff-release/enhance_context.py index 3375783..5951e3c 100644 --- a/git-cliff-release/enhance_context.py +++ b/git-cliff-release/enhance_context.py @@ -66,6 +66,7 @@ def enhance_commit(commit: dict[str, Any], pr_issues: dict[int, list[int]]) -> N parser.add_argument("--repo", type=str, required=True) parser.add_argument("--unreleased-version", nargs="?", default=None, type=str) parser.add_argument("--release-notes", action=BooleanOptionalAction) +parser.add_argument("--no-github", type=bool, required=False, default=False) if __name__ == "__main__": @@ -77,6 +78,10 @@ def enhance_commit(commit: dict[str, Any], pr_issues: dict[int, list[int]]) -> N context = json.load(sys.stdin) for release in context: + if args.no_github: + release["extra"] = { 'no_github': True } + continue + enhance_release(release, args.release_notes, args.unreleased_version) for commit in release["commits"]: