Add GitHub Actions CI/CD for automated APK building and release attachment#2
Conversation
Co-authored-by: dantech0xff <67886170+dantech0xff@users.noreply.github.com>
Co-authored-by: dantech0xff <67886170+dantech0xff@users.noreply.github.com>
Co-authored-by: dantech0xff <67886170+dantech0xff@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive CI/CD pipeline using GitHub Actions to automate APK building and release distribution for the QR Code Scanner app. The implementation eliminates manual APK building and provides users with immediate access to downloadable releases.
- Automated APK building triggered by GitHub releases or version tags
- Build validation workflow for pull requests and main branch pushes
- Release automation script to streamline the version management process
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/release.yml |
Main CI/CD workflow that builds release APKs and attaches them to GitHub releases |
.github/workflows/build.yml |
Build validation workflow that runs tests and creates debug APKs for PRs |
scripts/release.sh |
Bash script to automate the release process with version validation and git operations |
.github/CICD.md |
Documentation explaining the CI/CD workflows and release process |
README.md |
Updated with build status badge, CI/CD badge, and download instructions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
| VERSION=${GITHUB_REF#refs/tags/} | ||
| else | ||
| VERSION=$(grep 'versionName' app/build.gradle.kts | sed 's/.*"\(.*\)".*/\1/') | ||
| fi |
There was a problem hiding this comment.
The variable GITHUB_REF should be referenced as ${{ github.ref }} instead of $GITHUB_REF for consistency with the condition on line 59.
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| # Extract version without 'v' prefix | ||
| VERSION_NUMBER=${VERSION#v} | ||
| sed -i.bak "s/versionName = \".*\"/versionName = \"$VERSION_NUMBER\"/" app/build.gradle.kts |
There was a problem hiding this comment.
The sed command creates a backup file (.bak) but doesn't clean it up. Consider removing the backup file after successful execution or using a different approach that doesn't create backup files.
| sed -i.bak "s/versionName = \".*\"/versionName = \"$VERSION_NUMBER\"/" app/build.gradle.kts | |
| sed -i "" "s/versionName = \".*\"/versionName = \"$VERSION_NUMBER\"/" app/build.gradle.kts |
| echo "✅ Tag $VERSION has been pushed!" | ||
| echo "🚀 GitHub Actions will now build the APK automatically." | ||
| echo "📱 You can find the APK in the releases page once the build completes." | ||
| echo "🔗 https://github.com/$(git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/')/releases" No newline at end of file |
There was a problem hiding this comment.
The complex sed expression for extracting the repository path is fragile and may not handle all URL formats correctly. Consider using a more robust approach like gh repo view --json url if GitHub CLI is available, or splitting this into multiple simpler operations.
| echo "🔗 https://github.com/$(git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/')/releases" | |
| # Extract repository path (owner/repo) robustly | |
| if command -v gh >/dev/null 2>&1; then | |
| REPO_PATH=$(gh repo view --json nameWithOwner -q .nameWithOwner) | |
| else | |
| REMOTE_URL=$(git config --get remote.origin.url) | |
| # Remove .git suffix if present | |
| REMOTE_URL=${REMOTE_URL%.git} | |
| # Extract owner/repo from SSH or HTTPS URL | |
| if [[ "$REMOTE_URL" =~ github\.com[:/](.+/.+) ]]; then | |
| REPO_PATH="${BASH_REMATCH[1]}" | |
| else | |
| REPO_PATH="unknown/unknown" | |
| fi | |
| fi | |
| echo "🔗 https://github.com/$REPO_PATH/releases" |
This PR implements a complete CI/CD pipeline for automatically building and distributing APK releases of the QR Code Scanner app.
What's Added
🚀 Release Automation Workflow (
.github/workflows/release.yml)v*) are pushedqr-code-scanner-{version}.apkwith version extracted from git tags or build.gradle.kts🔧 Build Validation Workflow (
.github/workflows/build.yml)📜 Release Automation Script (
scripts/release.sh)Streamlines the release process with a single command:
The script handles:
build.gradle.kts📚 Documentation (
.github/CICD.md)Complete guide covering:
🎯 Enhanced User Experience
How It Works
Benefits
The implementation follows GitHub Actions best practices with proper caching, modern action versions, and comprehensive error handling. This sets up a professional release pipeline that scales with the project's growth.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx4096m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.4-bin/1w5dpkrfk8irigvoxmyhowfim/gradle-8.4/lib/gradle-launcher-8.4.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.4-bin/1w5dpkrfk8irigvoxmyhowfim/gradle-8.4/lib/agents/gradle-instrumentation-agent-8.4.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.4(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.