-
Notifications
You must be signed in to change notification settings - Fork 221
1418 lines (1254 loc) · 58 KB
/
Copy pathrelease.yml
File metadata and controls
1418 lines (1254 loc) · 58 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# =============================================================================
# Unified Release Workflow - RC and Production
# =============================================================================
#
# Purpose: Single workflow for both RC and production npm releases.
# npm OIDC Trusted Publishing allows only one workflow file per package.
#
# RC path (workflow_dispatch with release_type=rc):
# 1. Validates RC version format and inputs
# 2. Runs full CI pipeline (Jest + ESLint + release builds)
# 3. Creates release branch with version bumps across 5+ files
# 4. Runs iOS + Android E2E tests on the release branch
# 5. Validates Jira fix version exists
# 6. Publishes to npm with --tag rc
# 7. Creates GitHub pre-release + PR to master
# 8. Notifies team via Slack
#
# Production path (PR merge to master OR workflow_dispatch with release_type=production):
# 1. Validates the merge is from a release branch
# 2. Publishes to npm with the `latest` tag
# 3. Verifies the package is live on npm (retry loop, max 120s)
# 4. Creates a GitHub release with release notes
# 5. Fetches Jira tickets for the fix version
# 6. Notifies team via Slack
#
# =============================================================================
name: Release
on:
pull_request:
types:
- closed
branches:
- master
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
type: choice
options:
- rc
- production
rn_version:
description: 'Plugin version (e.g., 6.18.0-rc1 for RC, 6.18.0 for production)'
required: true
type: string
ios_sdk_version:
description: 'iOS native AppsFlyer SDK version (e.g., 6.18.0) — RC only'
required: false
type: string
android_sdk_version:
description: 'Android native AppsFlyer SDK version (e.g., 6.18.0) — RC only'
required: false
type: string
base_branch:
description: 'Base branch to create the release branch from — RC only'
required: false
default: development
type: string
pc_version:
description: 'PurchaseConnector iOS version override (leave empty to auto-fetch) — RC only'
required: false
default: ''
type: string
skip_unit:
description: 'Skip unit tests and linting — RC only'
required: false
type: boolean
default: false
skip_builds:
description: 'Skip Android + iOS release builds — RC only'
required: false
type: boolean
default: false
skip_e2e:
description: 'Skip E2E iOS + Android jobs — RC only'
required: false
type: boolean
default: false
dry_run:
description: 'Do not publish to npm'
required: false
type: boolean
default: true
concurrency:
group: release-${{ github.workflow }}-${{ inputs.release_type || 'production' }}
cancel-in-progress: false
jobs:
# ===========================================================================
# Job 0: Route to RC or Production path
# ===========================================================================
determine-release-type:
name: Determine Release Type
runs-on: ubuntu-latest
outputs:
release_type: ${{ steps.route.outputs.release_type }}
is_valid_trigger: ${{ steps.route.outputs.is_valid_trigger }}
steps:
- name: Route release
id: route
env:
EVENT_NAME: ${{ github.event_name }}
PR_MERGED: ${{ github.event.pull_request.merged }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
INPUT_RELEASE_TYPE: ${{ inputs.release_type }}
run: |
set -euo pipefail
if [[ "$EVENT_NAME" == "pull_request" ]]; then
if [[ "$PR_MERGED" == "true" ]] && [[ "$PR_HEAD_REF" == releases/* ]]; then
echo "release_type=production" >> "$GITHUB_OUTPUT"
echo "is_valid_trigger=true" >> "$GITHUB_OUTPUT"
echo "PR merged from release branch — production path"
else
echo "release_type=none" >> "$GITHUB_OUTPUT"
echo "is_valid_trigger=false" >> "$GITHUB_OUTPUT"
echo "PR not merged or not from release branch — skipping"
fi
else
echo "release_type=$INPUT_RELEASE_TYPE" >> "$GITHUB_OUTPUT"
echo "is_valid_trigger=true" >> "$GITHUB_OUTPUT"
echo "Manual dispatch — $INPUT_RELEASE_TYPE path"
fi
# ===========================================================================
# RC Job 1: Validate RC Inputs & Compute Branch
# ===========================================================================
validate-rc:
name: Validate RC Inputs & Compute Branch
runs-on: ubuntu-latest
needs: [determine-release-type]
if: needs.determine-release-type.outputs.release_type == 'rc'
outputs:
version: ${{ steps.compute.outputs.version }}
base_version: ${{ steps.compute.outputs.base_version }}
is_rc: ${{ steps.compute.outputs.is_rc }}
is_valid: ${{ steps.compute.outputs.is_valid }}
base_branch: ${{ steps.compute.outputs.base_branch }}
release_branch: ${{ steps.compute.outputs.release_branch }}
ios_sdk_version: ${{ steps.compute.outputs.ios_sdk_version }}
android_sdk_version: ${{ steps.compute.outputs.android_sdk_version }}
is_dry_run: ${{ steps.dry-run.outputs.value }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Resolve dry_run
id: dry-run
env:
EVENT_NAME: ${{ github.event_name }}
DISPATCH_DRY: ${{ github.event.inputs.dry_run }}
run: |
set -euo pipefail
case "$EVENT_NAME" in
workflow_dispatch)
if [[ "$DISPATCH_DRY" == "true" ]]; then
echo "value=true" >> "$GITHUB_OUTPUT"
else
echo "value=false" >> "$GITHUB_OUTPUT"
fi
;;
*)
echo "value=false" >> "$GITHUB_OUTPUT"
;;
esac
- name: Validate and compute
id: compute
env:
VERSION: ${{ github.event.inputs.rn_version }}
IOS_VER: ${{ github.event.inputs.ios_sdk_version }}
AND_VER: ${{ github.event.inputs.android_sdk_version }}
BASE_BRANCH_INPUT: ${{ github.event.inputs.base_branch }}
run: |
set -euo pipefail
if [[ -z "$VERSION" || -z "$IOS_VER" || -z "$AND_VER" ]]; then
echo "Missing required inputs"; exit 1
fi
# RN version format: X.Y.Z-rcN (no +build)
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$ ]]; then
echo "rn_version must be X.Y.Z-rcN (e.g., 6.18.0-rc1)"; exit 1
fi
if [[ ! $IOS_VER =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ios_sdk_version must be X.Y.Z"; exit 1
fi
if [[ ! $AND_VER =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "android_sdk_version must be X.Y.Z"; exit 1
fi
# Compute base version (remove -rcN)
BASE_VERSION=$(echo "$VERSION" | sed 's/-rc[0-9]*$//')
MAJOR_MINOR=$(echo "$BASE_VERSION" | grep -oE '^[0-9]+\.[0-9]+')
MAJOR=$(echo "$BASE_VERSION" | grep -oE '^[0-9]+')
RELEASE_BRANCH="releases/${MAJOR}.x.x/${MAJOR_MINOR}.x/${VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "base_version=$BASE_VERSION" >> $GITHUB_OUTPUT
echo "is_rc=true" >> $GITHUB_OUTPUT
echo "is_valid=true" >> $GITHUB_OUTPUT
echo "base_branch=$BASE_BRANCH_INPUT" >> $GITHUB_OUTPUT
echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT
echo "ios_sdk_version=$IOS_VER" >> $GITHUB_OUTPUT
echo "android_sdk_version=$AND_VER" >> $GITHUB_OUTPUT
# ===========================================================================
# RC Job 2: Lint, Test & Build (reusable)
# ===========================================================================
run-ci:
name: Lint, Test & Build
needs: [determine-release-type, validate-rc]
if: >-
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_valid == 'true'
uses: ./.github/workflows/lint-test-build.yml
with:
skip_unit: ${{ github.event.inputs.skip_unit == 'true' }}
skip_builds: ${{ github.event.inputs.skip_builds == 'true' }}
secrets: inherit
# ===========================================================================
# RC Job 3: Create/Update Release Branch and Apply Changes
# ===========================================================================
prepare-branch:
name: Create Release Branch & Apply Changes
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc]
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_valid == 'true'
outputs:
release_branch: ${{ steps.push.outputs.release_branch }}
steps:
- name: Checkout base branch
uses: actions/checkout@v5
with:
ref: ${{ needs.validate-rc.outputs.base_branch }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Create release branch
id: branch
run: |
set -e
REL_BRANCH="${{ needs.validate-rc.outputs.release_branch }}"
echo "Target release branch: $REL_BRANCH"
if git ls-remote --exit-code --heads origin "$REL_BRANCH" >/dev/null 2>&1; then
echo "Branch already exists on remote. Checking it out."
git fetch origin "$REL_BRANCH":"$REL_BRANCH"
git checkout "$REL_BRANCH"
else
git checkout -b "$REL_BRANCH"
fi
- name: Update package.json version
env:
VERSION: ${{ needs.validate-rc.outputs.version }}
run: |
echo "Setting package.json version to $VERSION"
npm version "$VERSION" --no-git-tag-version
grep '"version"' package.json
- name: Update Android SDK fallback in build.gradle
env:
AND_VER: ${{ needs.validate-rc.outputs.android_sdk_version }}
run: |
sed -i.bak "s/af-android-sdk:\${safeExtGet('appsflyerVersion', '[^']*')}/af-android-sdk:\${safeExtGet('appsflyerVersion', '${AND_VER}')}/" android/build.gradle
rm -f android/build.gradle.bak
grep "af-android-sdk:" android/build.gradle
- name: Update iOS SDK deps in podspec
env:
IOS_VER: ${{ needs.validate-rc.outputs.ios_sdk_version }}
PC_VER_INPUT: ${{ github.event.inputs.pc_version }}
run: |
# AppsFlyerFramework (default)
sed -i.bak "s/'AppsFlyerFramework', '[^']*'/'AppsFlyerFramework', '${IOS_VER}'/" react-native-appsflyer.podspec
# AppsFlyerFramework/Strict
sed -i.bak "s|'AppsFlyerFramework/Strict', '[^']*'|'AppsFlyerFramework/Strict', '${IOS_VER}'|" react-native-appsflyer.podspec
# PurchaseConnector (conditional dep, has its own version)
if grep -q "PurchaseConnector" react-native-appsflyer.podspec; then
if [[ -n "${PC_VER_INPUT:-}" ]]; then
PC_VER="$PC_VER_INPUT"
echo "Using manual PurchaseConnector version override: $PC_VER"
else
PC_VER=$(curl -s "https://api.github.com/repos/AppsFlyerSDK/appsflyer-apple-purchase-connector/releases/latest" | jq -r '.tag_name')
if [[ -n "$PC_VER" && "$PC_VER" != "null" ]]; then
echo "Auto-fetched PurchaseConnector version: $PC_VER"
fi
fi
if [[ -z "$PC_VER" || "$PC_VER" == "null" ]]; then
echo "::error::Could not fetch latest PurchaseConnector version and no pc_version input provided."
exit 1
fi
sed -i.bak "s/'PurchaseConnector', '[^']*'/'PurchaseConnector', '${PC_VER}'/" react-native-appsflyer.podspec
fi
rm -f react-native-appsflyer.podspec.bak
echo "Updated podspec lines:"
grep -n "AppsFlyerFramework\|PurchaseConnector" react-native-appsflyer.podspec || true
- name: Update plugin version constants
env:
VERSION: ${{ needs.validate-rc.outputs.version }}
run: |
echo "Updating PLUGIN_VERSION constants to: $VERSION"
# Android - RNAppsFlyerConstants.java
sed -i.bak "s/PLUGIN_VERSION = \"[^\"]*\"/PLUGIN_VERSION = \"${VERSION}\"/" android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java
rm -f android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java.bak
echo "Android:" && grep "PLUGIN_VERSION" android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java
# iOS - RNAppsFlyer.h
sed -i.bak "s/kAppsFlyerPluginVersion[[:space:]]*= @\"[^\"]*\"/kAppsFlyerPluginVersion = @\"${VERSION}\"/" ios/RNAppsFlyer.h
rm -f ios/RNAppsFlyer.h.bak
echo "iOS:" && grep "kAppsFlyerPluginVersion" ios/RNAppsFlyer.h
- name: Update README SDK version badges
env:
IOS_VER: ${{ needs.validate-rc.outputs.ios_sdk_version }}
AND_VER: ${{ needs.validate-rc.outputs.android_sdk_version }}
run: |
sed -i.bak -E "s/Android AppsFlyer SDK \*\*v[0-9.]+\*\*/Android AppsFlyer SDK **v${AND_VER}**/" README.md
sed -i.bak -E "s/iOS AppsFlyer SDK \*\*v[0-9.]+\*\*/iOS AppsFlyer SDK **v${IOS_VER}**/" README.md
rm -f README.md.bak
grep -n "AppsFlyer SDK \*\*v" README.md
- name: Update CHANGELOG.md
env:
VERSION: ${{ needs.validate-rc.outputs.version }}
IOS_VER: ${{ needs.validate-rc.outputs.ios_sdk_version }}
AND_VER: ${{ needs.validate-rc.outputs.android_sdk_version }}
run: |
CHANGELOG_ENTRY="## ${VERSION}\n Release date: *$(date +%Y-%m-%d)*\n\n### Changes\n- Android SDK ${AND_VER}\n- iOS SDK ${IOS_VER}\n- TODO: Add specific changes before merging\n"
printf '%b\n' "$CHANGELOG_ENTRY" | cat - CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md
head -10 CHANGELOG.md
- name: Commit & push changes
id: push
env:
VERSION: ${{ needs.validate-rc.outputs.version }}
IOS_VER: ${{ needs.validate-rc.outputs.ios_sdk_version }}
AND_VER: ${{ needs.validate-rc.outputs.android_sdk_version }}
run: |
set -e
REL_BRANCH='${{ needs.validate-rc.outputs.release_branch }}'
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
if [[ -n $(git status -s) ]]; then
git add -f package.json react-native-appsflyer.podspec README.md CHANGELOG.md \
ios/RNAppsFlyer.h \
android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java \
android/build.gradle
git commit -m "chore: prepare RC ${VERSION} (iOS ${IOS_VER}, Android ${AND_VER})"
git push --set-upstream origin "$REL_BRANCH"
else
echo "No changes to commit"
if ! git ls-remote --exit-code --heads origin "$REL_BRANCH" >/dev/null 2>&1; then
git push --set-upstream origin "$REL_BRANCH"
fi
fi
echo "release_branch=$REL_BRANCH" >> $GITHUB_OUTPUT
# ===========================================================================
# RC Job 4: E2E iOS
# ===========================================================================
run-e2e-ios:
name: RC-E2E iOS
needs: [determine-release-type, validate-rc, prepare-branch]
if: >-
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_valid == 'true' &&
github.event.inputs.skip_e2e != 'true'
uses: ./.github/workflows/ios-e2e.yml
with:
ref: ${{ needs.prepare-branch.outputs.release_branch }}
secrets: inherit
# ===========================================================================
# RC Job 5: E2E Android
# ===========================================================================
run-e2e-android:
name: RC-E2E Android
needs: [determine-release-type, validate-rc, prepare-branch]
if: >-
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_valid == 'true' &&
github.event.inputs.skip_e2e != 'true'
uses: ./.github/workflows/android-e2e.yml
with:
ref: ${{ needs.prepare-branch.outputs.release_branch }}
secrets: inherit
# ===========================================================================
# RC Job 6: Pre-publish gate
# ===========================================================================
pre-publish-gate:
name: Pre-publish Gate
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc, run-ci, run-e2e-ios, run-e2e-android]
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_valid == 'true'
outputs:
passed: ${{ steps.aggregate.outputs.passed }}
ci_result: ${{ steps.aggregate.outputs.ci_result }}
e2e_ios_result: ${{ steps.aggregate.outputs.e2e_ios_result }}
e2e_android_result: ${{ steps.aggregate.outputs.e2e_android_result }}
steps:
- name: Aggregate pre-publish results
id: aggregate
env:
CI_RESULT: ${{ needs.run-ci.result }}
E2E_IOS_RESULT: ${{ needs.run-e2e-ios.result }}
E2E_ANDROID_RESULT: ${{ needs.run-e2e-android.result }}
run: |
set -euo pipefail
echo "Lint, Test & Build : $CI_RESULT"
echo "RC-E2E iOS : $E2E_IOS_RESULT"
echo "RC-E2E Android : $E2E_ANDROID_RESULT"
ci_ok=false
ios_ok=false
android_ok=false
if [[ "$CI_RESULT" == "success" || "$CI_RESULT" == "skipped" ]]; then
ci_ok=true
fi
if [[ "$E2E_IOS_RESULT" == "success" || "$E2E_IOS_RESULT" == "skipped" ]]; then
ios_ok=true
fi
if [[ "$E2E_ANDROID_RESULT" == "success" || "$E2E_ANDROID_RESULT" == "skipped" ]]; then
android_ok=true
fi
{
echo "ci_result=$CI_RESULT"
echo "e2e_ios_result=$E2E_IOS_RESULT"
echo "e2e_android_result=$E2E_ANDROID_RESULT"
} >> "$GITHUB_OUTPUT"
if $ci_ok && $ios_ok && $android_ok; then
echo "passed=true" >> "$GITHUB_OUTPUT"
echo "Pre-publish gate passed"
exit 0
fi
echo "passed=false" >> "$GITHUB_OUTPUT"
echo "Pre-publish gate failed"
$ci_ok || echo " - Lint, Test & Build did not pass ($CI_RESULT)"
$ios_ok || echo " - RC-E2E iOS did not pass ($E2E_IOS_RESULT)"
$android_ok || echo " - RC-E2E Android did not pass ($E2E_ANDROID_RESULT)"
exit 1
# ===========================================================================
# RC Job 7: Validate Jira fix version
# ===========================================================================
validate-jira:
name: Validate Jira Fix Version
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc, pre-publish-gate]
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.pre-publish-gate.result == 'success' &&
needs.pre-publish-gate.outputs.passed == 'true'
steps:
- name: Verify Jira fix version exists
env:
CI_JIRA_EMAIL: ${{ secrets.CI_JIRA_EMAIL }}
CI_JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }}
CI_JIRA_DOMAIN: ${{ secrets.CI_JIRA_DOMAIN }}
BASE_VERSION: ${{ needs.validate-rc.outputs.base_version }}
run: |
set -euo pipefail
JIRA_FIX_VERSION="React Native SDK v${BASE_VERSION}"
JIRA_DOMAIN="${CI_JIRA_DOMAIN:-appsflyer.atlassian.net}"
echo "Looking for Jira fix version: $JIRA_FIX_VERSION"
if [[ -z "${CI_JIRA_EMAIL:-}" || -z "${CI_JIRA_TOKEN:-}" ]]; then
echo "::warning::Jira credentials not configured, skipping validation"
exit 0
fi
RESPONSE=$(curl -s -u "${CI_JIRA_EMAIL}:${CI_JIRA_TOKEN}" \
"https://${JIRA_DOMAIN}/rest/api/3/project/SDKRC/versions" \
| jq -r ".[] | select(.name == \"$JIRA_FIX_VERSION\") | .name")
if [[ -z "$RESPONSE" ]]; then
echo "::error::Jira fix version '$JIRA_FIX_VERSION' not found. Create it before publishing."
exit 1
fi
echo "Jira fix version found: $RESPONSE"
# ===========================================================================
# Production Job 1: Validate Production Release
# ===========================================================================
validate-production:
name: Validate Production Release
runs-on: ubuntu-latest
needs: [determine-release-type]
if: >-
needs.determine-release-type.outputs.release_type == 'production' &&
needs.determine-release-type.outputs.is_valid_trigger == 'true'
outputs:
version: ${{ steps.get-version.outputs.version }}
is_valid: ${{ steps.validate.outputs.is_valid }}
is_dry_run: ${{ steps.dry-run.outputs.value }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Resolve dry_run across trigger paths
id: dry-run
env:
EVENT_NAME: ${{ github.event_name }}
DISPATCH_DRY: ${{ github.event.inputs.dry_run }}
run: |
set -euo pipefail
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$DISPATCH_DRY" == "true" ]]; then
echo "value=true" >> "$GITHUB_OUTPUT"
else
echo "value=false" >> "$GITHUB_OUTPUT"
fi
- name: Validate release source
id: validate
env:
EVENT_NAME: ${{ github.event_name }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "Manual run - skipping branch validation"
echo "is_valid=true" >> "$GITHUB_OUTPUT"
else
SOURCE_BRANCH="$PR_HEAD_REF"
echo "Source branch: $SOURCE_BRANCH"
if [[ $SOURCE_BRANCH =~ ^releases/ ]]; then
echo "Valid release branch: $SOURCE_BRANCH"
echo "is_valid=true" >> "$GITHUB_OUTPUT"
else
echo "::error::Not a release branch: $SOURCE_BRANCH"
echo "is_valid=false" >> "$GITHUB_OUTPUT"
exit 1
fi
fi
- name: Get version from package.json
id: get-version
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_VERSION: ${{ github.event.inputs.rn_version }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
VERSION="$INPUT_VERSION"
echo "Using provided version: $VERSION"
else
VERSION=$(node -p "require('./package.json').version")
echo "Extracted version from package.json: $VERSION"
fi
# Validate version format (X.Y.Z, no -rc suffix for production)
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Valid production version format: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
else
echo "::error::Invalid production version format: $VERSION (expected X.Y.Z)"
exit 1
fi
- name: Check if tag already exists
env:
VERSION: ${{ steps.get-version.outputs.version }}
DRY_RUN: ${{ steps.dry-run.outputs.value }}
run: |
git fetch --tags
if git rev-parse "v$VERSION" >/dev/null 2>&1 || git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "::warning::Tag for $VERSION already exists"
if [[ "$DRY_RUN" != "true" ]]; then
echo "::error::Cannot create duplicate release"
exit 1
fi
fi
echo "Tag $VERSION does not exist - safe to proceed"
# ===========================================================================
# Shared: Publish to npm (RC with --tag rc, Production with latest)
# ===========================================================================
publish-to-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc, validate-production, prepare-branch, pre-publish-gate, validate-jira]
if: >-
!cancelled() &&
(
(needs.determine-release-type.outputs.release_type == 'rc' &&
needs.pre-publish-gate.result == 'success' &&
needs.pre-publish-gate.outputs.passed == 'true' &&
(needs.validate-jira.result == 'success' || needs.validate-jira.result == 'skipped'))
||
(needs.determine-release-type.outputs.release_type == 'production' &&
needs.validate-production.result == 'success' &&
needs.validate-production.outputs.is_valid == 'true')
)
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ needs.determine-release-type.outputs.release_type == 'rc' && needs.prepare-branch.outputs.release_branch || '' }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Install dependencies
run: npm install
- name: Verify version consistency
env:
RELEASE_TYPE: ${{ needs.determine-release-type.outputs.release_type }}
RC_VERSION: ${{ needs.validate-rc.outputs.version }}
PROD_VERSION: ${{ needs.validate-production.outputs.version }}
run: |
ACTUAL=$(node -p "require('./package.json').version")
if [[ "$RELEASE_TYPE" == "rc" ]]; then
EXPECTED="$RC_VERSION"
else
EXPECTED="$PROD_VERSION"
fi
if [[ "$ACTUAL" != "$EXPECTED" ]]; then
echo "::error::Version mismatch: package.json has '$ACTUAL' but expected '$EXPECTED'"
exit 1
fi
echo "Version consistent: $ACTUAL"
- name: Validate package (dry-run)
run: npm pack --dry-run
- name: Determine publish parameters
id: publish-params
env:
RELEASE_TYPE: ${{ needs.determine-release-type.outputs.release_type }}
RC_DRY_RUN: ${{ needs.validate-rc.outputs.is_dry_run }}
PROD_DRY_RUN: ${{ needs.validate-production.outputs.is_dry_run }}
run: |
if [[ "$RELEASE_TYPE" == "rc" ]]; then
echo "npm_tag=rc" >> "$GITHUB_OUTPUT"
echo "is_dry_run=${RC_DRY_RUN:-false}" >> "$GITHUB_OUTPUT"
else
echo "npm_tag=latest" >> "$GITHUB_OUTPUT"
echo "is_dry_run=${PROD_DRY_RUN:-false}" >> "$GITHUB_OUTPUT"
fi
- name: Dry-run — skipping publish
if: steps.publish-params.outputs.is_dry_run == 'true'
run: |
echo "DRY RUN — would publish $(node -p "require('./package.json').version") to npm"
npm pack --dry-run
- name: Publish to npm
if: steps.publish-params.outputs.is_dry_run != 'true'
env:
NODE_AUTH_TOKEN: ''
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="${{ steps.publish-params.outputs.npm_tag }}"
echo "Publishing $VERSION to npm with tag: $TAG"
if [[ "$TAG" == "rc" ]]; then
npm publish --tag rc --provenance
else
npm publish --provenance
fi
echo "Published $VERSION to npm"
- name: Verify publication (production only)
if: >-
needs.determine-release-type.outputs.release_type == 'production' &&
steps.publish-params.outputs.is_dry_run != 'true'
env:
VERSION: ${{ needs.validate-production.outputs.version }}
run: |
MAX_WAIT=120
POLL=15
ELAPSED=0
while (( ELAPSED < MAX_WAIT )); do
if npm view "react-native-appsflyer@$VERSION" version 2>/dev/null | grep -Fxq "$VERSION"; then
echo "Verified: $VERSION is live on npm"
break
fi
echo "Waiting for npm propagation (${ELAPSED}s / ${MAX_WAIT}s)..."
sleep "$POLL"
ELAPSED=$(( ELAPSED + POLL ))
done
if (( ELAPSED >= MAX_WAIT )); then
echo "::warning::npm propagation exceeded ${MAX_WAIT}s --- verify manually on npmjs.com"
fi
# ===========================================================================
# RC Job 8: Create Pre-Release Tag
# ===========================================================================
create-prerelease:
name: Create Pre-Release
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc, prepare-branch, publish-to-npm]
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.validate-rc.outputs.is_rc == 'true' &&
needs.publish-to-npm.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ needs.prepare-branch.outputs.release_branch }}
- name: Generate release notes
id: release-notes
env:
VERSION: ${{ needs.validate-rc.outputs.version }}
IOS_VER: ${{ needs.validate-rc.outputs.ios_sdk_version }}
AND_VER: ${{ needs.validate-rc.outputs.android_sdk_version }}
run: |
cat > release_notes.md << EOF
# AppsFlyer React Native Plugin - Release Candidate $VERSION
## Release Candidate for Testing
This is a pre-release version for QA testing. Do not use in production.
## Testing Instructions
\`\`\`bash
npm install react-native-appsflyer@${VERSION} --save
\`\`\`
## SDK Versions
- Android AppsFlyer SDK: ${AND_VER}
- iOS AppsFlyer SDK: ${IOS_VER}
---
**Note**: This is a pre-release and should not be used in production applications.
EOF
- name: Create GitHub Pre-Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.validate-rc.outputs.version }}
name: Release Candidate ${{ needs.validate-rc.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: true
generate_release_notes: false
token: ${{ secrets.GITHUB_TOKEN }}
# ===========================================================================
# RC Job 9: Open PR to master
# ===========================================================================
open-pr:
name: Open PR to master
runs-on: ubuntu-latest
needs: [determine-release-type, validate-rc, prepare-branch, publish-to-npm]
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc' &&
needs.publish-to-npm.result == 'success'
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ needs.prepare-branch.outputs.release_branch }}
- name: Create or update PR
uses: actions/github-script@v7
with:
script: |
const version = '${{ needs.validate-rc.outputs.base_version }}';
const rcVersion = '${{ needs.validate-rc.outputs.version }}';
const head = '${{ needs.prepare-branch.outputs.release_branch }}';
const base = 'master';
const androidVersion = '${{ needs.validate-rc.outputs.android_sdk_version }}';
const iosVersion = '${{ needs.validate-rc.outputs.ios_sdk_version }}';
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${head}`
});
const body = [
`### Release ${version}`,
'',
`- Android SDK: ${androidVersion}`,
`- iOS SDK: ${iosVersion}`,
'',
'```bash',
`npm install react-native-appsflyer@${rcVersion} --save`,
'```',
'',
'This PR was opened by the RC workflow.'
].join('\n');
if (prs.length > 0) {
const pr = prs[0];
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
title: `Release ${version}`,
body
});
core.setOutput('pr_number', pr.number);
} else {
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head,
base,
title: `Release ${version}`,
body,
maintainer_can_modify: true
});
core.setOutput('pr_number', pr.number);
}
# ===========================================================================
# Production Job 2: Create GitHub Release
# ===========================================================================
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [determine-release-type, validate-production, publish-to-npm]
if: >-
needs.determine-release-type.outputs.release_type == 'production' &&
needs.publish-to-npm.result == 'success' &&
needs.validate-production.outputs.is_dry_run != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Extract release notes from CHANGELOG
id: changelog
env:
VERSION: ${{ needs.validate-production.outputs.version }}
run: |
echo "Extracting release notes for version $VERSION from CHANGELOG.md"
if [ -f "CHANGELOG.md" ]; then
RELEASE_NOTES=$(awk "/## $VERSION/,/^## [0-9]/" CHANGELOG.md | sed '1d;$d')
if [ -z "$RELEASE_NOTES" ]; then
echo "::warning::Could not find release notes for $VERSION in CHANGELOG.md"
RELEASE_NOTES="Release version $VERSION. See [CHANGELOG.md](CHANGELOG.md) for details."
fi
else
RELEASE_NOTES="Release version $VERSION."
fi
echo "$RELEASE_NOTES" > release_notes.md
- name: Build release notes
env:
VERSION: ${{ needs.validate-production.outputs.version }}
REPO: ${{ github.repository }}
run: |
cat > final_release_notes.md << EOF
# AppsFlyer React Native Plugin v$VERSION
## Installation
\`\`\`bash
npm install react-native-appsflyer@$VERSION
\`\`\`
Then for iOS:
\`\`\`bash
cd ios && pod install
\`\`\`
## Changes in This Release
$(cat release_notes.md)
## Documentation
- [Installation Guide](https://github.com/$REPO/blob/master/Docs/Installation.md)
- [API Documentation](https://github.com/$REPO/blob/master/Docs/API.md)
- [Deep Linking Guide](https://github.com/$REPO/blob/master/Docs/DeepLink.md)
- [Expo Integration](https://github.com/$REPO/blob/master/Docs/ExpoIntegration.md)
## Links
- [npm Package](https://www.npmjs.com/package/react-native-appsflyer/v/$VERSION)
- [GitHub Repository](https://github.com/$REPO)
- [AppsFlyer Developer Hub](https://dev.appsflyer.com/)
## Support
For issues and questions, please contact <support@appsflyer.com>
EOF
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.validate-production.outputs.version }}
run: |
gh release create "v$VERSION" \
--title "v$VERSION" \
--notes-file final_release_notes.md \
--latest
# ===========================================================================
# RC Notify Team
# ===========================================================================
notify-team-rc:
name: Notify Team (RC)
runs-on: ubuntu-latest
needs:
- determine-release-type
- validate-rc
- prepare-branch
- run-ci
- run-e2e-ios
- run-e2e-android
- pre-publish-gate
- validate-jira
- publish-to-npm
- create-prerelease
if: >-
!cancelled() &&
needs.determine-release-type.outputs.release_type == 'rc'
steps:
- name: Determine status and failed stage
id: status
env:
VALIDATE_RESULT: ${{ needs.validate-rc.result }}
PREPARE_RESULT: ${{ needs.prepare-branch.result }}
GATE_RESULT: ${{ needs.pre-publish-gate.result }}
JIRA_RESULT: ${{ needs.validate-jira.result }}
PUBLISH_RESULT: ${{ needs.publish-to-npm.result }}
PRERELEASE_RESULT: ${{ needs.create-prerelease.result }}
run: |
set -euo pipefail
ok() { [[ "$1" == "success" || "$1" == "skipped" ]]; }