Skip to content

Commit

Permalink
feat(test): new test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chethan-rao committed Nov 24, 2023
1 parent 2fce24c commit a4ee9a4
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 53 deletions.
56 changes: 56 additions & 0 deletions .github/cocogitto-changelog-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{# Using a literal newline to set the newline variable -#}
{% set newline = "
" -%}

{% set commit_base_url = repository_url ~ "/commit/" -%}
{% set compare_base_url = repository_url ~ "/compare/" -%}
{% set pr_base_url = repository_url ~ "/pull/" -%}

{% if version.tag -%}
## {{ version.tag | trim_start_matches(pat="v") }} ({{ date | date(format="%Y-%m-%d") }})
{% else -%}
{% set from = from.id -%}
{% set to = version.id -%}

{% set from_shorthand = from.id | truncate(length=7, end="") -%}
{% set to_shorthand = version.id | truncate(length=7, end="") -%}

## Unreleased ([`{{ from_shorthand ~ ".." ~ to_shorthand }}`]({{ compare_base_url ~ from_shorthand ~ ".." ~ to_shorthand }}))
{% endif -%}

{% for type, typed_commits in commits | sort(attribute="type") | group_by(attribute="type") %}
{# The `striptags` removes the HTML comments added while grouping -#}
### {{ type | striptags | trim | upper_first }}
{% for scope, scoped_commits in typed_commits | group_by(attribute="scope") %}
- {{ "**" ~ scope ~ ":" ~ "**" -}}
{% for commit in scoped_commits | sort(attribute="date") -%}
{% set shorthand = commit.id | truncate(length=7, end="") -%}
{% set commit_link = commit_base_url ~ commit.id -%}
{# Replace PR numbers in commit message with PR link -#}
{% set pr_number = commit.summary | split(pat="(#") | last | trim_end_matches(pat=")") -%}
{% set pr_link = "[#" ~ pr_number ~ "](" ~ pr_base_url ~ pr_number ~ ")" -%}
{% if scoped_commits | length != 1 %}{{ newline ~ " - " }}{% else %}{{ " " }}{% endif -%}
{{ commit.summary | upper_first | trim | replace(from="#" ~ pr_number, to=pr_link) }} ([`{{ shorthand }}`]({{ commit_link }}))
{%- endfor -%}
{% endfor -%}

{% for commit in typed_commits | unscoped | sort(attribute="date") -%}
{% set shorthand = commit.id | truncate(length=7, end="") -%}
{% set commit_link = commit_base_url ~ commit.id -%}
{# Replace PR numbers in commit message with PR link -#}
{% set pr_number = commit.summary | split(pat="(#") | last | trim_end_matches(pat=")") -%}
{% set pr_link = "[#" ~ pr_number ~ "](" ~ pr_base_url ~ pr_number ~ ")" -%}
{{ newline ~ "- "}}{{ commit.summary | upper_first | trim | replace(from="#" ~ pr_number, to=pr_link) }} ([`{{ shorthand }}`]({{ commit_link }}))
{%- endfor %}
{% endfor %}
{% if version.tag and from.tag -%}
**Full Changelog:** [`{{ from.tag ~ "..." ~ version.tag }}`]({{ compare_base_url ~ from.tag ~ "..." ~ version.tag }})
{%- elif version.tag and from.id -%}
**Full Changelog:** [`{{ from.id ~ "..." ~ version.tag }}`]({{ compare_base_url ~ from.id ~ "..." ~ version.tag }})
{%- else -%}
{% set from = from.id -%}
{% set to = version.id -%}
{% set from_shorthand = from.id | truncate(length=7, end="") -%}
{% set to_shorthand = version.id | truncate(length=7, end="") -%}
**Full Changelog:** [`{{ from_shorthand ~ "..." ~ to_shorthand }}`]({{ compare_base_url ~ from_shorthand ~ "..." ~ to_shorthand }})
{%- endif %}
89 changes: 89 additions & 0 deletions .github/git-cliff-release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# configuration file for git-cliff
# see https://github.com/orhun/git-cliff#configuration-file

[changelog]
# changelog header
header = ""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% set newline = "\n" -%}
{% set commit_base_url = "https://github.com/juspay/hyperswitch-card-vault/commit/" -%}
{% set compare_base_url = "https://github.com/juspay/hyperswitch-card-vault/compare/" -%}
{% if version -%}
## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }})
{% else -%}
## [unreleased]
{% endif -%}
{% for group, commits in commits | group_by(attribute="group") %}
{# The `striptags` removes the HTML comments added while grouping -#}
### {{ group | striptags | trim | upper_first }}
{% for scope, commits in commits | group_by(attribute="scope") %}
- {{ "**" ~ scope ~ ":" ~ "**" -}}
{% for commit in commits -%}
{% if commits | length != 1 %}{{ newline ~ " - " }}{% else %}{{ " " }}{% endif -%}
{{ commit.message | upper_first | trim }} ([`{{ commit.id | truncate(length=7, end="") }}`]({{ commit_base_url ~ commit.id }})) by {{ commit.author.email -}}
{%- endfor -%}
{%- endfor -%}
{%- for commit in commits -%}
{% if commit.scope %}{% else %}
- {{ commit.message | upper_first | trim }} ([`{{ commit.id | truncate(length=7, end="") }}`]({{ commit_base_url ~ commit.id }})) by {{ commit.author.email -}}
{%- endif %}
{%- endfor %}
{% endfor %}
{% if previous and previous.commit_id and commit_id -%}
**Full Changelog:** [`{{ previous.version }}...{{ version }}`]({{ compare_base_url }}{{ previous.version }}...{{ version }})\n
{% endif %}
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = ""

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = false
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
{ pattern = "^ +", replace = "" }, # remove spaces at the beginning of the message
{ pattern = " +", replace = " " }, # replace multiple spaces with a single space
{ pattern = "\\(#([0-9]+)\\)", replace = "([#${1}](https://github.com/juspay/hyperswitch-card-vault/pull/${1}))" }, # replace PR numbers with links
{ pattern = "(\\n?Co-authored-by: .+ <.+@.+>\\n?)+", replace = "" }, # remove co-author information
{ pattern = "(\\n?Signed-off-by: .+ <.+@.+>\\n?)+", replace = "" }, # remove sign-off information
]
# regex for parsing and grouping commits
# the HTML comments (`<!-- N -->`) are a workaround to get sections in custom order, since `git-cliff` sorts sections in alphabetical order
# reference: https://github.com/orhun/git-cliff/issues/9
commit_parsers = [
{ message = "^(?i)(feat)", group = "<!-- 0 -->Features" },
{ message = "^(?i)(fix)", group = "<!-- 1 -->Bug Fixes" },
{ message = "^(?i)(perf)", group = "<!-- 2 -->Performance" },
{ body = ".*security", group = "<!-- 3 -->Security" },
{ message = "^(?i)(refactor)", group = "<!-- 4 -->Refactors" },
{ message = "^(?i)(test)", group = "<!-- 5 -->Testing" },
{ message = "^(?i)(docs)", group = "<!-- 6 -->Documentation" },
{ message = "^(?i)(chore\\(version\\)): V[\\d]+\\.[\\d]+\\.[\\d]+", skip = true },
{ message = "^(?i)(chore)", group = "<!-- 7 -->Miscellaneous Tasks" },
{ message = "^(?i)(build)", group = "<!-- 8 -->Build System / Dependencies" },
{ message = "^(?i)(ci)", skip = true },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# glob pattern for matching git tags
tag_pattern = "v[0-9]*"
# regex for skipping tags
# skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
# ignore_tags = ""
# sort the tags topologically
topo_order = true
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
# limit the number of commits included in the changelog.
# limit_commits = 42
119 changes: 67 additions & 52 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Release a new version

on:
push:
branches:
- "*"

workflow_dispatch:

jobs:
Expand All @@ -17,26 +21,34 @@ jobs:

- name: Checkout repository
uses: actions/checkout@v4
# with:
# fetch-depth: 0
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
fetch-depth: 0
# token: ${{ steps.generate_token.outputs.token }}

- name: Checkout repository
uses: actions/checkout@v3
if: ${{ github.event_name == 'push' }}
with:
fetch-depth: 0
# token: ${{ steps.generate_token.outputs.token }}

# - name: Install Rust
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: stable 2 weeks ago

- name: Install cocogitto
uses: baptiste0928/[email protected]
with:
crate: cocogitto
version: 5.4.0
# - name: Install cocogitto
# uses: baptiste0928/[email protected]
# with:
# crate: cocogitto
# version: 5.4.0

- name: Install git-cliff
uses: baptiste0928/[email protected]
with:
crate: git-cliff
version: 1.2.0
# - name: Install git-cliff
# uses: baptiste0928/[email protected]
# with:
# crate: git-cliff
# version: 1.2.0

# - name: Install changelog-gh-usernames
# uses: baptiste0928/[email protected]
Expand All @@ -45,47 +57,50 @@ jobs:
# git: https://github.com/SanchithHegde/changelog-gh-usernames
# rev: dab6da3ff99dbbff8650c114984c4d8be5161ac8

- name: Set Git Configuration
shell: bash
run: |
git config --local user.name 'Chethan'
git config --local user.email '[email protected]'
# - name: Set Git Configuration
# shell: bash
# run: |
# git config --local user.name 'Chethan'
# git config --local user.email '[email protected]'

- name: Obtain previous and new tag information
shell: bash
# Only consider tags on current branch when setting PREVIOUS_TAG
run: |
PREVIOUS_TAG="$(git tag --sort='version:refname' --merged | tail --lines 1)"
if [[ "$(cog bump --auto --dry-run)" == *"No conventional commits for your repository that required a bump"* ]]; then
NEW_TAG="$(cog bump --patch --dry-run)"
else
NEW_TAG="$(cog bump --auto --dry-run)"
fi
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV
# - name: Obtain previous and new tag information
# shell: bash
# # Only consider tags on current branch when setting PREVIOUS_TAG
# run: |
# git log
# git tag --sort='version:refname' --merged
# PREVIOUS_TAG="$(git tag --sort='version:refname' --merged | tail --lines 1)"
# if [[ "$(cog bump --auto --dry-run)" == *"No conventional commits for your repository that required a bump"* ]]; then
# NEW_TAG="$(cog bump --patch --dry-run)"
# else
# NEW_TAG="$(cog bump --auto --dry-run)"
# fi
# echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
# echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV
# echo "New tag: $NEW_TAG prev_tag: $PREVIOUS_TAG"

- name: Update changelog and create tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# Remove prefix 'v' from 'NEW_TAG' as cog bump --version expects only the version number
run: |
cog bump --version ${NEW_TAG#v}
# - name: Update changelog and create tag
# shell: bash
# if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# # Remove prefix 'v' from 'NEW_TAG' as cog bump --version expects only the version number
# run: |
# cog bump --version ${NEW_TAG#v}

- name: Push created commit and tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
run: |
git push
git push --tags
# - name: Push created commit and tag
# shell: bash
# if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# run: |
# git push
# git push --tags

- name: Generate release notes and create GitHub release
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
# Need to consider commits inclusive of previous tag to generate diff link between versions.
# This would also then require us to remove the last few lines from the changelog.
run: |
git-cliff --config .github/git-cliff-release.toml "${PREVIOUS_TAG}^..${NEW_TAG}" | changelog-gh-usernames | sed "/## ${PREVIOUS_TAG#v}/,\$d" > release-notes.md
gh release create "${NEW_TAG}" --notes-file release-notes.md --verify-tag --title "Hyperswitch-card-vault ${NEW_TAG}"
# - name: Generate release notes and create GitHub release
# shell: bash
# if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# env:
# GITHUB_TOKEN: ${{ github.token }}
# GH_TOKEN: ${{ steps.generate_token.outputs.token }}
# # Need to consider commits inclusive of previous tag to generate diff link between versions.
# # This would also then require us to remove the last few lines from the changelog.
# run: |
# git-cliff --config .github/git-cliff-release.toml "${PREVIOUS_TAG}^..${NEW_TAG}" | changelog-gh-usernames | sed "/## ${PREVIOUS_TAG#v}/,\$d" > release-notes.md
# gh release create "${NEW_TAG}" --notes-file release-notes.md --verify-tag --title "Hyperswitch-card-vault ${NEW_TAG}"
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,5 @@
#[allow(dead_code)]
enum PaymentMethod {
Card,
PayLater,
}
fn main() {}

0 comments on commit a4ee9a4

Please sign in to comment.