Skip to content

Commit

Permalink
feat: add --no-github flag to enhance_context.py
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin committed Dec 17, 2024
1 parent c8c2f75 commit 36d0004
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
24 changes: 12 additions & 12 deletions git-cliff-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF' >> $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
Expand Down Expand Up @@ -145,19 +146,18 @@ 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
dump_context_args+=(--tag "${{ steps.version_number.outputs.tag_name }}")
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
Expand Down
2 changes: 1 addition & 1 deletion git-cliff-release/cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ", ") }}\
Expand Down
5 changes: 5 additions & 0 deletions git-cliff-release/enhance_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand All @@ -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"]:
Expand Down

0 comments on commit 36d0004

Please sign in to comment.