From 3a4d918959eff3d9edc3bd7926607d5b4e0a08ea Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Wed, 3 Dec 2025 17:45:01 +0530 Subject: [PATCH 1/4] feat!: Add release preview workflow with breaking ACM provider changes BREAKING CHANGE: ACM module now requires explicit provider aliases for cross-account DNS records. Consumers must pass provider configuration to the module. --- .github/workflows/pr-title.yaml | 48 +++++++ .github/workflows/release-preview.yaml | 177 +++++++++++++++++++++++++ .github/workflows/terraform.yaml | 11 ++ .preview-releaserc.json | 11 ++ 4 files changed, 247 insertions(+) create mode 100644 .github/workflows/pr-title.yaml create mode 100644 .github/workflows/release-preview.yaml create mode 100644 .preview-releaserc.json 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/release-preview.yaml b/.github/workflows/release-preview.yaml new file mode 100644 index 0000000..e9c6e74 --- /dev/null +++ b/.github/workflows/release-preview.yaml @@ -0,0 +1,177 @@ +name: Release Preview + +on: + workflow_call: + +jobs: + preview: + name: Preview Release + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup branch for semantic-release + run: | + # Explicitly checkout to the PR branch by name + git checkout -B ${{ github.event.pull_request.head.ref }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Setup preview config + run: | + # Update preview config with the PR branch name + sed -i.bak "s|BRANCH_PLACEHOLDER|${{ github.event.pull_request.head.ref }}|g" .preview-releaserc.json + rm .preview-releaserc.json.bak + + - name: Run semantic-release (dry-run) + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_COMMITTER_NAME: "github-actions[bot]" + GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com" + GIT_AUTHOR_NAME: "github-actions[bot]" + GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com" + run: | + # Unset GitHub Actions environment variables that interfere with semantic-release + unset GITHUB_REF + unset GITHUB_REF_NAME + unset GITHUB_HEAD_REF + unset GITHUB_BASE_REF + + # Set them to what we want + export GITHUB_REF="refs/heads/${{ github.event.pull_request.head.ref }}" + export GITHUB_REF_NAME="${{ github.event.pull_request.head.ref }}" + + # Temporarily use preview config + mv .releaserc.json .releaserc.json.main + cp .preview-releaserc.json .releaserc.json + + # Run semantic-release with inline package installation (same as your local command) + OUTPUT=$(npx --package semantic-release --package @semantic-release/exec --package conventional-changelog-conventionalcommits semantic-release 2>&1 || true) + echo "$OUTPUT" + + # Restore original config + rm .releaserc.json + mv .releaserc.json.main .releaserc.json + + # Extract version information + NEW_VERSION=$(echo "$OUTPUT" | grep -Eo "The next release version is [0-9]+\.[0-9]+\.[0-9]+" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" || echo "") + RELEASE_TYPE=$(echo "$OUTPUT" | grep -Eo "Analysis of [0-9]+ commits complete: [a-z]+ release" | grep -Eo "(major|minor|patch) release" | sed 's/ release//' || echo "") + + # Extract release notes (everything after "Release note for version") + RELEASE_NOTES=$(echo "$OUTPUT" | sed -n '/Release note for version/,$p' | tail -n +2 || echo "") + + # Save to outputs + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT + + # Save release notes for comment + echo "release_notes<> $GITHUB_OUTPUT + echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Display Preview + run: | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo " RELEASE PREVIEW" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "" + if [ -n "${{ steps.semantic.outputs.new_version }}" ]; then + echo "Version: v${{ steps.semantic.outputs.new_version }}" + echo "Release Type: ${{ steps.semantic.outputs.release_type }}" + echo "Status: Release will be published" + else + echo "Status: No release will be published" + echo "Reason: No relevant changes detected" + fi + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + + - name: Comment on PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const newVersion = '${{ steps.semantic.outputs.new_version }}'; + const releaseType = '${{ steps.semantic.outputs.release_type }}'; + + const releaseNotes = `${{ steps.semantic.outputs.release_notes }}`; + + let body; + if (newVersion) { + body = `## Release Preview + + **Version:** \`v${newVersion}\` + **Release Type:** \`${releaseType}\` + **Status:** Release will be published when merged to main + + --- + + ### Release Notes + + ${releaseNotes} + + --- + + *This preview is generated by semantic-release dry-run mode*`; + } + else { + body = `## Release Preview + + **Status:** No release will be published + **Reason:** No relevant changes detected + + --- + +
+ View full semantic-release log + + \`\`\` + ${{ steps.semantic.outputs.full_output }} + \`\`\` +
+ + --- + + *This preview is generated by semantic-release dry-run mode*`; + } + + // Find existing comment + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const botComment = comments.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('Release Preview') + ); + + // Update or create comment + if (botComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: body + }); + } diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml index 3c55029..a264739 100644 --- a/.github/workflows/terraform.yaml +++ b/.github/workflows/terraform.yaml @@ -15,6 +15,17 @@ on: - main - master jobs: + prTitlecheck: + name: PR title check + uses: ./.github/workflows/pr-title.yaml + + releasePreview: + name: Release Preview + uses: ./.github/workflows/release-preview.yaml + permissions: + contents: write + pull-requests: write + preCommitCheck: name: Terraform Checks uses: ./.github/workflows/terraform-checks.yaml diff --git a/.preview-releaserc.json b/.preview-releaserc.json new file mode 100644 index 0000000..d000f8a --- /dev/null +++ b/.preview-releaserc.json @@ -0,0 +1,11 @@ +{ + "branches": ["BRANCH_PLACEHOLDER"], + "debug": true, + "ci": false, + "dryRun": true, + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github" + ] +} From 1e03046473b18503cba8cc162a00ee63231903dc Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Thu, 4 Dec 2025 11:05:32 +0530 Subject: [PATCH 2/4] ci: Updated node version and used github action to display preview output --- .github/workflows/release-preview.yaml | 107 ++++++------------------- 1 file changed, 24 insertions(+), 83 deletions(-) diff --git a/.github/workflows/release-preview.yaml b/.github/workflows/release-preview.yaml index e9c6e74..c93c471 100644 --- a/.github/workflows/release-preview.yaml +++ b/.github/workflows/release-preview.yaml @@ -3,6 +3,10 @@ name: Release Preview on: workflow_call: +env: + SEMANTIC_RELEASE_VERSION: '24.2.0' + NODE_VERSION: '20.11.0' + jobs: preview: name: Preview Release @@ -18,21 +22,10 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} - - name: Setup branch for semantic-release - run: | - # Explicitly checkout to the PR branch by name - git checkout -B ${{ github.event.pull_request.head.ref }} - - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 'lts/*' - - - name: Setup preview config - run: | - # Update preview config with the PR branch name - sed -i.bak "s|BRANCH_PLACEHOLDER|${{ github.event.pull_request.head.ref }}|g" .preview-releaserc.json - rm .preview-releaserc.json.bak + node-version: ${{ env.NODE_VERSION }} - name: Run semantic-release (dry-run) id: semantic @@ -53,18 +46,17 @@ jobs: export GITHUB_REF="refs/heads/${{ github.event.pull_request.head.ref }}" export GITHUB_REF_NAME="${{ github.event.pull_request.head.ref }}" - # Temporarily use preview config - mv .releaserc.json .releaserc.json.main - cp .preview-releaserc.json .releaserc.json - - # Run semantic-release with inline package installation (same as your local command) - OUTPUT=$(npx --package semantic-release --package @semantic-release/exec --package conventional-changelog-conventionalcommits semantic-release 2>&1 || true) + # Run semantic-release with inline configuration using CLI options + OUTPUT=$(npx --package semantic-release@${{ env.SEMANTIC_RELEASE_VERSION }} \ + --package @semantic-release/exec \ + --package conventional-changelog-conventionalcommits \ + semantic-release \ + --dry-run \ + --no-ci \ + --debug \ + --branches ${{ github.event.pull_request.head.ref }} 2>&1 || true) echo "$OUTPUT" - # Restore original config - rm .releaserc.json - mv .releaserc.json.main .releaserc.json - # Extract version information NEW_VERSION=$(echo "$OUTPUT" | grep -Eo "The next release version is [0-9]+\.[0-9]+\.[0-9]+" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" || echo "") RELEASE_TYPE=$(echo "$OUTPUT" | grep -Eo "Analysis of [0-9]+ commits complete: [a-z]+ release" | grep -Eo "(major|minor|patch) release" | sed 's/ release//' || echo "") @@ -100,78 +92,27 @@ jobs: - name: Comment on PR if: github.event_name == 'pull_request' - uses: actions/github-script@v7 + uses: mshick/add-pr-comment@v2 with: - script: | - const newVersion = '${{ steps.semantic.outputs.new_version }}'; - const releaseType = '${{ steps.semantic.outputs.release_type }}'; + message-id: release-preview + message: | + ## Release Preview - const releaseNotes = `${{ steps.semantic.outputs.release_notes }}`; - - let body; - if (newVersion) { - body = `## Release Preview - - **Version:** \`v${newVersion}\` - **Release Type:** \`${releaseType}\` + ${{ steps.semantic.outputs.new_version && format('**Version:** `v{0}` + **Release Type:** `{1}` **Status:** Release will be published when merged to main --- - ### Release Notes + ### Release Notes - ${releaseNotes} + {2} --- - *This preview is generated by semantic-release dry-run mode*`; - } - else { - body = `## Release Preview - - **Status:** No release will be published + *This preview is generated by semantic-release dry-run mode*', steps.semantic.outputs.new_version, steps.semantic.outputs.release_type, steps.semantic.outputs.release_notes) || '**Status:** ❌ No release will be published **Reason:** No relevant changes detected --- -
- View full semantic-release log - - \`\`\` - ${{ steps.semantic.outputs.full_output }} - \`\`\` -
- - --- - - *This preview is generated by semantic-release dry-run mode*`; - } - - // Find existing comment - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }); - - const botComment = comments.find(comment => - comment.user.type === 'Bot' && - comment.body.includes('Release Preview') - ); - - // Update or create comment - if (botComment) { - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: botComment.id, - body: body - }); - } else { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: body - }); - } + *This preview is generated by semantic-release dry-run mode*' }} From 8f483dc149ecd52f4f13ba26436f71d58110ff15 Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Thu, 4 Dec 2025 11:12:07 +0530 Subject: [PATCH 3/4] ci: removed unused preview-release file --- .preview-releaserc.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .preview-releaserc.json diff --git a/.preview-releaserc.json b/.preview-releaserc.json deleted file mode 100644 index d000f8a..0000000 --- a/.preview-releaserc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "branches": ["BRANCH_PLACEHOLDER"], - "debug": true, - "ci": false, - "dryRun": true, - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/github" - ] -} From 23050912ee53b9b3614251889cfa8e88f933b8ed Mon Sep 17 00:00:00 2001 From: rahul-infra Date: Thu, 4 Dec 2025 11:22:51 +0530 Subject: [PATCH 4/4] ci: removed unwanted debug. --- .github/workflows/release-preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-preview.yaml b/.github/workflows/release-preview.yaml index c93c471..cc5ce4b 100644 --- a/.github/workflows/release-preview.yaml +++ b/.github/workflows/release-preview.yaml @@ -110,7 +110,7 @@ jobs: --- - *This preview is generated by semantic-release dry-run mode*', steps.semantic.outputs.new_version, steps.semantic.outputs.release_type, steps.semantic.outputs.release_notes) || '**Status:** ❌ No release will be published + *This preview is generated by semantic-release dry-run mode*', steps.semantic.outputs.new_version, steps.semantic.outputs.release_type, steps.semantic.outputs.release_notes) || '**Status:** No release will be published **Reason:** No relevant changes detected ---