Skip to content

Commit 78f78ca

Browse files
author
rahul-infra
committed
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.
1 parent 5b078d7 commit 78f78ca

File tree

4 files changed

+247
-0
lines changed

4 files changed

+247
-0
lines changed

.github/workflows/pr-title.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Validate PR title'
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
main:
8+
name: Validate PR title
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Please look up the latest version from
12+
# https://github.com/amannn/action-semantic-pull-request/releases
13+
- uses: amannn/action-semantic-pull-request@v6.1.1
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
# Configure which types are allowed.
18+
# Default: https://github.com/commitizen/conventional-commit-types
19+
types: |
20+
fix
21+
feat
22+
docs
23+
ci
24+
chore
25+
# Configure that a scope must always be provided.
26+
requireScope: false
27+
# Configure additional validation for the subject based on a regex.
28+
# This example ensures the subject starts with an uppercase character.
29+
subjectPattern: ^[A-Z].+$
30+
# If `subjectPattern` is configured, you can use this property to override
31+
# the default error message that is shown when the pattern doesn't match.
32+
# The variables `subject` and `title` can be used within the message.
33+
subjectPatternError: |
34+
The subject "{subject}" found in the pull request title "{title}"
35+
didn't match the configured pattern. Please ensure that the subject
36+
starts with an uppercase character.
37+
# For work-in-progress PRs you can typically use draft pull requests
38+
# from Github. However, private repositories on the free plan don't have
39+
# this option and therefore this action allows you to opt-in to using the
40+
# special "[WIP]" prefix to indicate this state. This will avoid the
41+
# validation of the PR title and the pull request checks remain pending.
42+
# Note that a second check will be reported if this is enabled.
43+
wip: true
44+
# When using "Squash and merge" on a PR with only one commit, GitHub
45+
# will suggest using that commit message instead of the PR title for the
46+
# merge commit, and it's easy to commit this by mistake. Enable this option
47+
# to also validate the commit message for one commit PRs.
48+
validateSingleCommit: false
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Release Preview
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
preview:
8+
name: Preview Release
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
ref: ${{ github.event.pull_request.head.ref }}
20+
21+
- name: Setup branch for semantic-release
22+
run: |
23+
# Explicitly checkout to the PR branch by name
24+
git checkout -B ${{ github.event.pull_request.head.ref }}
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 'lts/*'
30+
31+
- name: Setup preview config
32+
run: |
33+
# Update preview config with the PR branch name
34+
sed -i.bak "s/BRANCH_PLACEHOLDER/${{ github.event.pull_request.head.ref }}/g" .preview-releaserc.json
35+
rm .preview-releaserc.json.bak
36+
37+
- name: Run semantic-release (dry-run)
38+
id: semantic
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GIT_COMMITTER_NAME: "github-actions[bot]"
42+
GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com"
43+
GIT_AUTHOR_NAME: "github-actions[bot]"
44+
GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com"
45+
run: |
46+
# Unset GitHub Actions environment variables that interfere with semantic-release
47+
unset GITHUB_REF
48+
unset GITHUB_REF_NAME
49+
unset GITHUB_HEAD_REF
50+
unset GITHUB_BASE_REF
51+
52+
# Set them to what we want
53+
export GITHUB_REF="refs/heads/${{ github.event.pull_request.head.ref }}"
54+
export GITHUB_REF_NAME="${{ github.event.pull_request.head.ref }}"
55+
56+
# Temporarily use preview config
57+
mv .releaserc.json .releaserc.json.main
58+
cp .preview-releaserc.json .releaserc.json
59+
60+
# Run semantic-release with inline package installation (same as your local command)
61+
OUTPUT=$(npx --package semantic-release --package @semantic-release/exec --package conventional-changelog-conventionalcommits semantic-release 2>&1 || true)
62+
echo "$OUTPUT"
63+
64+
# Restore original config
65+
rm .releaserc.json
66+
mv .releaserc.json.main .releaserc.json
67+
68+
# Extract version information
69+
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 "")
70+
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 "")
71+
72+
# Extract release notes (everything after "Release note for version")
73+
RELEASE_NOTES=$(echo "$OUTPUT" | sed -n '/Release note for version/,$p' | tail -n +2 || echo "")
74+
75+
# Save to outputs
76+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
77+
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
78+
79+
# Save release notes for comment
80+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
81+
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
82+
echo "EOF" >> $GITHUB_OUTPUT
83+
84+
- name: Display Preview
85+
run: |
86+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
87+
echo " RELEASE PREVIEW"
88+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
89+
echo ""
90+
if [ -n "${{ steps.semantic.outputs.new_version }}" ]; then
91+
echo "Version: v${{ steps.semantic.outputs.new_version }}"
92+
echo "Release Type: ${{ steps.semantic.outputs.release_type }}"
93+
echo "Status: Release will be published"
94+
else
95+
echo "Status: No release will be published"
96+
echo "Reason: No relevant changes detected"
97+
fi
98+
echo ""
99+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
100+
101+
- name: Comment on PR
102+
if: github.event_name == 'pull_request'
103+
uses: actions/github-script@v7
104+
with:
105+
script: |
106+
const newVersion = '${{ steps.semantic.outputs.new_version }}';
107+
const releaseType = '${{ steps.semantic.outputs.release_type }}';
108+
109+
const releaseNotes = `${{ steps.semantic.outputs.release_notes }}`;
110+
111+
let body;
112+
if (newVersion) {
113+
body = `## Release Preview
114+
115+
**Version:** \`v${newVersion}\`
116+
**Release Type:** \`${releaseType}\`
117+
**Status:** Release will be published when merged to main
118+
119+
---
120+
121+
### Release Notes
122+
123+
${releaseNotes}
124+
125+
---
126+
127+
*This preview is generated by semantic-release dry-run mode*`;
128+
}
129+
else {
130+
body = `## Release Preview
131+
132+
**Status:** No release will be published
133+
**Reason:** No relevant changes detected
134+
135+
---
136+
137+
<details>
138+
<summary> View full semantic-release log</summary>
139+
140+
\`\`\`
141+
${{ steps.semantic.outputs.full_output }}
142+
\`\`\`
143+
</details>
144+
145+
---
146+
147+
*This preview is generated by semantic-release dry-run mode*`;
148+
}
149+
150+
// Find existing comment
151+
const { data: comments } = await github.rest.issues.listComments({
152+
owner: context.repo.owner,
153+
repo: context.repo.repo,
154+
issue_number: context.issue.number,
155+
});
156+
157+
const botComment = comments.find(comment =>
158+
comment.user.type === 'Bot' &&
159+
comment.body.includes('Release Preview')
160+
);
161+
162+
// Update or create comment
163+
if (botComment) {
164+
await github.rest.issues.updateComment({
165+
owner: context.repo.owner,
166+
repo: context.repo.repo,
167+
comment_id: botComment.id,
168+
body: body
169+
});
170+
} else {
171+
await github.rest.issues.createComment({
172+
owner: context.repo.owner,
173+
repo: context.repo.repo,
174+
issue_number: context.issue.number,
175+
body: body
176+
});
177+
}

.github/workflows/terraform.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ on:
1515
- main
1616
- master
1717
jobs:
18+
prTitlecheck:
19+
name: PR title check
20+
uses: ./.github/workflows/pr-title.yaml
21+
22+
releasePreview:
23+
name: Release Preview
24+
uses: ./.github/workflows/release-preview.yaml
25+
permissions:
26+
contents: write
27+
pull-requests: write
28+
1829
preCommitCheck:
1930
name: Terraform Checks
2031
uses: ./.github/workflows/terraform-checks.yaml

.preview-releaserc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"branches": ["BRANCH_PLACEHOLDER"],
3+
"debug": true,
4+
"ci": false,
5+
"dryRun": true,
6+
"plugins": [
7+
"@semantic-release/commit-analyzer",
8+
"@semantic-release/release-notes-generator",
9+
"@semantic-release/github"
10+
]
11+
}

0 commit comments

Comments
 (0)