Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/validate-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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"