-
Notifications
You must be signed in to change notification settings - Fork 196
184 lines (157 loc) · 7.44 KB
/
create-release-pr.yml
File metadata and controls
184 lines (157 loc) · 7.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Create Release PR
on:
# For making a release pr from android / ios sdk actions
workflow_call:
secrets:
GH_PUSH_TOKEN:
required: false
description: 'GitHub token for pushing changes'
inputs:
cordova_version:
description: 'New Cordova Version (e.g., 5.2.15 or 5.2.15-beta.1)'
required: true
type: string
android_version:
description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.'
required: false
type: string
ios_version:
description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.'
required: false
type: string
target_branch:
description: 'Target branch to create the release PR on. Defaults to main.'
required: false
type: string
default: main
#For making a release pr from cordova github actions.
workflow_dispatch:
inputs:
cordova_version:
description: 'New Cordova Version (e.g., 5.2.15 or 5.2.15-beta.1)'
required: true
type: string
android_version:
description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.'
required: false
type: string
ios_version:
description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.'
required: false
type: string
target_branch:
description: 'Target branch to create the release PR on. Defaults to main.'
required: false
type: string
default: main
jobs:
prep:
uses: OneSignal/sdk-shared/.github/workflows/prep-release.yml@main
secrets:
# Need this cross-repo token (sdk-shared & this repo) to perform changes
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
# Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-shared)
target_repo: OneSignal/OneSignal-Cordova-SDK
version: ${{ inputs.cordova_version }}
# Cordova specific steps
update_version:
needs: prep
runs-on: macos-latest
outputs:
cordova_from: ${{ steps.current_versions.outputs.cordova_from }}
android_from: ${{ steps.current_versions.outputs.android_from }}
ios_from: ${{ steps.current_versions.outputs.ios_from }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# Need repository otherwise caller would set github.repository to the caller itself (e.g. sdk-shared)
repository: OneSignal/OneSignal-Cordova-SDK
ref: ${{ needs.prep.outputs.release_branch }}
token: ${{ secrets.GH_PUSH_TOKEN || github.token }}
- name: Setup Git User
uses: OneSignal/sdk-shared/.github/actions/setup-git-user@main
- name: Get current native SDK versions from target branch
id: current_versions
run: |
git fetch origin ${{ inputs.target_branch }}
# Get versions from target branch (not the release branch)
CURRENT_VERSION=$(git show origin/${{ inputs.target_branch }}:package.json | jq -r .version)
ANDROID_VERSION=$(git show origin/${{ inputs.target_branch }}:plugin.xml | sed -n 's/.*com\.onesignal:OneSignal:\([0-9.]*\).*/\1/p' | head -1)
IOS_VERSION=$(git show origin/${{ inputs.target_branch }}:plugin.xml | sed -n 's/.*OneSignalXCFramework.*spec="\([0-9.]*\)".*/\1/p' | head -1)
echo "cordova_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT
echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT
- name: Update Android SDK version
if: inputs.android_version != ''
run: |
VERSION="${{ inputs.android_version }}"
# Validate version exists on GitHub
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
if [ -z "$RELEASE" ]; then
echo "✗ Android SDK version ${VERSION} not found on GitHub"
exit 1
fi
# Update plugin.xml with new version
# mac os sed syntax
sed -i '' 's|<framework src="com\.onesignal:OneSignal:[^"]*" />|<framework src="com.onesignal:OneSignal:'"$VERSION"'" />|' plugin.xml
echo "✓ Updated plugin.xml with Android SDK ${VERSION}"
# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Update Android SDK to ${VERSION}" && git push
- name: Update iOS SDK version
if: inputs.ios_version != ''
run: |
VERSION="${{ inputs.ios_version }}"
# Validate version exists on GitHub
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
if [ -z "$RELEASE" ]; then
echo "✗ iOS SDK version ${VERSION} not found"
exit 1
fi
# Update plugin.xml with new version
# mac os sed syntax
sed -i '' "s|<pod name=\"OneSignalXCFramework\" spec=\"[^\"]*\" />|<pod name=\"OneSignalXCFramework\" spec=\"${VERSION}\" />|" plugin.xml
echo "✓ Updated plugin.xml with iOS SDK ${VERSION}"
# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Update iOS SDK to ${VERSION}" && git push
- name: Update sdk version
run: |
NEW_VERSION="${{ inputs.cordova_version }}"
# Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215)
# For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15)
BASE_VERSION=$(echo "$NEW_VERSION" | sed 's/-[a-z].*//')
WRAPPER_VERSION=$(echo "$BASE_VERSION" | awk -F'.' '{printf "%02d%02d%02d", $1, $2, $3}')
# Update package.json version
npm pkg set version="$NEW_VERSION"
# Update plugin.xml cordova plugin version (target <plugin> element specifically)
sed -i '' '/<plugin/,/>/ { s/version="[^"]*"/version="'"$NEW_VERSION"'"/; }' plugin.xml
# Update OneSignalPush.java wrapper version
sed -i '' "s/OneSignalWrapper\.setSdkVersion(\"[^\"]*\")/OneSignalWrapper.setSdkVersion(\"$WRAPPER_VERSION\")/g" src/android/com/onesignal/cordova/OneSignalPush.java
# Update OneSignalPush.m wrapper version
sed -i '' "s/OneSignalWrapper\.sdkVersion = @\"[^\"]*\"/OneSignalWrapper.sdkVersion = @\"$WRAPPER_VERSION\"/g" src/ios/OneSignalPush.m
# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Release $NEW_VERSION" && git push
create-pr:
needs: [prep, update_version]
uses: OneSignal/sdk-shared/.github/workflows/create-release.yml@main
secrets:
# Need this cross-repo token (sdk-shared & this repo) to perform changes
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
# Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-shared)
target_repo: OneSignal/OneSignal-Cordova-SDK
release_branch: ${{ needs.prep.outputs.release_branch }}
target_branch: ${{ inputs.target_branch }}
android_from: ${{ needs.update_version.outputs.android_from }}
android_to: ${{ inputs.android_version }}
ios_from: ${{ needs.update_version.outputs.ios_from }}
ios_to: ${{ inputs.ios_version }}