Skip to content

Commit f974f8a

Browse files
authored
Merge pull request #111 from urbanairship/fix-prepare-workflows
Fixes
2 parents 70cf445 + 682ab19 commit f974f8a

12 files changed

+191
-120
lines changed

.github/workflows/prep-plugin-releases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ on:
3434
default: true
3535

3636
env:
37-
GITHUB_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
37+
GH_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
3838

3939
jobs:
4040
centralized-plugin-releases:
@@ -82,7 +82,7 @@ jobs:
8282
"${{ github.event.inputs.android_version }}" \
8383
$PLUGIN_ARGS
8484
env:
85-
GITHUB_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
85+
GH_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
8686
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
8787

8888
- name: Display release summary

.github/workflows/prep-proxy-release.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55

66
env:
7-
BUNDLE_PATH: vendor/bundle
7+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88

99
jobs:
1010
prepare-release:
@@ -16,10 +16,7 @@ jobs:
1616

1717
- name: Detect SDK versions
1818
id: detect
19-
run: |
20-
./scripts/detect_sdk_versions.sh
21-
env:
22-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
run: ./scripts/detect_sdk_versions.sh
2320

2421
- name: Display version summary
2522
run: |
@@ -40,8 +37,7 @@ jobs:
4037
EOF
4138
4239
- name: Prepare release
43-
run: |
44-
./scripts/prep_proxy_release.sh
40+
run: ./scripts/prep_proxy_release.sh
4541

4642
- name: Create Pull Request
4743
id: cpr

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ AirshipConfig.plist
4545
docs/
4646

4747
# Typescript
48-
lib/
48+
/lib/
4949

5050
# Yarn
5151
yarn-error.log

AirshipFrameworkProxy.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Pod::Spec.new do |s|
3-
s.version = "15.0.1"
3+
s.version = "15.0.2"
44
s.name = "AirshipFrameworkProxy"
55
s.summary = "Airship iOS mobile framework proxy"
66
s.documentation_url = "https://docs.airship.com/platform/mobile"

android/gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[versions]
22

33
# Airship
4-
airshipProxy = '15.0.1'
5-
airship = '20.0.4'
4+
airshipProxy = '15.0.2'
5+
airship = '20.0.6'
66

77
# Gradle plugins
88
androidGradlePlugin = '8.13.1'

scripts/detect_sdk_versions.sh

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -e
33

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

