Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
CI: add workflow to create hotfix tag (#2532)
Shankar Singh Cc51cc9d555d4
diff --git a/.github/workflows/create-hotfix-tag.yml b/.github/workflows/create-hotfix-tag.ymlnew file mode 100644index 0000000000..378f4d71de--- /dev/null+++ b/.github/workflows/create-hotfix-tag.yml@@ -0,0 +1,98 @@+name: Create tag on hotfix branch++on:+ workflow_dispatch:++jobs:+ create_tag:+ runs-on: ubuntu-latest++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3+ with:+ fetch-depth: 0+ token: ${{ secrets.AUTO_RELEASE_PAT }}++ - name: Install git-cliff+ uses: baptiste0928/[email protected]+ with:+ crate: git-cliff+ version: 1.2.0++ - name: Check if the input is valid hotfix branch+ shell: bash+ run: |+ if [[ ${{github.ref}} =~ ^refs/heads/hotfix-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ echo "::notice::${{github.ref}} is a valid branch."+ else+ echo "::error::${{github.ref}} is not a valid branch."+ fi++ - name: Check if the latest commit is tag+ shell: bash+ run: |+ if [[ -z "$(git tag --points-at HEAD)" ]]; then+ echo "::notice::The latest commit is not a tag "+ else+ echo "::error::The latest commit on the branch is already a tag"+ fi++ - name: Determine current and next tag+ shell: bash+ run: |+ function get_next_tag() {+ local previous_tag="${1}"+ local previous_hotfix_number+ local next_tag++ previous_hotfix_number="$(echo "${previous_tag}" | awk -F. '{ print $4 }')"++ if [[ -z "${previous_hotfix_number}" ]]; then+ # Previous tag was not a hotfix tag+ next_tag="${previous_tag}+hotfix.1"+ else+ # Previous tag was a hotfix tag, increment hotfix number+ local hotfix_number=$((previous_hotfix_number + 1))+ next_tag="${previous_tag/%${previous_hotfix_number}/${hotfix_number}}"+ fi++ echo "${next_tag}"+ }++ PREVIOUS_TAG="$(git tag --merged | sort --version-sort | tail --lines 1)"+ NEXT_TAG="$(get_next_tag "${PREVIOUS_TAG}")"++ echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV+ echo "NEXT_TAG=${NEXT_TAG}" >> $GITHUB_ENV++ - name: Generate changelog+ shell: bash+ run: |+ # Generate changelog content and store it in `release-notes.md`+ git-cliff --config '.github/git-cliff-changelog.toml' --strip header --tag "${NEXT_TAG}" "${PREVIOUS_TAG}^.." \+ | sed "/## ${PREVIOUS_TAG#v}\$/,\$d" \+ | sed '$s/$/\n- - -/' > release-notes.md++ # Append release notes after the specified pattern in CHANGELOG.md+ sed --in-place '0,/^- - -/!b; /^- - -/{+ a+ r release-notes.md+ }' CHANGELOG.md+ rm release-notes.md++ - 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: Push created commit and tag+ shell: bash+ run: |+ # Stage, commit and tag the changelog+ git add CHANGELOG.md+ git commit --message "chore(version): ${NEXT_TAG}"+ git tag --message "$(git show --no-patch --format=%s HEAD)" "${NEXT_TAG}" HEAD+ git push+ git push --tagsdiff --git a/.github/workflows/hotfix-branch-creation.yml b/.github/workflows/hotfix-branch-creation.ymlindex ced5880faf..77a8bad6bc 100644--- a/.github/workflows/hotfix-branch-creation.yml+++ b/.github/workflows/hotfix-branch-creation.yml@@ -1,4 +1,4 @@-name: Create a new hotfix branch+name: Create hotfix branchon:workflow_dispatch: