Skip to content
Merged
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
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
branches:
- main
paths:
- 'V2er/Info.plist'
- 'V2er.xcodeproj/project.pbxproj'
- 'V2er/Config/Version.xcconfig'
workflow_dispatch:
inputs:
force_release:
Expand Down Expand Up @@ -38,9 +37,9 @@ jobs:
- name: Check version and create tag if needed
id: check
run: |
# Get current version from project.pbxproj (works on Linux)
CURRENT_VERSION=$(grep -m1 'MARKETING_VERSION = ' V2er.xcodeproj/project.pbxproj | sed 's/.*MARKETING_VERSION = \(.*\);/\1/' | xargs)
CURRENT_BUILD=$(grep -m1 'CURRENT_PROJECT_VERSION = ' V2er.xcodeproj/project.pbxproj | sed 's/.*CURRENT_PROJECT_VERSION = \(.*\);/\1/' | xargs)
# Get current version from Version.xcconfig (works on Linux)
CURRENT_VERSION=$(grep '^MARKETING_VERSION = ' V2er/Config/Version.xcconfig | sed 's/.*MARKETING_VERSION = //' | xargs)
CURRENT_BUILD=$(grep '^CURRENT_PROJECT_VERSION = ' V2er/Config/Version.xcconfig | sed 's/.*CURRENT_PROJECT_VERSION = //' | xargs)

echo "Current version: $CURRENT_VERSION (build $CURRENT_BUILD)"

Expand Down
14 changes: 12 additions & 2 deletions VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ This project uses two version identifiers:

### How to Update Versions

To update versions, simply edit the file `V2er/Config/Version.xcconfig`:
#### Option 1: Use the Update Script (Recommended)
```bash
# Interactive mode
./scripts/update-version.sh

# Or with arguments
./scripts/update-version.sh 1.1.3 31
```

#### Option 2: Manual Edit
Edit the file `V2er/Config/Version.xcconfig`:

```bash
# Open the file
V2er/Config/Version.xcconfig

# Update these two lines:
MARKETING_VERSION = 1.1.2 # VERSION_NAME (user-facing version)
CURRENT_PROJECT_VERSION = 29 # VERSION_CODE (build number)
CURRENT_PROJECT_VERSION = 30 # VERSION_CODE (build number)
```

**That's it!** No need to edit project.pbxproj or any other files. The xcconfig file is automatically loaded by Xcode and applies to all build configurations.
Expand Down
81 changes: 81 additions & 0 deletions scripts/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# Script to update app version
# Usage: ./scripts/update-version.sh [version] [build]
# Example: ./scripts/update-version.sh 1.1.3 31

CONFIG_FILE="V2er/Config/Version.xcconfig"
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

[nitpick] The config file path is hardcoded. Consider making this configurable through an environment variable or command-line argument to improve flexibility and testability.

Copilot uses AI. Check for mistakes.

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Function to display current version
show_current_version() {
CURRENT_VERSION=$(grep '^MARKETING_VERSION = ' "$CONFIG_FILE" | sed 's/.*MARKETING_VERSION = //' | xargs)
CURRENT_BUILD=$(grep '^CURRENT_PROJECT_VERSION = ' "$CONFIG_FILE" | sed 's/.*CURRENT_PROJECT_VERSION = //' | xargs)
Comment on lines +17 to +18
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The script doesn't validate that the config file exists before trying to read from it. If the file is missing, these commands will fail silently and return empty values, leading to confusing behavior.

Copilot uses AI. Check for mistakes.
echo -e "${YELLOW}Current version: ${NC}$CURRENT_VERSION (build $CURRENT_BUILD)"
}

