-
Notifications
You must be signed in to change notification settings - Fork 62
160 lines (132 loc) · 6.72 KB
/
Copy pathbump-native-version.yml
File metadata and controls
160 lines (132 loc) · 6.72 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
name: Bump Native OneSignal SDKs
on:
workflow_dispatch:
inputs:
android_version:
description: "Target OneSignal-Android-SDK version (e.g., 5.1.38)"
required: true
type: string
ios_version:
description: "Target OneSignal-iOS-SDK version (e.g., 5.2.15)"
required: true
type: string
permissions:
contents: write
pull-requests: write
jobs:
bump-native-sdks:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitHub CLI
run: sudo apt-get update -y && sudo apt-get install -y gh jq
- name: Configure GitHub Auth
run: gh auth status || gh auth login --with-token <<< "${GH_TOKEN}"
- name: Get current native SDK versions
id: current
run: |
ANDROID_FILE="com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml"
IOS_FILE="com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml"
ANDROID_CURRENT=$(grep -oE 'com\.onesignal:OneSignal:[0-9]+\.[0-9]+\.[0-9]+' "$ANDROID_FILE" | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
IOS_CURRENT=$(grep -oE 'OneSignalXCFramework\" version=\"[0-9]+\.[0-9]+\.[0-9]+' "$IOS_FILE" | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "android_current=$ANDROID_CURRENT" >> $GITHUB_OUTPUT
echo "ios_current=$IOS_CURRENT" >> $GITHUB_OUTPUT
echo "Detected Android SDK: $ANDROID_CURRENT, iOS SDK: $IOS_CURRENT"
- name: Update native SDK versions in Unity dependencies
run: |
ANDROID_NEW=${{ inputs.android_version }}
IOS_NEW=${{ inputs.ios_version }}
echo "🔧 Updating Android SDK → $ANDROID_NEW"
sed -i "s/com\.onesignal:OneSignal:[0-9.]\+/com.onesignal:OneSignal:${ANDROID_NEW}/g" \
com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml
sed -i "s/com\.onesignal:OneSignal:[0-9.]\+/com.onesignal:OneSignal:${ANDROID_NEW}/g" \
OneSignalExample/Assets/Plugins/Android/mainTemplate.gradle || true
sed -i "s/com\.onesignal:OneSignal:[0-9.]\+/com.onesignal:OneSignal:${ANDROID_NEW}/g" \
OneSignalExample/ProjectSettings/AndroidResolverDependencies.xml || true
echo "🔧 Updating iOS SDK → $IOS_NEW"
sed -i "s/OneSignalXCFramework\" version=\"[0-9.]\+/OneSignalXCFramework\" version=\"${IOS_NEW}/g" \
com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml
- name: Gather and combine release notes
id: combined
uses: actions/github-script@v8
env:
ANDROID_OLD: ${{ steps.current.outputs.android_current }}
IOS_OLD: ${{ steps.current.outputs.ios_current }}
ANDROID_NEW: ${{ inputs.android_version }}
IOS_NEW: ${{ inputs.ios_version }}
with:
script: |
const { ANDROID_OLD, ANDROID_NEW, IOS_OLD, IOS_NEW } = process.env;
const getNotesBetween = async (repo, from, to) => {
console.log(`🔎 Gathering release notes for ${repo} from ${from} → ${to}`);
const [owner, name] = repo.split('/');
const releases = await github.paginate(github.rest.repos.listReleases, {
owner, repo: name, per_page: 100
});
const normalize = t => t.replace(/^Release /, '');
const tags = releases.map(r => normalize(r.tag_name));
const startIndex = tags.indexOf(from);
const endIndex = tags.indexOf(to);
if (startIndex === -1 || endIndex === -1) {
console.warn(`⚠️ Could not find tags ${from} or ${to} in ${repo}`);
return '';
}
const selected = releases.filter(r => {
const tag = normalize(r.tag_name);
return tags.indexOf(tag) > startIndex && tags.indexOf(tag) <= endIndex;
}).reverse();
return selected
.map(r => `- ### ${normalize(r.tag_name)}\n${r.body || '_No notes provided._'}`)
.join('\n\n');
};
const androidNotes = await getNotesBetween(
'OneSignal/OneSignal-Android-SDK',
ANDROID_OLD,
ANDROID_NEW
);
const iosNotes = await getNotesBetween(
'OneSignal/OneSignal-iOS-SDK',
IOS_OLD,
IOS_NEW
);
const combined = `
- Updated included Android SDK from ${ANDROID_OLD} to [${ANDROID_NEW}](https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/${ANDROID_NEW})
${androidNotes}
- Updated included iOS SDK from ${IOS_OLD} to [${IOS_NEW}](https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/${IOS_NEW})
${iosNotes}
For full changes, see the [Android release notes](https://github.com/OneSignal/OneSignal-Android-SDK/releases) and [iOS release notes](https://github.com/OneSignal/OneSignal-iOS-SDK/releases)
`.trim();
core.setOutput('combined', combined);
console.log('✅ Combined release notes generated.');
- name: Update CHANGELOG.md
uses: actions/github-script@v8
env:
NOTES: ${{ steps.combined.outputs.combined }}
with:
script: |
const fs = require('fs');
const file = 'OneSignalExample/Assets/OneSignal/CHANGELOG.md';
let changelog = fs.readFileSync(file, 'utf8');
const insert = process.env.NOTES;
changelog = changelog.replace(/(## \[Unreleased\])/, `$1\n${insert}\n`);
fs.writeFileSync(file, changelog);
console.log('✅ CHANGELOG.md updated successfully.');
- name: Commit and create PR
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="bump-native-${{ inputs.android_version }}-${{ inputs.ios_version }}"
git checkout -B "$BRANCH" # create or reset local branch to latest
git add .
git commit -m "Bump native OneSignal SDKs; OneSignal-Android-SDK ${{ inputs.android_version }}, OneSignal-iOS-SDK ${{ inputs.ios_version }}" || echo "No changes to commit"
git push origin "$BRANCH" --force
gh pr create \
--title "Bump native OneSignal SDKs; OneSignal-Android-SDK ${{ inputs.android_version }}, OneSignal-iOS-SDK ${{ inputs.ios_version }}" \
--body "${{ steps.combined.outputs.combined }}" \
--base main \
--label "native-sdk-bump" || echo "PR already exists, skipping creation"