From 5816a0dc346b75d0fe9cc5461e969faff02b35f6 Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 13:14:14 +0530 Subject: [PATCH 1/6] feat!: Updated pr title check and preview release type Made changes in terraform workflow Updated github workflows. removed github token decleration in my new version preview feat!: breaking change to workflow BREAKING CHANGE: Updated release preview mechanism fix: use PR merge ref for version preview fix: changes versionpreview.yaml fix: Updated Preview.yaml file fix: updated versions-preview workflow making it edit the existing release preview refactor: simplify version preview using semantic-release action fix: configure semantic-release to analyze PR branches fix: use semantic-release with proper branch configuration fix: create branch instead of renaming in detached HEAD debug: add logging to see what semantic-release sees fix: pass PR number as input to version-preview workflow fix: made changes in version-preivew for using sematic release. --- .github/workflows/pr-title.yaml | 48 ++++++++++++++++ .github/workflows/terraform.yaml | 16 ++++++ .github/workflows/version-preview.yaml | 77 ++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 .github/workflows/pr-title.yaml create mode 100644 .github/workflows/version-preview.yaml diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml new file mode 100644 index 0000000..9ec553f --- /dev/null +++ b/.github/workflows/pr-title.yaml @@ -0,0 +1,48 @@ +name: 'Validate PR title' + +on: + workflow_call: + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + # Please look up the latest version from + # https://github.com/amannn/action-semantic-pull-request/releases + - uses: amannn/action-semantic-pull-request@v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # Configure which types are allowed. + # Default: https://github.com/commitizen/conventional-commit-types + types: | + fix + feat + docs + ci + chore + # Configure that a scope must always be provided. + requireScope: false + # Configure additional validation for the subject based on a regex. + # This example ensures the subject starts with an uppercase character. + subjectPattern: ^[A-Z].+$ + # If `subjectPattern` is configured, you can use this property to override + # the default error message that is shown when the pattern doesn't match. + # The variables `subject` and `title` can be used within the message. + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase character. + # For work-in-progress PRs you can typically use draft pull requests + # from Github. However, private repositories on the free plan don't have + # this option and therefore this action allows you to opt-in to using the + # special "[WIP]" prefix to indicate this state. This will avoid the + # validation of the PR title and the pull request checks remain pending. + # Note that a second check will be reported if this is enabled. + wip: true + # When using "Squash and merge" on a PR with only one commit, GitHub + # will suggest using that commit message instead of the PR title for the + # merge commit, and it's easy to commit this by mistake. Enable this option + # to also validate the commit message for one commit PRs. + validateSingleCommit: false diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml index 3c55029..59ccfca 100644 --- a/.github/workflows/terraform.yaml +++ b/.github/workflows/terraform.yaml @@ -6,6 +6,9 @@ on: - main - master pull_request_target: + branches: + - main + - master types: - opened - edited @@ -15,6 +18,19 @@ on: - main - master jobs: + prTitlecheck: + name: PR title check + if: ${{ github.event_name == 'pull_request_target' }} + uses: ./.github/workflows/pr-title.yaml + + versionPreview: + name: Version Preview + if: ${{ github.event_name == 'pull_request' }} + permissions: + contents: read + pull-requests: write + uses: ./.github/workflows/version-preview.yaml + preCommitCheck: name: Terraform Checks uses: ./.github/workflows/terraform-checks.yaml diff --git a/.github/workflows/version-preview.yaml b/.github/workflows/version-preview.yaml new file mode 100644 index 0000000..2410b58 --- /dev/null +++ b/.github/workflows/version-preview.yaml @@ -0,0 +1,77 @@ +name: 'Version Preview' + +on: + workflow_call: + +defaults: + run: + shell: bash + +permissions: + contents: read + pull-requests: write + +jobs: + preview: + name: Preview Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Analyze PR commits + id: semantic + run: | + git fetch origin ${{ github.base_ref }} + + COMMITS=$(git log origin/${{ github.base_ref }}..HEAD --pretty=format:"%s") + + if echo "$COMMITS" | grep -qE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE:"; then + TYPE="major" + elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then + TYPE="minor" + elif echo "$COMMITS" | grep -qE "^fix(\(.+\))?:"; then + TYPE="patch" + else + TYPE="none" + fi + + if [ "$TYPE" != "none" ]; then + CURRENT=$(git tag --sort=-v:refname | head -1 | sed 's/^v//') + IFS='.' read -r maj min pat <<< "$CURRENT" + + [ "$TYPE" = "major" ] && maj=$((maj + 1)) && min=0 && pat=0 + [ "$TYPE" = "minor" ] && min=$((min + 1)) && pat=0 + [ "$TYPE" = "patch" ] && pat=$((pat + 1)) + + echo "new_release_published=true" >> $GITHUB_OUTPUT + echo "new_release_version=$maj.$min.$pat" >> $GITHUB_OUTPUT + echo "new_release_type=$TYPE" >> $GITHUB_OUTPUT + echo "new_release_notes<> $GITHUB_OUTPUT + echo "## Changes in this PR" >> $GITHUB_OUTPUT + echo "$COMMITS" | sed 's/^/- /' >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + else + echo "new_release_published=false" >> $GITHUB_OUTPUT + fi + + - name: Comment PR + if: always() + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: release-preview + message: | + ## Release Preview + + ${{ steps.semantic.outputs.new_release_published == 'true' && format('**Release Type:** `{0}` + **Next Version:** `v{1}` + + ### Release Notes + {2} + + --- + *This shows what release will be created when this PR is merged.*', steps.semantic.outputs.new_release_type, steps.semantic.outputs.new_release_version, steps.semantic.outputs.new_release_notes) || 'No new release will be created from this PR. + + This PR does not contain conventional commits that trigger a release.' }} From 2ce524f20938f8a285c0f1e08c0b37edf21d543c Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 17:38:55 +0530 Subject: [PATCH 2/6] fix: updated versions.tf --- .github/workflows/version-preview.yaml | 55 ++++++++++---------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/.github/workflows/version-preview.yaml b/.github/workflows/version-preview.yaml index 2410b58..e8dba35 100644 --- a/.github/workflows/version-preview.yaml +++ b/.github/workflows/version-preview.yaml @@ -21,41 +21,28 @@ jobs: with: fetch-depth: 0 - - name: Analyze PR commits + - name: Semantic Release (Dry Run) id: semantic - run: | - git fetch origin ${{ github.base_ref }} - - COMMITS=$(git log origin/${{ github.base_ref }}..HEAD --pretty=format:"%s") - - if echo "$COMMITS" | grep -qE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE:"; then - TYPE="major" - elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then - TYPE="minor" - elif echo "$COMMITS" | grep -qE "^fix(\(.+\))?:"; then - TYPE="patch" - else - TYPE="none" - fi - - if [ "$TYPE" != "none" ]; then - CURRENT=$(git tag --sort=-v:refname | head -1 | sed 's/^v//') - IFS='.' read -r maj min pat <<< "$CURRENT" - - [ "$TYPE" = "major" ] && maj=$((maj + 1)) && min=0 && pat=0 - [ "$TYPE" = "minor" ] && min=$((min + 1)) && pat=0 - [ "$TYPE" = "patch" ] && pat=$((pat + 1)) - - echo "new_release_published=true" >> $GITHUB_OUTPUT - echo "new_release_version=$maj.$min.$pat" >> $GITHUB_OUTPUT - echo "new_release_type=$TYPE" >> $GITHUB_OUTPUT - echo "new_release_notes<> $GITHUB_OUTPUT - echo "## Changes in this PR" >> $GITHUB_OUTPUT - echo "$COMMITS" | sed 's/^/- /' >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - else - echo "new_release_published=false" >> $GITHUB_OUTPUT - fi + uses: cycjimmy/semantic-release-action@v4 + with: + semantic_version: 18.0.0 + dry_run: true + branches: | + [ + '+([0-9])?(.{+([0-9]),x}).x', + 'main', + 'master', + { + name: '*', + prerelease: true + } + ] + extra_plugins: | + @semantic-release/changelog@6.0.0 + @semantic-release/git@10.0.0 + conventional-changelog-conventionalcommits@4.6.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR if: always() From cf202379d2d9f63e5c14ab3fbab8afb037901495 Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 18:03:52 +0530 Subject: [PATCH 3/6] debug semantic release preview --- .github/workflows/version-preview.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/version-preview.yaml b/.github/workflows/version-preview.yaml index e8dba35..5ca7868 100644 --- a/.github/workflows/version-preview.yaml +++ b/.github/workflows/version-preview.yaml @@ -21,6 +21,20 @@ jobs: with: fetch-depth: 0 + - name: Debug Git State + run: | + echo "Current branch: $(git branch --show-current)" + echo "Current HEAD: $(git rev-parse HEAD)" + echo "" + echo "Latest 5 commits:" + git log --oneline -5 + echo "" + echo "Latest tag:" + git describe --tags --abbrev=0 || echo "No tags found" + echo "" + echo "Commits since last tag:" + git log $(git describe --tags --abbrev=0 2>/dev/null || echo "HEAD~10")..HEAD --oneline || echo "Cannot determine" + - name: Semantic Release (Dry Run) id: semantic uses: cycjimmy/semantic-release-action@v4 From 061ffd9da30ffc7052bd5d8fb5be107b4cd75ada Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 18:31:06 +0530 Subject: [PATCH 4/6] fix: create temp branch for semantic-release analysis --- .github/workflows/version-preview.yaml | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.github/workflows/version-preview.yaml b/.github/workflows/version-preview.yaml index 5ca7868..010bbe6 100644 --- a/.github/workflows/version-preview.yaml +++ b/.github/workflows/version-preview.yaml @@ -21,19 +21,12 @@ jobs: with: fetch-depth: 0 - - name: Debug Git State + - name: Create temporary branch run: | - echo "Current branch: $(git branch --show-current)" - echo "Current HEAD: $(git rev-parse HEAD)" - echo "" - echo "Latest 5 commits:" - git log --oneline -5 - echo "" - echo "Latest tag:" - git describe --tags --abbrev=0 || echo "No tags found" - echo "" - echo "Commits since last tag:" - git log $(git describe --tags --abbrev=0 2>/dev/null || echo "HEAD~10")..HEAD --oneline || echo "Cannot determine" + echo "Current state: detached HEAD" + echo "Creating temporary branch for semantic-release..." + git checkout -b temp-preview-branch + echo "Now on branch: $(git branch --show-current)" - name: Semantic Release (Dry Run) id: semantic @@ -43,13 +36,7 @@ jobs: dry_run: true branches: | [ - '+([0-9])?(.{+([0-9]),x}).x', - 'main', - 'master', - { - name: '*', - prerelease: true - } + 'temp-preview-branch' ] extra_plugins: | @semantic-release/changelog@6.0.0 From ee95bc4727482cd8e02e5ad229c486d0eb4ee9a3 Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 18:39:55 +0530 Subject: [PATCH 5/6] feat: add version preview using semantic-release with dry-run --- .github/workflows/version-preview.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/version-preview.yaml b/.github/workflows/version-preview.yaml index 010bbe6..861240f 100644 --- a/.github/workflows/version-preview.yaml +++ b/.github/workflows/version-preview.yaml @@ -22,11 +22,7 @@ jobs: fetch-depth: 0 - name: Create temporary branch - run: | - echo "Current state: detached HEAD" - echo "Creating temporary branch for semantic-release..." - git checkout -b temp-preview-branch - echo "Now on branch: $(git branch --show-current)" + run: git checkout -b temp-preview-branch - name: Semantic Release (Dry Run) id: semantic From 784808c2d84f2b55f750d52f3d1cf4e5f1558f64 Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Tue, 2 Dec 2025 22:40:06 +0530 Subject: [PATCH 6/6] feat!: Updated readme for cross-account provider BREAKING CHANGES: Made changes for readme file in cross-account examples. --- examples/cross-account/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cross-account/README.md b/examples/cross-account/README.md index 4a809d3..70ba35e 100644 --- a/examples/cross-account/README.md +++ b/examples/cross-account/README.md @@ -26,7 +26,7 @@ route53:ChangeResourceRecordSets route53:ListHostedZonesByName route53:ListResourceRecordSets -And a trust policy allowing Account A to assume the role. +And a trust policy which allows Account A to assume the role. ## Example `tfvars` Configuration