Skip to content
Merged

Fixes #111

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
4 changes: 2 additions & 2 deletions .github/workflows/prep-plugin-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ on:
default: true

env:
GITHUB_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
GH_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}

jobs:
centralized-plugin-releases:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
"${{ github.event.inputs.android_version }}" \
$PLUGIN_ARGS
env:
GITHUB_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
GH_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

- name: Display release summary
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/prep-proxy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

env:
BUNDLE_PATH: vendor/bundle
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
prepare-release:
Expand All @@ -16,10 +16,7 @@ jobs:

- name: Detect SDK versions
id: detect
run: |
./scripts/detect_sdk_versions.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/detect_sdk_versions.sh

- name: Display version summary
run: |
Expand All @@ -40,8 +37,7 @@ jobs:
EOF

- name: Prepare release
run: |
./scripts/prep_proxy_release.sh
run: ./scripts/prep_proxy_release.sh

- name: Create Pull Request
id: cpr
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ AirshipConfig.plist
docs/

# Typescript
lib/
/lib/

# Yarn
yarn-error.log
Expand Down
2 changes: 1 addition & 1 deletion AirshipFrameworkProxy.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Pod::Spec.new do |s|
s.version = "15.0.1"
s.version = "15.0.2"
s.name = "AirshipFrameworkProxy"
s.summary = "Airship iOS mobile framework proxy"
s.documentation_url = "https://docs.airship.com/platform/mobile"
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]

# Airship
airshipProxy = '15.0.1'
airship = '20.0.4'
airshipProxy = '15.0.2'
airship = '20.0.6'

# Gradle plugins
androidGradlePlugin = '8.13.1'
Expand Down
44 changes: 13 additions & 31 deletions scripts/detect_sdk_versions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

# Detect SDK versions and calculate proxy version bump
Expand All @@ -7,6 +7,9 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

