Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# GitHub Actions Workflows

This directory contains GitHub Actions workflows for continuous integration and deployment.

## Active Workflows

### Android Build (`android-build.yml`)

Automatically builds and tests the Android library on pull requests.

**Triggers:**
- Pull request opened, synchronized, or reopened
- Only runs when relevant files change (android/, src/, package.json)

**What it does:**
1. Sets up Java 17 and Node.js 18
2. Installs npm dependencies
3. Validates Gradle wrapper
4. Builds the Android library using Gradle
5. Uploads build reports on failure

### iOS Build (`ios-build.yml`)

Automatically builds and tests the iOS library on pull requests.

**Triggers:**
- Pull request opened, synchronized, or reopened
- Only runs when relevant files change (ios/, src/, package.json, podspec)

**What it does:**
1. Sets up Node.js 18 and Ruby 3.0
2. Installs npm dependencies
3. Installs CocoaPods
4. Validates the podspec
5. Builds the iOS library using xcodebuild
6. Uploads build logs on failure

### Other Workflows

#### Test and Build (`test-and-build.yml`)

Manual workflow for comprehensive testing across all environments.

**Triggers:**
- Manual dispatch only (`workflow_dispatch`)

**What it does:**
1. Runs JavaScript tests
2. Builds the TypeScript library
3. Builds Android with Gradle
4. Sets up iOS environment (build steps incomplete)

#### Documentation and Release

- `publish-documentation.yml` - Publishes documentation to GitHub Pages
- `release-and-publish-npm.yml` - Handles releases and npm publishing

## Running Workflows Locally

### Android Build

```bash
cd android
./gradlew build
```

### iOS Build

```bash
cd ios
xcodebuild clean build \
-project RNBluetoothClassic.xcodeproj \
-scheme RNBluetoothClassic \
-sdk iphonesimulator \
-configuration Release
```

### JavaScript/TypeScript

```bash
npm ci
npm run test
npm run build
```

## Notes

- The Android and iOS workflows use path filters to only run when relevant code changes
- Build artifacts and logs are uploaded on failure for debugging
- The workflows use the latest stable versions of actions and tools
50 changes: 50 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Android Build

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'android/**'
- 'src/**'
- 'package.json'
- '.github/workflows/android-build.yml'

jobs:
build-android:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2

- name: Build Android library
working-directory: android
run: ./gradlew build --no-daemon --stacktrace

- name: Upload build artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: android-build-reports
path: android/build/reports/
retention-days: 7
65 changes: 65 additions & 0 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: iOS Build

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'ios/**'
- 'src/**'
- 'package.json'
- 'react-native-bluetooth-classic.podspec'
- '.github/workflows/ios-build.yml'

jobs:
build-ios:
runs-on: macos-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: false

- name: Install CocoaPods
run: |
gem install cocoapods
pod --version

- name: Validate Podspec
run: pod lib lint react-native-bluetooth-classic.podspec --allow-warnings --skip-import-validation

- name: Build iOS library
run: |
cd ios
xcodebuild clean build \
-project RNBluetoothClassic.xcodeproj \
-scheme RNBluetoothClassic \
-sdk iphonesimulator \
-configuration Release \
-destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO

- name: Upload build logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: ios-build-logs
path: ~/Library/Logs/xcodebuild/
retention-days: 7
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ Feel free to contribute any changes or bug fixes you see fit. Although when doi
- Changes should be customizable where possible (especially when possibly breaking to others)
- Changes should be documented

### Continuous Integration

The project uses GitHub Actions for continuous integration. When you open a pull request:

- **Android Build**: Automatically compiles the Android library to ensure your changes don't break the build
- **iOS Build**: Automatically compiles the iOS library to ensure your changes don't break the build

These workflows run automatically when you modify relevant files (android/, ios/, or src/ directories). See [.github/workflows/README.md](.github/workflows/README.md) for more details.

#### Android

When first building the Android project there were issues with react-native-create-library and the version of Android/Gradle installed on my machine. This needed to be resolved by ensuring that the project was inline with the version of Android Studio and the Android plugin for gradle. In my case, the project was configured with 1.3.1 and 2.2, which caused problems, in order to resolve [Android plugin for gradle versions](https://developer.android.com/studio/releases/gradle-plugin.html)
Expand Down
Loading