# Function to update version
update_version() {
local new_version=$1
local new_build=$2

# Update MARKETING_VERSION
sed -i '' "s/^MARKETING_VERSION = .*/MARKETING_VERSION = $new_version/" "$CONFIG_FILE"

# Update CURRENT_PROJECT_VERSION
sed -i '' "s/^CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $new_build/" "$CONFIG_FILE"
Comment on lines +22 to +31
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The sed commands use unescaped variables in regex patterns, which could break if the version contains special regex characters (like dots or brackets). Consider escaping the variables or using a more robust replacement method.

Suggested change
# Function to update version
update_version() {
local new_version=$1
local new_build=$2
# Update MARKETING_VERSION
sed -i '' "s/^MARKETING_VERSION = .*/MARKETING_VERSION = $new_version/" "$CONFIG_FILE"
# Update CURRENT_PROJECT_VERSION
sed -i '' "s/^CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $new_build/" "$CONFIG_FILE"
# Escape replacement string for sed (escapes &, \, and | for use as delimiter)
escape_sed_replacement() {
printf '%s' "$1" | sed -e 's/[&\\/|]/\\&/g'
}
# Function to update version
update_version() {
local new_version=$1
local new_build=$2
# Escape replacement strings
local esc_version
local esc_build
esc_version=$(escape_sed_replacement "$new_version")
esc_build=$(escape_sed_replacement "$new_build")
# Update MARKETING_VERSION
sed -i '' "s|^MARKETING_VERSION = .*|MARKETING_VERSION = $esc_version|" "$CONFIG_FILE"
# Update CURRENT_PROJECT_VERSION
sed -i '' "s|^CURRENT_PROJECT_VERSION = .*|CURRENT_PROJECT_VERSION = $esc_build|" "$CONFIG_FILE"

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +31
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The sed commands use unescaped variables in regex patterns, which could break if the version contains special regex characters (like dots or brackets). Consider escaping the variables or using a more robust replacement method.

Suggested change
# Update MARKETING_VERSION
sed -i '' "s/^MARKETING_VERSION = .*/MARKETING_VERSION = $new_version/" "$CONFIG_FILE"
# Update CURRENT_PROJECT_VERSION
sed -i '' "s/^CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $new_build/" "$CONFIG_FILE"
# Escape replacement strings for sed
local escaped_version
local escaped_build
escaped_version=$(printf '%s' "$new_version" | sed 's/[&/\]/\\&/g')
escaped_build=$(printf '%s' "$new_build" | sed 's/[&/\]/\\&/g')
# Update MARKETING_VERSION
sed -i '' "s/^MARKETING_VERSION = .*/MARKETING_VERSION = $escaped_version/" "$CONFIG_FILE"
# Update CURRENT_PROJECT_VERSION
sed -i '' "s/^CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $escaped_build/" "$CONFIG_FILE"

Copilot uses AI. Check for mistakes.

echo -e "${GREEN}✅ Version updated successfully!${NC}"
}

# Main script
echo -e "${GREEN}=== V2er Version Update Tool ===${NC}\n"

# Show current version
show_current_version

# If no arguments provided, run in interactive mode
if [ $# -eq 0 ]; then
echo ""
read -p "Enter new version (e.g., 1.1.3): " NEW_VERSION
read -p "Enter new build number (e.g., 31): " NEW_BUILD

if [ -z "$NEW_VERSION" ] || [ -z "$NEW_BUILD" ]; then
echo -e "${RED}❌ Error: Version and build number are required${NC}"
exit 1
fi
else
# Use provided arguments
NEW_VERSION=$1
NEW_BUILD=$2

if [ -z "$NEW_VERSION" ] || [ -z "$NEW_BUILD" ]; then
echo -e "${RED}❌ Error: Usage: $0 <version> <build>${NC}"
echo "Example: $0 1.1.3 31"
exit 1
fi
fi

# Confirm update
echo ""
echo -e "${YELLOW}Will update to:${NC} $NEW_VERSION (build $NEW_BUILD)"
read -p "Proceed? (y/n): " -n 1 -r
echo ""

if [[ $REPLY =~ ^[Yy]$ ]]; then
update_version "$NEW_VERSION" "$NEW_BUILD"
echo ""
show_current_version
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Commit the changes: git add -A && git commit -m \"chore: bump version to $NEW_VERSION (build $NEW_BUILD)\""
echo "2. Push to trigger release: git push"
else
echo -e "${RED}❌ Update cancelled${NC}"
exit 1
fi
Loading