# Source shared utilities
source "$SCRIPT_DIR/lib/version_utils.sh"

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
Expand Down Expand Up @@ -36,45 +39,24 @@ echo -e "Current iOS SDK: ${BOLD}$CURRENT_IOS_VERSION${NC}"
CURRENT_ANDROID_VERSION=$(grep "airship =" "$REPO_ROOT/android/gradle/libs.versions.toml" | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
echo -e "Current Android SDK: ${BOLD}$CURRENT_ANDROID_VERSION${NC}"

echo -e "\n${BLUE}Fetching latest SDK tags...${NC}"
echo -e "\n${BLUE}Fetching latest SDK versions...${NC}"

# Fetch latest iOS SDK tag
LATEST_IOS_VERSION=$(gh api repos/urbanairship/ios-library/tags --jq '.[0].name' 2>/dev/null || echo "")
LATEST_IOS_VERSION="${LATEST_IOS_VERSION#v}" # Strip 'v' prefix if present
if [ -z "$LATEST_IOS_VERSION" ]; then
echo -e "${RED}Failed to fetch iOS SDK tags${NC}"
# Fetch latest iOS SDK version
LATEST_IOS_VERSION=$(get_latest_release_version "urbanairship/ios-library")
if [ $? -ne 0 ] || [ -z "$LATEST_IOS_VERSION" ]; then
echo -e "${RED}Failed to fetch iOS SDK version${NC}"
exit 1
fi
echo -e "Latest iOS SDK: ${BOLD}$LATEST_IOS_VERSION${NC}"

# Fetch latest Android SDK tag
LATEST_ANDROID_VERSION=$(gh api repos/urbanairship/android-library/tags --jq '.[0].name' 2>/dev/null || echo "")
LATEST_ANDROID_VERSION="${LATEST_ANDROID_VERSION#v}" # Strip 'v' prefix if present
if [ -z "$LATEST_ANDROID_VERSION" ]; then
echo -e "${RED}Failed to fetch Android SDK tags${NC}"
# Fetch latest Android SDK version
LATEST_ANDROID_VERSION=$(get_latest_release_version "urbanairship/android-library")
if [ $? -ne 0 ] || [ -z "$LATEST_ANDROID_VERSION" ]; then
echo -e "${RED}Failed to fetch Android SDK version${NC}"
exit 1
fi
echo -e "Latest Android SDK: ${BOLD}$LATEST_ANDROID_VERSION${NC}"

# Function to determine bump type (major, minor, patch)
determine_bump_type() {
local old=$1
local new=$2

IFS='.' read -r old_major old_minor old_patch <<< "$old"
IFS='.' read -r new_major new_minor new_patch <<< "$new"

if [ "$new_major" -gt "$old_major" ]; then
echo "major"
elif [ "$new_minor" -gt "$old_minor" ]; then
echo "minor"
elif [ "$new_patch" -gt "$old_patch" ]; then
echo "patch"
else
echo "none"
fi
}

# Determine bump types for each SDK
IOS_BUMP=$(determine_bump_type "$CURRENT_IOS_VERSION" "$LATEST_IOS_VERSION")
ANDROID_BUMP=$(determine_bump_type "$CURRENT_ANDROID_VERSION" "$LATEST_ANDROID_VERSION")
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/changelog_prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ IMPORTANT INSTRUCTIONS:
2. Decide SIMPLE or DETAILED based on criteria above
3. Return ONLY the formatted changelog (no explanations, no preamble)
4. If unsure or SDK changelogs lack substance, use SIMPLE
5. Ensure all version numbers in links match exactly (no 'v' prefix in URLs)
5. Do not include 'v' prefix in version numbers within URLs
6. Use release type: "Major" for X.0.0, "Minor" for X.Y.0, "Patch" for X.Y.Z
16 changes: 10 additions & 6 deletions scripts/lib/generate_changelog.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash
# Intelligent changelog generation using Gemini CLI
# Fetches SDK changelogs, analyzes them, and generates appropriate format

# Get script directory
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROMPT_TEMPLATE="$LIB_DIR/changelog_prompt.txt"

# Source shared utilities
source "$LIB_DIR/version_utils.sh"

# Fetch SDK changelog from GitHub release notes
fetch_github_changelog() {
local repo="$1"
Expand Down Expand Up @@ -131,7 +134,7 @@ validate_and_fix() {

# 1. Fix version format (remove 'v' prefix if present)
if echo "$changelog_content" | grep -q "Version v[0-9]"; then
sed -i '' 's/Version v\([0-9]\)/Version \1/g' "$changelog_file"
sedi 's/Version v\([0-9]\)/Version \1/g' "$changelog_file"
echo " ✓ Fixed version format (removed 'v' prefix)" >&2
fixes_made=true
fi
Expand All @@ -145,14 +148,14 @@ validate_and_fix() {
# 3. Fix malformed GitHub links
if echo "$changelog_content" | grep -q "github.com/urbanairship/.*releases/tag/[^)]*[^0-9.)]"; then
# Remove any trailing characters after version number in links
sed -i '' -E 's|(https://github.com/urbanairship/[^/]+/releases/tag/[0-9.]+)[^)]*|\1|g' "$changelog_file"
sedi -E 's|(https://github.com/urbanairship/[^/]+/releases/tag/[0-9.]+)[^)]*|\1|g' "$changelog_file"
echo " ✓ Fixed malformed GitHub release links" >&2
fixes_made=true
fi

# 4. Remove trailing whitespace
if grep -q "[[:space:]]$" "$changelog_file"; then
sed -i '' 's/[[:space:]]*$//' "$changelog_file"
sedi 's/[[:space:]]*$//' "$changelog_file"
echo " ✓ Removed trailing whitespace" >&2
fixes_made=true
fi
Expand Down Expand Up @@ -254,10 +257,11 @@ validate_pr() {
local pr_title=$(echo "$pr_data" | jq -r '.title')
local pr_body=$(echo "$pr_data" | jq -r '.body')

# Expected title format: "Release X.Y.Z"
# Expected title format: "Release X.Y.Z" or "[TEST] Release X.Y.Z"
local expected_title="Release ${plugin_version}"
local expected_test_title="[TEST] Release ${plugin_version}"

if [ "$pr_title" != "$expected_title" ]; then
if [ "$pr_title" != "$expected_title" ] && [ "$pr_title" != "$expected_test_title" ]; then
echo " ⚠️ WARNING: PR title is '$pr_title', expected '$expected_title'" >&2
fi

Expand Down
70 changes: 70 additions & 0 deletions scripts/lib/version_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# Shared utilities for version management scripts

# Portable sed -i (macOS vs GNU)
sedi() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}

# Determine bump type (major, minor, patch)
determine_bump_type() {
local old=$1
local new=$2

IFS='.' read -r old_major old_minor old_patch <<< "$old"
IFS='.' read -r new_major new_minor new_patch <<< "$new"

if [ "$new_major" -gt "$old_major" ]; then
echo "major"
elif [ "$new_minor" -gt "$old_minor" ]; then
echo "minor"
elif [ "$new_patch" -gt "$old_patch" ]; then
echo "patch"
else
echo "none"
fi
}

# Get highest semver version from a GitHub repo
# Uses releases API (preferred), falls back to tags
# Filters for valid semver, strips 'v' prefix, sorts semantically
get_latest_release_version() {
local repo="$1"
local error_file=$(mktemp)
local versions

# Try releases API first (preferred - explicitly published versions)
versions=$(gh api "repos/${repo}/releases" --paginate --jq '.[].tag_name' 2>"$error_file")

# Fallback to tags if no releases found
if [ -z "$versions" ]; then
versions=$(gh api "repos/${repo}/tags" --paginate --jq '.[].name' 2>"$error_file")
fi

# Check for API errors
if [ -z "$versions" ] && [ -s "$error_file" ]; then
echo " API error: $(cat "$error_file")" >&2
rm -f "$error_file"
return 1
fi
rm -f "$error_file"

# Filter to valid semver, strip 'v' prefix, sort semantically, get highest
local result=$(echo "$versions" | \
grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | \
sed 's/^v//' | \
sort -t. -k1,1n -k2,2n -k3,3n | \
tail -1)

# Validate result is a proper version
if ! [[ "$result" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo " No valid semver releases found" >&2
return 1
fi

echo "$result"
}
15 changes: 9 additions & 6 deletions scripts/prep_proxy_release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

# Prepare proxy release: update versions, dependencies, changelog
Expand All @@ -7,6 +7,9 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

# Source shared utilities
source "$SCRIPT_DIR/lib/version_utils.sh"

# Parse arguments
TEST_MODE=false
if [ "$1" = "--test" ]; then
Expand Down Expand Up @@ -44,8 +47,8 @@ echo -e "${BLUE}Updating files...${NC}"

# Update AirshipFrameworkProxy.podspec
if [ "$TEST_MODE" = "false" ]; then
sed -i '' "s/s.version[[:space:]]*=[[:space:]]*\"[0-9]*\.[0-9]*\.[0-9]*\"/s.version = \"${PROXY_VERSION}\"/" "$REPO_ROOT/AirshipFrameworkProxy.podspec"
sed -i '' "s/s.dependency[[:space:]]*'Airship',[[:space:]]*\"[0-9]*\.[0-9]*\.[0-9]*\"/s.dependency 'Airship', \"${IOS_VERSION}\"/" "$REPO_ROOT/AirshipFrameworkProxy.podspec"
sedi "s/s.version[[:space:]]*=[[:space:]]*\"[0-9]*\.[0-9]*\.[0-9]*\"/s.version = \"${PROXY_VERSION}\"/" "$REPO_ROOT/AirshipFrameworkProxy.podspec"
sedi "s/s.dependency[[:space:]]*'Airship',[[:space:]]*\"[0-9]*\.[0-9]*\.[0-9]*\"/s.dependency 'Airship', \"${IOS_VERSION}\"/" "$REPO_ROOT/AirshipFrameworkProxy.podspec"
echo "✓ Updated AirshipFrameworkProxy.podspec"
else
echo " Would update AirshipFrameworkProxy.podspec:"
Expand All @@ -55,7 +58,7 @@ fi

# Update Package.swift
if [ "$TEST_MODE" = "false" ]; then
sed -i '' "s/from: \"[0-9]*\.[0-9]*\.[0-9]*\"/from: \"${IOS_VERSION}\"/" "$REPO_ROOT/Package.swift"
sedi "s/from: \"[0-9]*\.[0-9]*\.[0-9]*\"/from: \"${IOS_VERSION}\"/" "$REPO_ROOT/Package.swift"
echo "✓ Updated Package.swift"
else
echo " Would update Package.swift:"
Expand All @@ -64,8 +67,8 @@ fi

# Update android/gradle/libs.versions.toml
if [ "$TEST_MODE" = "false" ]; then
sed -i '' "s/airshipProxy = '[0-9]*\.[0-9]*\.[0-9]*'/airshipProxy = '${PROXY_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
sed -i '' "s/airship = '[0-9]*\.[0-9]*\.[0-9]*'/airship = '${ANDROID_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
sedi "s/airshipProxy = '[0-9]*\.[0-9]*\.[0-9]*'/airshipProxy = '${PROXY_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
sedi "s/airship = '[0-9]*\.[0-9]*\.[0-9]*'/airship = '${ANDROID_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
echo "✓ Updated android/gradle/libs.versions.toml"
else
echo " Would update android/gradle/libs.versions.toml:"
Expand Down
Loading
Loading