-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 3.24 KB
/
Copy pathvalidate-release.yml
File metadata and controls
88 lines (74 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Validate Release
on:
push:
branches:
- 'release/*'
jobs:
validate-release:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: main-branch
- name: Extract version from branch name
id: extract-version
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
VERSION="${BRANCH_NAME#release/}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Get current versionCode
id: current-version
run: |
CURRENT_VERSION_CODE=$(sed -nE 's/^[[:space:]]*versionCode[[:space:]]*=[[:space:]]*([0-9]+)[[:space:]]*$/\1/p' app/build.gradle.kts | head -n1)
[[ "$CURRENT_VERSION_CODE" =~ ^[0-9]+$ ]] || { echo "❌ Invalid current versionCode: $CURRENT_VERSION_CODE"; exit 1; }
echo "current_version_code=$CURRENT_VERSION_CODE" >> $GITHUB_OUTPUT
echo "Current versionCode: $CURRENT_VERSION_CODE"
- name: Get main branch versionCode
id: main-version
run: |
MAIN_VERSION_CODE=$(sed -nE 's/^[[:space:]]*versionCode[[:space:]]*=[[:space:]]*([0-9]+)[[:space:]]*$/\1/p' main-branch/app/build.gradle.kts | head -n1)
[[ "$MAIN_VERSION_CODE" =~ ^[0-9]+$ ]] || { echo "❌ Invalid main versionCode: $MAIN_VERSION_CODE"; exit 1; }
echo "main_version_code=$MAIN_VERSION_CODE" >> $GITHUB_OUTPUT
echo "Main branch versionCode: $MAIN_VERSION_CODE"
- name: Compare versionCode
run: |
CURRENT=${{ steps.current-version.outputs.current_version_code }}
MAIN=${{ steps.main-version.outputs.main_version_code }}
echo "Current versionCode: $CURRENT"
echo "Main versionCode: $MAIN"
if (( CURRENT <= MAIN )); then
echo "❌ Error: Current versionCode ($CURRENT) must be greater than main branch versionCode ($MAIN)"
exit 1
else
echo "✅ versionCode validation passed: $CURRENT > $MAIN"
fi
- name: Check release note exists
run: |
VERSION="${{ steps.extract-version.outputs.version }}"
RELEASE_NOTE_PATH="docs/releaseNote/v$VERSION/release.md"
echo "Checking for release note at: $RELEASE_NOTE_PATH"
if [ ! -f "$RELEASE_NOTE_PATH" ]; then
echo "❌ Error: Release note not found at $RELEASE_NOTE_PATH"
echo "Please create a release note for version $VERSION"
exit 1
else
echo "✅ Release note found at $RELEASE_NOTE_PATH"
echo ""
echo "Release note content:"
cat "$RELEASE_NOTE_PATH"
fi
- name: Validation Summary
if: success()
run: |
echo "🎉 All validations passed!"
echo "- Version: ${{ steps.extract-version.outputs.version }}"
echo "- versionCode: ${{ steps.current-version.outputs.current_version_code }} (main: ${{ steps.main-version.outputs.main_version_code }})"
echo "- Release note: ✅ exists"