1+ #! /bin/bash
2+
3+ # Release script for QR Code Scanner
4+ # Usage: ./scripts/release.sh <version>
5+ # Example: ./scripts/release.sh v1.0.0-alpha-06
6+
7+ set -e
8+
9+ if [ $# -eq 0 ]; then
10+ echo " Usage: $0 <version>"
11+ echo " Example: $0 v1.0.0-alpha-06"
12+ exit 1
13+ fi
14+
15+ VERSION=$1
16+
17+ # Validate version format
18+ if [[ ! $VERSION =~ ^v[0-9]+\. [0-9]+\. [0-9]+.* $ ]]; then
19+ echo " Error: Version must start with 'v' and follow semantic versioning (e.g., v1.0.0-alpha-06)"
20+ exit 1
21+ fi
22+
23+ echo " Creating release for version: $VERSION "
24+
25+ # Check if tag already exists
26+ if git rev-parse " $VERSION " > /dev/null 2>&1 ; then
27+ echo " Error: Tag $VERSION already exists"
28+ exit 1
29+ fi
30+
31+ # Get current branch
32+ CURRENT_BRANCH=$( git branch --show-current)
33+ echo " Current branch: $CURRENT_BRANCH "
34+
35+ # Ensure we're on main/master branch
36+ if [[ " $CURRENT_BRANCH " != " main" && " $CURRENT_BRANCH " != " master" ]]; then
37+ echo " Warning: You're not on main/master branch. Continue? (y/N)"
38+ read -n 1 -r
39+ echo
40+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
41+ echo " Aborted"
42+ exit 1
43+ fi
44+ fi
45+
46+ # Ensure working directory is clean
47+ if ! git diff-index --quiet HEAD --; then
48+ echo " Error: Working directory is not clean. Please commit your changes first."
49+ exit 1
50+ fi
51+
52+ # Update version in build.gradle.kts if needed
53+ echo " Current version in build.gradle.kts:"
54+ grep ' versionName' app/build.gradle.kts || echo " Version not found"
55+
56+ echo " Do you want to update the version in build.gradle.kts? (y/N)"
57+ read -n 1 -r
58+ echo
59+ if [[ $REPLY =~ ^[Yy]$ ]]; then
60+ # Extract version without 'v' prefix
61+ VERSION_NUMBER=${VERSION# v}
62+ sed -i.bak " s/versionName = \" .*\" /versionName = \" $VERSION_NUMBER \" /" app/build.gradle.kts
63+ echo " Updated versionName to $VERSION_NUMBER "
64+
65+ # Commit version update
66+ git add app/build.gradle.kts
67+ git commit -m " Bump version to $VERSION_NUMBER "
68+ fi
69+
70+ # Create and push tag
71+ echo " Creating tag: $VERSION "
72+ git tag -a " $VERSION " -m " Release $VERSION "
73+
74+ echo " Pushing tag to origin..."
75+ git push origin " $VERSION "
76+
77+ echo " ✅ Tag $VERSION has been pushed!"
78+ echo " 🚀 GitHub Actions will now build the APK automatically."
79+ echo " 📱 You can find the APK in the releases page once the build completes."
80+ echo " 🔗 https://github.com/$( git config --get remote.origin.url | sed ' s/.*github.com[:/]\(.*\)\.git/\1/' ) /releases"
0 commit comments