10+
# Source shared utilities
11+
source "$SCRIPT_DIR/lib/version_utils.sh"
12+
1013
# Colors for output
1114
RED='\033[0;31m'
1215
GREEN='\033[0;32m'
@@ -36,45 +39,24 @@ echo -e "Current iOS SDK: ${BOLD}$CURRENT_IOS_VERSION${NC}"
3639
CURRENT_ANDROID_VERSION=$(grep "airship =" "$REPO_ROOT/android/gradle/libs.versions.toml" | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
3740
echo -e "Current Android SDK: ${BOLD}$CURRENT_ANDROID_VERSION${NC}"
3841

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

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

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

59-
# Function to determine bump type (major, minor, patch)
60-
determine_bump_type() {
61-
local old=$1
62-
local new=$2
63-
64-
IFS='.' read -r old_major old_minor old_patch <<< "$old"
65-
IFS='.' read -r new_major new_minor new_patch <<< "$new"
66-
67-
if [ "$new_major" -gt "$old_major" ]; then
68-
echo "major"
69-
elif [ "$new_minor" -gt "$old_minor" ]; then
70-
echo "minor"
71-
elif [ "$new_patch" -gt "$old_patch" ]; then
72-
echo "patch"
73-
else
74-
echo "none"
75-
fi
76-
}
77-
7860
# Determine bump types for each SDK
7961
IOS_BUMP=$(determine_bump_type "$CURRENT_IOS_VERSION" "$LATEST_IOS_VERSION")
8062
ANDROID_BUMP=$(determine_bump_type "$CURRENT_ANDROID_VERSION" "$LATEST_ANDROID_VERSION")

scripts/lib/changelog_prompt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ IMPORTANT INSTRUCTIONS:
4444
2. Decide SIMPLE or DETAILED based on criteria above
4545
3. Return ONLY the formatted changelog (no explanations, no preamble)
4646
4. If unsure or SDK changelogs lack substance, use SIMPLE
47-
5. Ensure all version numbers in links match exactly (no 'v' prefix in URLs)
47+
5. Do not include 'v' prefix in version numbers within URLs
4848
6. Use release type: "Major" for X.0.0, "Minor" for X.Y.0, "Patch" for X.Y.Z

scripts/lib/generate_changelog.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Intelligent changelog generation using Gemini CLI
33
# Fetches SDK changelogs, analyzes them, and generates appropriate format
44

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

9+
# Source shared utilities
10+
source "$LIB_DIR/version_utils.sh"
11+
912
# Fetch SDK changelog from GitHub release notes
1013
fetch_github_changelog() {
1114
local repo="$1"
@@ -131,7 +134,7 @@ validate_and_fix() {
131134

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

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

257-
# Expected title format: "Release X.Y.Z"
260+
# Expected title format: "Release X.Y.Z" or "[TEST] Release X.Y.Z"
258261
local expected_title="Release ${plugin_version}"
262+
local expected_test_title="[TEST] Release ${plugin_version}"
259263

260-
if [ "$pr_title" != "$expected_title" ]; then
264+
if [ "$pr_title" != "$expected_title" ] && [ "$pr_title" != "$expected_test_title" ]; then
261265
echo " ⚠️ WARNING: PR title is '$pr_title', expected '$expected_title'" >&2
262266
fi
263267

scripts/lib/version_utils.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
# Shared utilities for version management scripts
3+
4+
# Portable sed -i (macOS vs GNU)
5+
sedi() {
6+
if [[ "$OSTYPE" == "darwin"* ]]; then
7+
sed -i '' "$@"
8+
else
9+
sed -i "$@"
10+
fi
11+
}
12+
13+
# Determine bump type (major, minor, patch)
14+
determine_bump_type() {
15+
local old=$1
16+
local new=$2
17+
18+
IFS='.' read -r old_major old_minor old_patch <<< "$old"
19+
IFS='.' read -r new_major new_minor new_patch <<< "$new"
20+
21+
if [ "$new_major" -gt "$old_major" ]; then
22+
echo "major"
23+
elif [ "$new_minor" -gt "$old_minor" ]; then
24+
echo "minor"
25+
elif [ "$new_patch" -gt "$old_patch" ]; then
26+
echo "patch"
27+
else
28+
echo "none"
29+
fi
30+
}
31+
32+
# Get highest semver version from a GitHub repo
33+
# Uses releases API (preferred), falls back to tags
34+
# Filters for valid semver, strips 'v' prefix, sorts semantically
35+
get_latest_release_version() {
36+
local repo="$1"
37+
local error_file=$(mktemp)
38+
local versions
39+
40+
# Try releases API first (preferred - explicitly published versions)
41+
versions=$(gh api "repos/${repo}/releases" --paginate --jq '.[].tag_name' 2>"$error_file")
42+
43+
# Fallback to tags if no releases found
44+
if [ -z "$versions" ]; then
45+
versions=$(gh api "repos/${repo}/tags" --paginate --jq '.[].name' 2>"$error_file")
46+
fi
47+
48+
# Check for API errors
49+
if [ -z "$versions" ] && [ -s "$error_file" ]; then
50+
echo " API error: $(cat "$error_file")" >&2
51+
rm -f "$error_file"
52+
return 1
53+
fi
54+
rm -f "$error_file"
55+
56+
# Filter to valid semver, strip 'v' prefix, sort semantically, get highest
57+
local result=$(echo "$versions" | \
58+
grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | \
59+
sed 's/^v//' | \
60+
sort -t. -k1,1n -k2,2n -k3,3n | \
61+
tail -1)
62+
63+
# Validate result is a proper version
64+
if ! [[ "$result" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
65+
echo " No valid semver releases found" >&2
66+
return 1
67+
fi
68+
69+
echo "$result"
70+
}

scripts/prep_proxy_release.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -e
33

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

10+
# Source shared utilities
11+
source "$SCRIPT_DIR/lib/version_utils.sh"
12+
1013
# Parse arguments
1114
TEST_MODE=false
1215
if [ "$1" = "--test" ]; then
@@ -44,8 +47,8 @@ echo -e "${BLUE}Updating files...${NC}"
4447

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

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

6568
# Update android/gradle/libs.versions.toml
6669
if [ "$TEST_MODE" = "false" ]; then
67-
sed -i '' "s/airshipProxy = '[0-9]*\.[0-9]*\.[0-9]*'/airshipProxy = '${PROXY_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
68-
sed -i '' "s/airship = '[0-9]*\.[0-9]*\.[0-9]*'/airship = '${ANDROID_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
70+
sedi "s/airshipProxy = '[0-9]*\.[0-9]*\.[0-9]*'/airshipProxy = '${PROXY_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
71+
sedi "s/airship = '[0-9]*\.[0-9]*\.[0-9]*'/airship = '${ANDROID_VERSION}'/" "$REPO_ROOT/android/gradle/libs.versions.toml"
6972
echo "✓ Updated android/gradle/libs.versions.toml"
7073
else
7174
echo " Would update android/gradle/libs.versions.toml:"

0 commit comments

Comments
 (0)