npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

rn-build-version

v1.2.2

Published

A powerful React Native CLI tool for version management, build automation, and changelog generation for Android and iOS apps.

Readme

rn-build-version

A React Native tool for managing versionCode and versionName in your Android build.gradle file, with support for building APKs and AABs. It simplifies version management by providing interactive prompts and automates backups and changelog updates.

🚀 Features

  • Version Management:
    • Increment patch (e.g., 0.0.10.0.2), minor (e.g., 0.0.10.1.0), or major (e.g., 0.0.11.0.0) versions.
    • Set custom versionCode and versionName.
    • Skip version updates for local testing builds.
  • Automation:
    • Backup build.gradle before modifications.
    • Generate or update a CHANGELOG.md file with version details.
  • Flexibility:
    • Custom Gradle file path support via CLI option.
    • Dry-run mode to simulate changes without applying them.

📌 Prerequisites

  • Ensure your build.gradle contains versionCode and versionName (e.g., in defaultConfig).
  • Configure signing in build.gradle for release builds.

⚠️ Notes

  • The tool assumes a standard React Native Android project structure.
  • Run chmod +x android/gradlew on macOS/Linux if Gradle permissions are an issue.

📦 Installation

Install the package globally or as a development dependency in your React Native project:

# Globally
npm install -g rn-build-version

# As a dev dependency
npm install --save-dev rn-build-version

# Using yarn
yarn add --dev rn-build-version

🔧 Usage

1️⃣ Add Scripts to Your package.json

Integrate the tool into your React Native project by adding these scripts:

{
  "scripts": {
    "build:android:apk": "rn-build-version && cd android && ./gradlew clean assembleRelease",
    "build:android:aab": "rn-build-version && cd android && ./gradlew clean bundleRelease",
    "build:android:apk:fast": "rn-build-version && cd android && ./gradlew assembleRelease",
    "build:android:aab:fast": "rn-build-version && cd android && ./gradlew bundleRelease",
    "build:android:apk:local": "cd android && ./gradlew clean assembleRelease",
    "build:android:aab:local": "cd android && ./gradlew clean bundleRelease",
    "build:android:apk:local:fast": "cd android && ./gradlew assembleRelease",
    "build:android:aab:local:fast": "cd android && ./gradlew bundleRelease"
  }
}

2️⃣ Run the Commands

🚀 Production Builds (with Version Management)

npm run build:android:apk
npm run build:android:aab

yarn build:android:apk
yarn build:android:aab

These commands prompt you to update the version before building.

🛠️ Local Testing Builds (No Version Change)

npm run build:android:apk:local
npm run build:android:aab:local

yarn build:android:apk:local
yarn build:android:aab:local

These skip version prompts and build with the current version.

⚡ Fast Builds (No Clean, for Quicker Iteration)

npm run build:android:apk:fast
npm run build:android:aab:fast
npm run build:android:apk:local:fast
npm run build:android:aab:local:fast

yarn build:android:apk:fast
yarn build:android:aab:fast
yarn build:android:apk:local:fast
yarn build:android:aab:local:fast

📊 When to Use Each Command

| Command | Use Case | |---------|---------| | yarn build:android:apk | Full build with version update and clean (ideal for production APK). | | yarn build:android:aab | Full build with version update and clean (ideal for production AAB). | | yarn build:android:apk:fast | Quick build with version update, no clean (faster for testing APK). | | yarn build:android:aab:fast | Quick build with version update, no clean (faster for testing AAB). | | yarn build:android:apk:local | Local build with clean, no version update (fresh APK for local use). | | yarn build:android:aab:local | Local build with clean, no version update (fresh AAB for local use). | | yarn build:android:apk:local:fast | Fast local build, no clean or version update (quick APK iteration). | | yarn build:android:aab:local:fast | Fast local build, no clean or version update (quick AAB iteration). |

🖥️ CLI Usage

Run the tool directly with options:

rn-build-version [options]

| Option | Description | Default | |--------|-------------|---------| | -g, --gradle <path> | Path to your build.gradle file | android/app/build.gradle | | -d, --dry-run | Simulate changes without applying them | false |

📌 Examples

  • Use a custom Gradle path:
rn-build-version --gradle ./custom/path/build.gradle
  • Simulate changes (dry-run):
rn-build-version --dry-run
  • Combine options:
rn-build-version --gradle ./android/app/build.gradle --dry-run

✨ Example Interaction

When you run rn-build-version or a build script with it, you’ll see:

Current versionCode: 1
Current versionName: 0.0.1
? What do you want to do with the version? (Use arrow keys)
  > Increment patch (e.g., 0.0.1 -> 0.0.2)
    Increment minor (e.g., 0.0.1 -> 0.1.0)
    Increment major (e.g., 0.0.1 -> 1.0.0)
    Set custom version
    Skip (no increment)
  • Choosing "Increment patch":

    • Updates versionCode: 2, versionName: "0.0.2".
    • Creates a backup (build.gradle.bak).
    • Appends to CHANGELOG.md.
  • Choosing "Set custom version":

    • Prompts for new versionName and versionCode.
    • Example: Set versionName: "1.2.3", versionCode: 123.

💡 Enjoy hassle-free versioning in your React Native projects! 🚀


Screenshots


Fixed: Now this will work all type of version naming convension.