Skip to content

Commit 93db158

Browse files
committed
🚧 WIP added prepare and validate release automations
1 parent 642b679 commit 93db158

2 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Prepare For Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (e.g., 2.3.0)'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
prepare-release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Setup
24+
uses: ./.github/actions/setup
25+
26+
- name: Validate Version Format
27+
run: |
28+
if ! [[ "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
29+
echo "::error::Invalid version format. Use semantic versioning (e.g., 2.3.0 or 2.3.0-beta1)"
30+
exit 1
31+
fi
32+
33+
- name: Update Changelog
34+
id: update_changelog
35+
run: |
36+
new_version="${{ github.event.inputs.version }}"
37+
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
38+
39+
if grep -qF "## ${new_version}" CHANGELOG.md; then
40+
echo "CHANGELOG.md already has an entry for ${new_version}, skipping."
41+
else
42+
tmp=$(mktemp)
43+
echo "## ${new_version}" > "$tmp"
44+
echo "" >> "$tmp"
45+
cat CHANGELOG.md >> "$tmp"
46+
mv "$tmp" CHANGELOG.md
47+
fi
48+
49+
- name: Update Version
50+
run: npm version "${{ github.event.inputs.version }}" --no-git-tag-version
51+
52+
- name: Build
53+
run: yarn prepare
54+
55+
- name: Create Pull Request
56+
uses: peter-evans/create-pull-request@v5
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
title: "Prepare for Release ${{ steps.update_changelog.outputs.new_version }}"
60+
body: |
61+
# Prepare for Release ${{ steps.update_changelog.outputs.new_version }}
62+
63+
## SDK Release Checklist
64+
- [ ] CHANGELOG.md updated with release notes
65+
- [ ] Version bumped in package.json
66+
- [ ] `yarn prepare` ran successfully (itblBuildInfo.ts updated)
67+
- [ ] All tests passing
68+
- [ ] Documentation updated (if needed)
69+
70+
branch: "prepare-for-release-${{ steps.update_changelog.outputs.new_version }}"
71+
commit-message: "Prepare for release ${{ steps.update_changelog.outputs.new_version }}"
72+
labels: release
73+
delete-branch: true
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Validate Release PR
2+
3+
on:
4+
pull_request:
5+
types: [labeled, opened, synchronize, edited]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
validate:
13+
if: >-
14+
(github.event.action == 'labeled' && github.event.label.name == 'release') ||
15+
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'release'))
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Validate Release PR
21+
env:
22+
PR_BODY: ${{ github.event.pull_request.body }}
23+
run: |
24+
errors=()
25+
26+
# --- Extract version from source of truth ---
27+
version=$(node -p "require('./package.json').version")
28+
if [ -z "$version" ]; then
29+
echo "::error::Could not extract version from package.json"
30+
exit 1
31+
fi
32+
echo "Detected version: $version"
33+
34+
# --- Check: Docs PR linked ---
35+
if ! echo "$PR_BODY" | grep -qiP "github\.com/Iterable/iterable-docs/pull/\d+"; then
36+
errors+=("No docs PR link found in the PR description. Add a link to the iterable-docs PR (e.g. https://github.com/Iterable/iterable-docs/pull/123).")
37+
fi
38+
39+
# --- Check: CHANGELOG entry (RN uses ## X.Y.Z without brackets) ---
40+
if ! grep -qF "## $version" CHANGELOG.md; then
41+
errors+=("CHANGELOG.md is missing an entry for version $version.")
42+
fi
43+
44+
# --- Check: Version consistency ---
45+
build_info_ver=$(grep -oP "version:\s*'\K[^']+" src/itblBuildInfo.ts)
46+
47+
if [ "$build_info_ver" != "$version" ]; then
48+
errors+=("src/itblBuildInfo.ts version is '$build_info_ver', expected '$version'. Did you run 'yarn prepare'?")
49+
fi
50+
51+
# --- Report ---
52+
if [ ${#errors[@]} -gt 0 ]; then
53+
echo "::error::Release validation failed with ${#errors[@]} issue(s):"
54+
for err in "${errors[@]}"; do
55+
echo "::error:: - $err"
56+
done
57+
exit 1
58+
fi
59+
60+
echo "All release validations passed for version $version."

0 commit comments

Comments
 (0)