Skip to content

Commit

Permalink
[ado] Fix dist-tag determination (facebook#583)
Browse files Browse the repository at this point in the history
Uses a different approach that relies on runtime determination instead
of compile time.
  • Loading branch information
alloy authored Sep 8, 2020
1 parent 21e63df commit 5a3c0a6
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# It is expected that a `latestStableBranch` variable is set in the pipeline's settings:
# https://dev.azure.com/ms/react-native/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=221

# This file defines the build steps to publish a release
name: $(Date:yyyyMMdd).$(Rev:.r)

Expand All @@ -13,16 +16,6 @@ trigger:

pr: none

# It is expected that a `latestStableBranch` variable is set in the pipeline's settings:
# https://dev.azure.com/ms/react-native/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=221
variables:
${{ if eq(variables['Build.SourceBranchName'], variables['latestStableBranch']) }}:
npmDistTag: latest
${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
npmDistTag: canary
${{ if and(ne(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.SourceBranchName'], variables['latestStableBranch'])) }}:
npmDistTag: v${{variables['Build.SourceBranchName']}}

jobs:
- job: RNGithubNpmJSPublish
displayName: React-Native GitHub Publish to npmjs.org
Expand All @@ -38,6 +31,22 @@ jobs:
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- script: exit 1
displayName: Validate variables
condition: eq(variables.latestStableBranch, '')

- script: echo '##vso[task.setvariable variable=npmDistTag]latest'
displayName: Set dist-tag to latest
condition: eq(variables['Build.SourceBranchName'], variables.latestStableBranch)

- script: echo '##vso[task.setvariable variable=npmDistTag]canary'
displayName: Set dist-tag to canary
condition: eq(variables['Build.SourceBranchName'], 'master')

- script: echo '##vso[task.setvariable variable=npmDistTag]v${{variables['Build.SourceBranchName']}}'
displayName: Set dist-tag to v0.x-stable
condition: and(ne(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.SourceBranchName'], variables.latestStableBranch))

- task: CmdLine@2
displayName: npm install
inputs:
Expand All @@ -47,16 +56,16 @@ jobs:
displayName: Bump stable package version
inputs:
script: node .ado/bumpFileVersions.js
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
condition: ne(variables['Build.SourceBranchName'], 'master')

- task: CmdLine@2
displayName: Bump canary package version
inputs:
script: node scripts/bump-oss-version.js --nightly
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
condition: eq(variables['Build.SourceBranchName'], 'master')

- script: npm publish --tag ${{variables.npmDistTag}} --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$(npmAuthToken)
displayName: Publish ${{variables.npmDistTag}} react-native-macos to npmjs.org
- script: npm publish --tag $(npmDistTag) --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$(npmAuthToken)
displayName: Publish react-native-macos to npmjs.org

- task: CmdLine@2
displayName: 'Tag published release'
Expand All @@ -67,7 +76,7 @@ jobs:
BUILD_SOURCEBRANCH: $(Build.SourceBranch)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
githubApiToken: $(githubApiToken)
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
condition: ne(variables['Build.SourceBranchName'], 'master')


- job: RNMacOSInitNpmJSPublish
Expand Down

0 comments on commit 5a3c0a6

Please sign in to comment.