-
-
Notifications
You must be signed in to change notification settings - Fork 11
360 lines (308 loc) · 12.2 KB
/
Copy pathrelease-react-native.yml
File metadata and controls
360 lines (308 loc) · 12.2 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
name: "A. Release: react-native-iap"
on:
workflow_dispatch:
inputs:
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
- current
- rc-bump
default: patch
prerelease:
description: "Publish as prerelease (-rc.1)"
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: write
jobs:
validate-android:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
GRADLE_OPTS: '-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError"'
defaults:
run:
working-directory: libraries/react-native-iap
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install Yarn 3
run: corepack enable && corepack prepare yarn@3.6.1 --activate
- name: Install dependencies
run: yarn install --immutable
- name: Generate nitrogen code
run: yarn nitrogen
- name: Install JDK
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "17"
- name: Accept Android SDK licenses
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses || true
- name: Build Android library
working-directory: libraries/react-native-iap/example/android
run: ./gradlew :react-native-iap:assembleDebug --stacktrace
validate-ios:
runs-on: macos-15
timeout-minutes: 60
env:
XCODE_VERSION: 16.4
defaults:
run:
working-directory: libraries/react-native-iap
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install Yarn 3
run: corepack enable && corepack prepare yarn@3.6.1 --activate
- name: Install dependencies
run: yarn install --immutable
- name: Generate nitrogen code
run: yarn nitrogen
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Cache CocoaPods
uses: actions/cache@v5
with:
path: |
~/.cocoapods/repos/trunk
libraries/react-native-iap/example/ios/Pods
key: ${{ runner.os }}-pods-rniap-${{ hashFiles('libraries/react-native-iap/example/ios/Podfile.lock') }}
- name: Install Ruby dependencies
working-directory: libraries/react-native-iap/example
run: bundle install
- name: Install CocoaPods dependencies
working-directory: libraries/react-native-iap/example/ios
run: bundle exec pod install --repo-update
- name: Build iOS library
working-directory: libraries/react-native-iap/example/ios
run: |
set -o pipefail
xcodebuild build \
-workspace example.xcworkspace \
-scheme example \
-destination 'generic/platform=iOS Simulator' \
-configuration Debug \
CODE_SIGNING_ALLOWED=NO \
COMPILER_INDEX_STORE_ENABLE=NO
deploy:
needs: [validate-android, validate-ios]
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
defaults:
run:
working-directory: libraries/react-native-iap
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Checkout release tag (current version)
if: ${{ inputs.version == 'current' }}
run: |
NEW_VERSION=$(node -p "require('./package.json').version")
RELEASE_TAG="react-native-iap-${NEW_VERSION}"
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
git checkout "$RELEASE_TAG"
else
echo "Tag $RELEASE_TAG does not exist; current mode will use HEAD."
fi
- name: Disable Corepack
run: corepack disable
- name: Install dependencies
run: node .yarn/releases/yarn-3.6.1.cjs install --immutable
- name: Lint
run: |
node .yarn/releases/yarn-3.6.1.cjs lint:tsc
npx eslint --ext .ts,.tsx,.js,.jsx src plugin/src
- name: Configure Git user
run: |
git config user.name "react-native-iap bot"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
VERSION_TYPE="${{ inputs.version }}"
IS_PRERELEASE="${{ inputs.prerelease }}"
if [ "$VERSION_TYPE" = "current" ]; then
NEW_VERSION=$(node -p "require('./package.json').version")
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
if [[ "$NEW_VERSION" == *-* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
exit 0
fi
if [ "$VERSION_TYPE" = "rc-bump" ]; then
npm version prerelease --preid=rc --no-git-tag-version
elif [ "$IS_PRERELEASE" = "true" ]; then
npm version "pre${VERSION_TYPE}" --preid=rc --no-git-tag-version
else
npm version "$VERSION_TYPE" --no-git-tag-version
fi
NEW_VERSION=$(node -p "require('./package.json').version")
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
if [[ "$NEW_VERSION" == *-* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Check if release tag already exists
id: check_tag
env:
NEW_VERSION: ${{ steps.bump.outputs.version }}
VERSION_TYPE: ${{ inputs.version }}
run: |
RELEASE_TAG="react-native-iap-${NEW_VERSION}"
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
if [ "$VERSION_TYPE" = "current" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "⚠️ Tag $RELEASE_TAG already exists. Will reuse existing tag (current mode)."
else
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "❌ Tag $RELEASE_TAG already exists. Use 'current' to retry this version."
exit 1
fi
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "✓ Tag $RELEASE_TAG does not exist"
fi
- name: Prepare package (build + codegen)
run: node .yarn/releases/yarn-3.6.1.cjs prepare
- name: Commit version update
if: ${{ inputs.version != 'current' }}
run: |
NEW_VERSION="${{ steps.bump.outputs.version }}"
git add package.json
git commit -m "chore(release): react-native-iap ${NEW_VERSION}"
- name: Push commit and tags
if: ${{ inputs.version != 'current' }}
env:
NEW_VERSION: ${{ steps.bump.outputs.version }}
run: |
STASHED=false
if ! git diff --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then
git stash push --include-untracked -m "release artifacts"
STASHED=true
fi
git pull --rebase origin main
if [ "$STASHED" = "true" ]; then
git stash pop
fi
git tag -a "react-native-iap-${NEW_VERSION}" -m "Release react-native-iap-${NEW_VERSION}"
git push origin HEAD:main --follow-tags
- name: Create tag (current version)
if: ${{ inputs.version == 'current' && steps.check_tag.outputs.exists != 'true' }}
env:
NEW_VERSION: ${{ steps.bump.outputs.version }}
run: |
TAG_TARGET="HEAD"
PUBLISHED_GIT_HEAD=$(npm view "react-native-iap@$NEW_VERSION" gitHead 2>/dev/null || true)
if [ -n "$PUBLISHED_GIT_HEAD" ] && git cat-file -e "$PUBLISHED_GIT_HEAD^{commit}" 2>/dev/null; then
TAG_TARGET="$PUBLISHED_GIT_HEAD"
fi
git tag -a "react-native-iap-${NEW_VERSION}" "$TAG_TARGET" -m "Release react-native-iap-${NEW_VERSION}"
git push origin "react-native-iap-${NEW_VERSION}"
- name: Resolve symlinks for npm publish
run: |
if [ -L openiap-versions.json ]; then
cp --remove-destination "$(readlink openiap-versions.json)" openiap-versions.json
fi
- name: Consumer install smoke test
run: node .yarn/releases/yarn-3.6.1.cjs verify:consumer-install --pack-ignore-scripts
- name: Ensure npm CLI v11.5.1 or later (required for OIDC)
run: npm install -g npm@11.5.1
- name: Check if npm package already published
id: check_npm
env:
VERSION: ${{ steps.bump.outputs.version }}
run: |
if NPM_OUTPUT=$(npm view "react-native-iap@$VERSION" version 2>&1); then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "⚠️ react-native-iap@$VERSION already exists on npm"
elif echo "$NPM_OUTPUT" | grep -qiE 'E404|404 Not Found'; then
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "✓ react-native-iap@$VERSION does not exist, will publish"
else
echo "❌ Unable to verify react-native-iap@$VERSION on npm"
echo "$NPM_OUTPUT"
exit 1
fi
- name: Publish to npm with OIDC trusted publishing
if: steps.check_npm.outputs.exists == 'false'
run: |
if [ "${{ steps.bump.outputs.is_prerelease }}" = "true" ]; then
npm publish --tag next --access public --provenance
else
npm publish --access public --provenance
fi
- name: Generate release notes
id: release_notes
env:
VERSION: ${{ steps.bump.outputs.version }}
run: |
RELEASE_REF="HEAD"
if git rev-parse "react-native-iap-$VERSION" >/dev/null 2>&1; then
RELEASE_REF="react-native-iap-$VERSION"
fi
PREV_TAG=$(git for-each-ref --sort=-creatordate --format '%(refname:short)' 'refs/tags/react-native-iap-*' | grep -v "$VERSION" | head -n 1)
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git log "$PREV_TAG..$RELEASE_REF" --pretty=format:"- %s ([\`%h\`](https://github.com/hyodotdev/openiap/commit/%H))" -- libraries/react-native-iap/ packages/google/ packages/apple/)
fi
if [ -z "$CHANGELOG" ]; then
CHANGELOG="- No direct code changes — picks up the latest openiap-google / openiap-apple native library updates. See the consolidated release notes for details."
fi
cat > /tmp/release-notes.md <<EOF
## react-native-iap $VERSION
React Native wrapper for the OpenIAP specification.
### What's Changed
$CHANGELOG
### Installation
\`\`\`bash
npm install react-native-iap@$VERSION
# or
yarn add react-native-iap@$VERSION
\`\`\`
### Documentation
- [Setup guide — React Native](https://openiap.dev/docs/setup/react-native)
- [API reference](https://openiap.dev/docs/apis)
- [Release notes](https://openiap.dev/docs/updates/releases)
### Links
- [npm](https://www.npmjs.com/package/react-native-iap/v/$VERSION)
- [GitHub (monorepo)](https://github.com/hyodotdev/openiap/tree/main/libraries/react-native-iap)
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: react-native-iap-${{ steps.bump.outputs.version }}
name: react-native-iap ${{ steps.bump.outputs.version }}
draft: false
prerelease: ${{ steps.bump.outputs.is_prerelease }}
body_path: /tmp/release-notes.md