Skip to content

Commit d7435dc

Browse files
rahul-infrarahul-infra
andauthored
feat!: Add release preview workflow with breaking ACM provider changes (#30)
* 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. * ci: Updated node version and used github action to display preview output * ci: removed unused preview-release file * ci: removed unwanted debug. --------- Co-authored-by: rahul-infra <rahul.sayam@infraspec.dev>
1 parent 5b078d7 commit d7435dc

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-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: 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: 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

0 commit comments

Comments
 (0)