Skip to content

Commit 1983782

Browse files
author
rahul-infra
committed
feat!: Updated changes for cross account and thegithub workflows for preview release notes.
BREAKING CHANGE: Kong module now requires explicit provider aliases for cross-account DNS records.
1 parent b32ea2a commit 1983782

File tree

9 files changed

+127
-2
lines changed

9 files changed

+127
-2
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Release Preview
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
SEMANTIC_RELEASE_VERSION: '24.2.0'
8+
NODE_VERSION: '20.11.0'
9+
10+
jobs:
11+
preview:
12+
name: Preview Release
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ env.NODE_VERSION }}
29+
30+
- name: Run semantic-release (dry-run)
31+
id: semantic
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GIT_COMMITTER_NAME: "github-actions[bot]"
35+
GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com"
36+
GIT_AUTHOR_NAME: "github-actions[bot]"
37+
GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com"
38+
run: |
39+
# Unset GitHub Actions environment variables that interfere with semantic-release
40+
unset GITHUB_REF
41+
unset GITHUB_REF_NAME
42+
unset GITHUB_HEAD_REF
43+
unset GITHUB_BASE_REF
44+
45+
# Set them to what we want
46+
export GITHUB_REF="refs/heads/${{ github.event.pull_request.head.ref }}"
47+
export GITHUB_REF_NAME="${{ github.event.pull_request.head.ref }}"
48+
49+
# Run semantic-release with inline configuration using CLI options
50+
OUTPUT=$(npx --package semantic-release@${{ env.SEMANTIC_RELEASE_VERSION }} \
51+
--package @semantic-release/exec \
52+
--package conventional-changelog-conventionalcommits \
53+
semantic-release \
54+
--dry-run \
55+
--no-ci \
56+
--debug \
57+
--branches ${{ github.event.pull_request.head.ref }} 2>&1 || true)
58+
echo "$OUTPUT"
59+
60+
# Extract version information
61+
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 "")
62+
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 "")
63+
64+
# Extract release notes (everything after "Release note for version")
65+
RELEASE_NOTES=$(echo "$OUTPUT" | sed -n '/Release note for version/,$p' | tail -n +2 || echo "")
66+
67+
# Save to outputs
68+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
69+
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
70+
71+
# Save release notes for comment
72+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
73+
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
74+
echo "EOF" >> $GITHUB_OUTPUT
75+
76+
- name: Display Preview
77+
run: |
78+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
79+
echo " RELEASE PREVIEW"
80+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
81+
echo ""
82+
if [ -n "${{ steps.semantic.outputs.new_version }}" ]; then
83+
echo "Version: v${{ steps.semantic.outputs.new_version }}"
84+
echo "Release Type: ${{ steps.semantic.outputs.release_type }}"
85+
echo "Status: Release will be published"
86+
else
87+
echo "Status: No release will be published"
88+
echo "Reason: No relevant changes detected"
89+
fi
90+
echo ""
91+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
92+
93+
- name: Comment on PR
94+
if: github.event_name == 'pull_request'
95+
uses: mshick/add-pr-comment@v2
96+
with:
97+
message-id: release-preview
98+
message: |
99+
## Release Preview
100+
101+
${{ steps.semantic.outputs.new_version && format('**Version:** `v{0}`
102+
**Release Type:** `{1}`
103+
**Status:** Release will be published when merged to main
104+
105+
---
106+
107+
### Release Notes
108+
109+
{2}
110+
111+
---
112+
113+
*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
114+
**Reason:** No relevant changes detected
115+
116+
---
117+
118+
*This preview is generated by semantic-release dry-run mode*' }}

.github/workflows/terraform.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main' }}
2525
uses: ./.github/workflows/pr-title.yaml
2626

27+
releasePreview:
28+
name: Release Preview
29+
uses: ./.github/workflows/release-preview.yaml
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
2734
preCommitCheck:
2835
name: Terraform Checks
2936
uses: ./.github/workflows/terraform-checks.yaml
File renamed without changes.
File renamed without changes.

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ data "aws_ecs_cluster" "this" {
204204

205205
module "ecs_kong" {
206206
source = "infraspecdev/ecs-deployment/aws"
207-
version = "4.3.6"
207+
version = "~> 5.0.0"
208208

209209
vpc_id = var.vpc_id
210210
cluster_name = data.aws_ecs_cluster.this.cluster_name
@@ -346,7 +346,7 @@ module "ecs_kong" {
346346

347347
module "internal_alb_kong" {
348348
source = "infraspecdev/ecs-deployment/aws//modules/alb"
349-
version = "~> 4.3.4"
349+
version = "~> 5.0.0"
350350

351351
name = "${local.kong.name}-internal"
352352
internal = true

0 commit comments

Comments
 (0)