Skip to content

Commit 84ff98a

Browse files
Copilotdantech0xff
andcommitted
Add release automation script and enhance documentation
Co-authored-by: dantech0xff <67886170+dantech0xff@users.noreply.github.com>
1 parent a11b8c0 commit 84ff98a

3 files changed

Lines changed: 99 additions & 1 deletion

File tree

.github/CICD.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,24 @@ This repository includes GitHub Actions workflows for automated building and rel
2020

2121
## Creating a Release
2222

23-
To create a new release with an APK:
23+
### Option 1: Using the Release Script (Recommended)
24+
25+
The repository includes a helper script to streamline the release process:
26+
27+
```bash
28+
./scripts/release.sh v1.0.0-alpha-06
29+
```
30+
31+
This script will:
32+
- Validate the version format
33+
- Check if you're on the main/master branch
34+
- Optionally update the version in `app/build.gradle.kts`
35+
- Create and push the git tag
36+
- Provide links to track the build progress
37+
38+
### Option 2: Manual Process
39+
40+
To create a new release manually:
2441

2542
1. **Create and push a tag**:
2643
```bash

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Android QR Code Scanner by Dan Tech
22
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/dantech0xff/compose-barcode-scanner)
3+
[![Build Test](https://github.com/dantech0xff/compose-qr-code-scanner/actions/workflows/build.yml/badge.svg)](https://github.com/dantech0xff/compose-qr-code-scanner/actions/workflows/build.yml)
34
![](https://img.shields.io/badge/Kotlin-Compose-green)
45
![](https://img.shields.io/badge/Google--Billing-blue)
56
![](https://img.shields.io/badge/Camera--X-red)

scripts/release.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

Comments
 (0)