Skip to content

Add GitHub Actions CI/CD for automated APK building and release attachment#2

Merged
dantech0xff merged 4 commits into
mainfrom
copilot/fix-161b9bf0-872f-44f6-b45c-15a500dcfdc2
Sep 2, 2025
Merged

Add GitHub Actions CI/CD for automated APK building and release attachment#2
dantech0xff merged 4 commits into
mainfrom
copilot/fix-161b9bf0-872f-44f6-b45c-15a500dcfdc2

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 2, 2025

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)

  • Triggers: Automatically runs when GitHub releases are published or version tags (v*) are pushed
  • Environment: Ubuntu with Java 17, Android SDK, and Gradle caching for optimal build performance
  • Output: Builds release APK and automatically attaches it to the GitHub release
  • Naming: Smart APK naming as qr-code-scanner-{version}.apk with version extracted from git tags or build.gradle.kts

🔧 Build Validation Workflow (.github/workflows/build.yml)

  • Triggers: Runs on pull requests and pushes to main/master branches
  • Purpose: Validates that code changes don't break the build and runs tests
  • Artifact: Uploads debug APK for testing purposes

📜 Release Automation Script (scripts/release.sh)

Streamlines the release process with a single command:

./scripts/release.sh v1.0.0-alpha-06

The script handles:

  • Version format validation
  • Repository state checks (clean working directory, correct branch)
  • Optional version bumping in build.gradle.kts
  • Git tag creation and pushing
  • Helpful progress feedback and links

📚 Documentation (.github/CICD.md)

Complete guide covering:

  • How to create releases (automated script vs manual process)
  • Workflow triggers and outputs
  • APK naming conventions
  • Build environment details

🎯 Enhanced User Experience

  • README updates: Added build status badge and download instructions
  • Direct downloads: Users can now easily download APKs from the GitHub releases page
  • Automated versioning: Consistent version management across git tags and build files

How It Works

  1. Create a release: Use the automation script or manually create a git tag
  2. Automatic building: GitHub Actions detects the release/tag and builds the APK
  3. Asset attachment: The built APK is automatically attached to the GitHub release
  4. User download: Users download the APK directly from the releases page

Benefits

  • Zero manual APK building: Eliminates the need to build and upload APKs manually
  • Consistent releases: Automated process ensures reliable, repeatable releases
  • Better user experience: Users get immediate access to downloadable APKs
  • Quality assurance: Build validation on every PR prevents broken releases
  • Developer productivity: Simple one-command release process

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
    • Triggering command: /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.

Copilot AI and others added 3 commits September 2, 2025 05:19
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>
Copilot AI changed the title [WIP] build the apk and attach to release Add GitHub Actions CI/CD for automated APK building and release attachment Sep 2, 2025
Copilot AI requested a review from dantech0xff September 2, 2025 05:24
@dantech0xff dantech0xff marked this pull request as ready for review September 2, 2025 14:32
Copilot AI review requested due to automatic review settings September 2, 2025 14:32
@dantech0xff dantech0xff merged commit ab56ca1 into main Sep 2, 2025
2 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +59 to +63
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(grep 'versionName' app/build.gradle.kts | sed 's/.*"\(.*\)".*/\1/')
fi
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable GITHUB_REF should be referenced as ${{ github.ref }} instead of $GITHUB_REF for consistency with the condition on line 59.

Copilot uses AI. Check for mistakes.
Comment thread scripts/release.sh
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
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
sed -i.bak "s/versionName = \".*\"/versionName = \"$VERSION_NUMBER\"/" app/build.gradle.kts
sed -i "" "s/versionName = \".*\"/versionName = \"$VERSION_NUMBER\"/" app/build.gradle.kts

Copilot uses AI. Check for mistakes.
Comment thread scripts/release.sh
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
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants