From bc16f900b8122966eda9815d22d663724c0dbe49 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran Date: Wed, 29 Nov 2023 20:25:31 +0530 Subject: [PATCH] feat: add change log template --- .github/git-cliff-changelog.toml | 8 +-- .github/workflows/release-new-version.yml | 80 +++++++++++++++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release-new-version.yml diff --git a/.github/git-cliff-changelog.toml b/.github/git-cliff-changelog.toml index 1d7e4080c..a82c637d8 100644 --- a/.github/git-cliff-changelog.toml +++ b/.github/git-cliff-changelog.toml @@ -5,14 +5,14 @@ # changelog header header = """ # Changelog\n -All notable changes to HyperSwitch will be documented here.\n +All notable changes to Hyperswitch Control Center will be documented here.\n """ # template for the changelog body # https://tera.netlify.app/docs/#introduction body = """ {% set newline = "\n" -%} -{% set commit_base_url = "https://github.com/juspay/hyperswitch/commit/" -%} -{% set compare_base_url = "https://github.com/juspay/hyperswitch/compare/" -%} +{% set commit_base_url = "https://github.com/juspay/hyperswitch-control-center/commit/" -%} +{% set compare_base_url = "https://github.com/juspay/hyperswitch-control-center/compare/" -%} {% if version -%} ## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }}) {% else -%} @@ -54,7 +54,7 @@ split_commits = false 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/pull/${1}))" }, # replace PR numbers with links + { pattern = "\\(#([0-9]+)\\)", replace = "([#${1}](https://github.com/juspay/hyperswitch-control-center/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 ] diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml new file mode 100644 index 000000000..93f3dc793 --- /dev/null +++ b/.github/workflows/release-new-version.yml @@ -0,0 +1,80 @@ +name: Release a new version + +# on: +# schedule: +# - cron: "30 14 * * 0-4" # Run workflow at 8 PM IST every Sunday-Thursday + +# workflow_dispatch: + +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true + + +on: + pull_request_target: + types: + - closed + +env: + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + +jobs: + create-release: + name: Release a new version + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.AUTO_RELEASE_PAT }} + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable 2 weeks ago + + - name: Install cocogitto + uses: baptiste0928/cargo-install@v2.2.0 + with: + crate: cocogitto + version: 5.4.0 + + - name: Set Git Configuration + shell: bash + run: | + git config --local user.name 'github-actions' + git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' + + - 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: 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