88 variables :
99 - name : BUILDSECMON_OPT_IN
1010 value : true
11+ - name : USE_YARN_FOR_PUBLISH
12+ value : false
13+
1114 timeoutInMinutes : 90
1215 cancelTimeoutInMinutes : 5
1316 templateContext :
5053 # Disable Nightly publishing on the main branch
5154 - ${{ if endsWith(variables['Build.SourceBranchName'], '-stable') }} :
5255 - 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
5564 node .ado/scripts/prepublish-check.mjs --verbose --tag $(publishTag)
5665 displayName: Set and validate npm auth
5766 condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
@@ -65,19 +74,33 @@ jobs:
6574 condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
6675
6776 - script : |
77+ set -eox pipefail
6878 if [[ -f .rnm-publish ]]; then
6979 # https://github.com/microsoft/react-native-macos/issues/2580
7080 # `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.
7282 # 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
7592 fi
7693 displayName: Publish packages
7794 condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
7895
7996 - 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
83106 condition: always()
0 commit comments