name: Bump Feature Version and Build Release on: workflow_dispatch: jobs: bump-feature-version-and-build: runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Git user run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" # Ensure gradlew is executable (for fresh clones) - name: Ensure gradlew is executable run: chmod +x ./gradlew - name: Bump MINOR version in build.gradle (features update) working-directory: presentation run: | # Extract current versionName and versionCode VERSION_LINE=$(grep "versionName" build.gradle) VERSION_NAME=$(echo "$VERSION_LINE" | sed -n "s/.*versionName[ ]*['\"]\([^'\"]*\)['\"].*/\1/p") VERSION_CODE=$(grep "versionCode" build.gradle | awk '{print $2}') # Error handling for version parsing if [[ ! "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Error: versionName is not in MAJOR.MINOR.PATCH format: $VERSION_NAME" exit 1 fi if ! [[ "$VERSION_CODE" =~ ^[0-9]+$ ]]; then echo "Error: versionCode is not an integer: $VERSION_CODE" exit 1 fi # Split versionName into major, minor, patch IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NAME" # Bump minor version, reset patch to 0 MINOR=$((MINOR + 1)) PATCH=0 NEW_VERSION_NAME="$MAJOR.$MINOR.$PATCH" NEW_VERSION_CODE=$((VERSION_CODE + 1)) # Update build.gradle in-place sed -i "s/versionName.*/versionName '$NEW_VERSION_NAME'/" build.gradle sed -i "s/versionCode.*/versionCode $NEW_VERSION_CODE/" build.gradle echo "Bumped version to $NEW_VERSION_NAME ($NEW_VERSION_CODE)" - name: Commit version bump and push branch working-directory: presentation run: | BRANCH="bump-feature-version-$(date +'%Y%m%d-%H%M%S')" git checkout -b "$BRANCH" git add build.gradle git commit -m "chore: bump feature version [skip ci]" || echo "No changes to commit" git push origin "$BRANCH" echo "Pushed to branch $BRANCH. Please open a pull request to merge into master." - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: commit-message: "chore: bump feature version [skip ci]" branch: bump-feature-version title: "chore: bump feature version [skip ci]" body: "Automated version bump." base: master path: presentation/build.gradle - name: Decode Keystore File run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > ${{ github.workspace }}/my-release-key.keystore - name: Build Release working-directory: presentation run: | ../gradlew assembleRelease \ -Pandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore \ -Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \ -Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \ -Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }} # Find and upload APK artifacts for easy download - name: Upload APK as artifact if: always() uses: actions/upload-artifact@v4 with: name: release-apk path: | presentation/build/outputs/apk/release/*.apk presentation/app/build/outputs/apk/release/*.apk # Adjust/add paths if your APKs are elsewhere # Optional: Show APK files found (for debugging) - name: List built APKs working-directory: presentation run: | echo "APK files in build/outputs/apk/release:" ls -lh build/outputs/apk/release || echo "No APKs found" echo "APK files in app/build/outputs/apk/release:" ls -lh app/build/outputs/apk/release || echo "No APKs found" # Documentation for maintainers - name: Workflow summary run: | echo "This workflow:" echo "- Bumps the MINOR version and resets PATCH in presentation/build.gradle" echo "- Commits and pushes the version update" echo "- Builds the release APK" echo "- Uploads the APK as a downloadable artifact"