From e0c6c357097a329571d00ef965b825605d6348ac Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Mon, 26 Jan 2026 11:13:44 +0100 Subject: [PATCH] feat(dx): Add tools to bump version --- Makefile | 31 +++++++++++++++++++++++ fastlane/Fastfile | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/Makefile b/Makefile index a49d69d..3a6892f 100644 --- a/Makefile +++ b/Makefile @@ -302,6 +302,37 @@ upload-metadata: bundle install bundle exec fastlane upload_metadata +# ============================================================================ +# VERSION MANAGEMENT +# ============================================================================ + +## Bump the major version number (e.g., 1.1.2 -> 2.0.0) +# +# Increments the major version number and resets minor and patch to 0. +# This should be used for breaking changes or major feature releases. +.PHONY: bump-version-major +bump-version-major: + bundle install + bundle exec fastlane bump_version_major + +## Bump the minor version number (e.g., 1.1.2 -> 1.2.0) +# +# Increments the minor version number and resets patch to 0. +# This should be used for new features or significant improvements. +.PHONY: bump-version-minor +bump-version-minor: + bundle install + bundle exec fastlane bump_version_minor + +## Bump the patch version number (e.g., 1.1.2 -> 1.1.3) +# +# Increments the patch version number. +# This should be used for bug fixes and minor updates. +.PHONY: bump-version-patch +bump-version-patch: + bundle install + bundle exec fastlane bump_version_patch + # ============================================================================ # HELP & DOCUMENTATION # ============================================================================ diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 37b9cdb..406d3cf 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -271,12 +271,76 @@ Your feedback helps us improve Flinky for everyone. Thank you!" UI.success "✅ Code signing synced successfully!" end + desc "Bump the major version number (e.g., 1.1.2 -> 2.0.0)" + lane :bump_version_major do + _bump_version(bump_type: "major") + end + + desc "Bump the minor version number (e.g., 1.1.2 -> 1.2.0)" + lane :bump_version_minor do + _bump_version(bump_type: "minor") + end + + desc "Bump the patch version number (e.g., 1.1.2 -> 1.1.3)" + lane :bump_version_patch do + _bump_version(bump_type: "patch") + end + # ============================================================================ # PRIVATE LANES # ============================================================================ # These lanes are internal helpers and are not exposed in `fastlane lanes` # ============================================================================ + # Private lane: Bump version number in project.pbxproj + private_lane :_bump_version do |options| + bump_type = options[:bump_type] # "major", "minor", or "patch" + + # Get current version + old_version = get_version_number( + xcodeproj: "Flinky.xcodeproj", + target: "Flinky" + ) + + # Parse version into components + version_parts = old_version.split(".").map(&:to_i) + major = version_parts[0] || 0 + minor = version_parts[1] || 0 + patch = version_parts[2] || 0 + + # Increment the appropriate part + case bump_type + when "major" + major += 1 + minor = 0 + patch = 0 + when "minor" + minor += 1 + patch = 0 + when "patch" + patch += 1 + else + UI.user_error!("Invalid bump_type: #{bump_type}. Must be 'major', 'minor', or 'patch'") + end + + new_version = "#{major}.#{minor}.#{patch}" + + # Update all MARKETING_VERSION entries in project.pbxproj + project_file = File.expand_path("../Flinky.xcodeproj/project.pbxproj") + project_content = File.read(project_file) + + # Replace all MARKETING_VERSION entries + updated_content = project_content.gsub( + /MARKETING_VERSION = #{Regexp.escape(old_version)};/, + "MARKETING_VERSION = #{new_version};" + ) + + # Write the updated content back + File.write(project_file, updated_content) + + UI.success "✅ Version bumped from #{old_version} to #{new_version}" + end + # Private lane: Setup code signing for App Store Connect private_lane :_setup_code_signing do sync_code_signing(