Skip to content

Commit 4a6d5da

Browse files
committed
feat: version check
1 parent 9da982b commit 4a6d5da

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ jobs:
1212
contents: write
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
fetch-depth: 0
18+
19+
- name: Validate version matches tag
20+
run: |
21+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
22+
GRADLE_VERSION=$(grep -oP 'versionName\s*=\s*"\K[^"]+' app/build.gradle.kts)
23+
if [ "$TAG_VERSION" != "$GRADLE_VERSION" ]; then
24+
echo "❌ Version mismatch!"
25+
echo " Tag version: $TAG_VERSION"
26+
echo " Gradle version: $GRADLE_VERSION"
27+
exit 1
28+
fi
29+
echo "✅ Version matched: $TAG_VERSION"
1530
1631
- name: Set up JDK 17
1732
uses: actions/setup-java@v4
@@ -64,3 +79,31 @@ jobs:
6479
generate_release_notes: true
6580
env:
6681
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Bump to next snapshot version
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
run: |
87+
# Parse current version
88+
CURRENT_VERSION=$(grep -oP 'versionName\s*=\s*"\K[^"]+' app/build.gradle.kts)
89+
CURRENT_CODE=$(grep -oP 'versionCode\s*=\s*\K[0-9]+' app/build.gradle.kts)
90+
91+
# Calculate next patch version
92+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
93+
NEXT_PATCH=$((VERSION_PARTS[2] + 1))
94+
NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT"
95+
NEXT_CODE=$((CURRENT_CODE + 1))
96+
97+
echo "Current version: $CURRENT_VERSION (code: $CURRENT_CODE)"
98+
echo "Next version: $NEXT_VERSION (code: $NEXT_CODE)"
99+
100+
# Update build.gradle.kts
101+
sed -i "s/versionName = \"$CURRENT_VERSION\"/versionName = \"$NEXT_VERSION\"/" app/build.gradle.kts
102+
sed -i "s/versionCode = $CURRENT_CODE/versionCode = $NEXT_CODE/" app/build.gradle.kts
103+
104+
# Commit and push
105+
git config user.name "github-actions[bot]"
106+
git config user.email "github-actions[bot]@users.noreply.github.com"
107+
git add app/build.gradle.kts
108+
git commit -m "Bump version to $NEXT_VERSION for next development cycle"
109+
git push origin HEAD:main

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525
minSdk = 33
2626
targetSdk = 36
2727
versionCode = 28
28-
versionName = "0.56.0"
28+
versionName = "0.60.4"
2929

3030
testInstrumentationRunner = "local.oss.chronicle.application.ChronicleTestRunner"
3131
}

0 commit comments

Comments
 (0)