8
8
variables :
9
9
- name : BUILDSECMON_OPT_IN
10
10
value : true
11
+ - name : USE_YARN_FOR_PUBLISH
12
+ value : false
13
+
11
14
timeoutInMinutes : 90
12
15
cancelTimeoutInMinutes : 5
13
16
templateContext :
50
53
# Disable Nightly publishing on the main branch
51
54
- ${{ if endsWith(variables['Build.SourceBranchName'], '-stable') }} :
52
55
- script : |
53
- yarn config set npmPublishRegistry "https://registry.npmjs.org"
54
- yarn config set npmAuthToken $(npmAuthToken)
56
+ if [ "$(USE_YARN_FOR_PUBLISH)" = "true" ]; then
57
+ echo "Configuring yarn for npm publishing"
58
+ yarn config set npmPublishRegistry "https://registry.npmjs.org"
59
+ yarn config set npmAuthToken $(npmAuthToken)
60
+ else
61
+ echo "Configuring npm for publishing"
62
+ echo "//registry.npmjs.org/:_authToken=$(npmAuthToken)" > ~/.npmrc
63
+ fi
55
64
node .ado/scripts/prepublish-check.mjs --verbose --tag $(publishTag)
56
65
displayName: Set and validate npm auth
57
66
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
@@ -65,19 +74,33 @@ jobs:
65
74
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
66
75
67
76
- script : |
77
+ set -eox pipefail
68
78
if [[ -f .rnm-publish ]]; then
69
79
# https://github.com/microsoft/react-native-macos/issues/2580
70
80
# `nx release publish` gets confused by the output of RNM's prepack script.
71
- # Let's call `yarn npm publish` directly instead on the packages we want to publish.
81
+ # Let's call publish directly instead on the packages we want to publish.
72
82
# yarn nx release publish --tag $(publishTag) --excludeTaskDependencies
73
- yarn ./packages/virtualized-lists npm publish --tag $(publishTag)
74
- yarn ./packages/react-native npm publish --tag $(publishTag)
83
+ if [ "$(USE_YARN_FOR_PUBLISH)" = "true" ]; then
84
+ echo "Publishing with yarn npm publish"
85
+ yarn ./packages/virtualized-lists npm publish --tag $(publishTag)
86
+ yarn ./packages/react-native npm publish --tag $(publishTag)
87
+ else
88
+ echo "Publishing with npm publish"
89
+ (cd ./packages/virtualized-lists && npm publish --tag $(publishTag))
90
+ (cd ./packages/react-native && npm publish --tag $(publishTag))
91
+ fi
75
92
fi
76
93
displayName: Publish packages
77
94
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
78
95
79
96
- script : |
80
- yarn config unset npmAuthToken
81
- yarn config unset npmPublishRegistry
82
- displayName: Unset npm configuration
97
+ if [ "$(USE_YARN_FOR_PUBLISH)" = "true" ]; then
98
+ echo "Cleaning up yarn npm configuration"
99
+ yarn config unset npmAuthToken || true
100
+ yarn config unset npmPublishRegistry || true
101
+ else
102
+ echo "Cleaning up npm configuration"
103
+ rm -f ~/.npmrc
104
+ fi
105
+ displayName: Remove NPM auth configuration
83
106
condition: always()
0 commit comments