-
Notifications
You must be signed in to change notification settings - Fork 10
/
azure-pipelines.yml
230 lines (200 loc) · 7.39 KB
/
azure-pipelines.yml
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
trigger:
branches:
include:
- '*'
exclude:
- dependabot/*
resources:
- repo: self
variables:
TAG: '$(Build.BuildNumber)'
NPM_RC_PATH: '$(Build.Repository.LocalPath)/.npmrc'
AZ_SUBSCRIPTION: 'Managed Services Central Billing'
AZ_ACCOUNT_NAME: 'rhythmuidocs'
CANARY_FEED: https://pkgs.dev.azure.com/dd-managed-services/_packaging/rhythm-ui/npm/registry/
BLOB_PROD: prod
BLOB_CANARY: canary
BLOB_BETA: beta
stages:
##################################################
# BUILD STAGE #
##################################################
- stage: build
displayName: "Build"
jobs:
- job: buildPrimeCache
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node'
- task: DeleteFiles@1
inputs:
sourceFolder: .ruidocs
contents: '*'
# Fix concurrent issue with multiple threads trying to create this folder
- script: |
mkdir -p .ruidocs
displayName: 'Prime Cache'
- script: |
yarn install
yarn bootstrap
displayName: 'Install Dependencies'
# - script: |
# yarn lint
# yarn test
# displayName: 'Running tests'
# If Release, Read app version from root package json
- script: |
if [[ "$(Build.SourceBranch)" == refs/heads/release/* ]]; then
RUI_PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
RUI_SHORT_VERSION=v$(echo $RUI_PACKAGE_VERSION | sed "s/\(\.[0-9]*\)$//" | tr . -)
echo "##vso[task.setvariable variable=RUI_PACKAGE_VERSION]$RUI_PACKAGE_VERSION"
echo "##vso[task.setvariable variable=RUI_SHORT_VERSION]v$RUI_SHORT_VERSION"
elif [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
echo "##vso[task.setvariable variable=RUI_PACKAGE_VERSION]0.0.0-canary-$(TAG)"
echo "##vso[task.setvariable variable=RUI_SHORT_VERSION]canary"
fi
displayName: 'Set Version'
- script: |
yarn build:components
displayName: 'Build Components'
- script: |
if [[ "$(Build.SourceBranch)" == refs/heads/release/* ]]; then
WWW_PATH_PREFIX=$(BLOB_PROD)/$(RUI_SHORT_VERSION) yarn build:site
elif [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
WWW_PATH_PREFIX=$(BLOB_CANARY) yarn build:site
else
yarn build:site
fi
displayName: 'Build Docs'
- script: |
if [[ "$(Build.SourceBranch)" == refs/heads/release/* ]]; then
STORYBOOK_PATH_PREFIX=$(BLOB_PROD)/$(RUI_SHORT_VERSION)/react yarn build:storybook:react
elif [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
STORYBOOK_PATH_PREFIX=$(BLOB_CANARY)/react yarn build:storybook:react
else
yarn build:storybook:react
fi
displayName: 'Build React Docs'
# Disabled for now until we pick up vue again
# - script: |
# yarn build:storybook:vue
# displayName: 'Build react docs'
- script: |
if [[ "$(Build.SourceBranch)" == refs/heads/release/* ]]; then
node_modules/.bin/lerna exec --scope @rhythm-ui/* --stream --no-private -- "npm pack"
yarn lerna version $(RUI_PACKAGE_VERSION)-beta.$(TAG) --no-git-tag-version --no-push --yes
node_modules/.bin/lerna exec --scope @rhythm-ui/* --stream --no-private -- "npm pack"
elif [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
yarn lerna version 0.0.0-canary.$(TAG) --no-git-tag-version --no-push --yes
node_modules/.bin/lerna exec --scope @rhythm-ui/* --stream --no-private -- "npm pack"
fi
displayName: 'Pack Components'
- task: CopyFiles@2
displayName: 'Stage all NPM Packages'
inputs:
contents: |
components/*/*.tgz
adapters/react/*/*.tgz
adapters/vue/*/*.tgz
system/*/*.tgz
targetFolder: $(Build.ArtifactStagingDirectory)/npm
flattenFolders: true
- task: ArchiveFiles@2
displayName: 'Stage Docs'
inputs:
rootFolderOrFile: './www/public'
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/docs/site.zip'
replaceExistingArchive: true
- task: ArchiveFiles@2
displayName: 'Stage React Docs'
inputs:
rootFolderOrFile: './.out-react'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/docs/react.zip'
replaceExistingArchive: true
# - task: ArchiveFiles@2
# inputs:
# rootFolderOrFile: './.out-vue'
# archiveType: 'zip'
# archiveFile: '$(Build.ArtifactStagingDirectory)/docs/vue.zip'
# replaceExistingArchive: true
# displayName: Stage Vue Docs
# Save reference to build variables
# (This is a backwards way because azure doesn't allow release variables to be shared between stages)
- script: |
echo -e "RUI_PACKAGE_VERSION=$(RUI_PACKAGE_VERSION)\nRUI_SHORT_VERSION=$(RUI_SHORT_VERSION)" > $(Build.ArtifactStagingDirectory)/variables.txt
chmod +x $(Build.ArtifactStagingDirectory)/variables.txt
displayName: 'Stage Build Out Variables'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: drop
displayName: 'Publish Build Artifacts'
##################################################
# PUBLISH CANARY STAGE #
##################################################
- stage: Canary
displayName: 'Publish Canary'
dependsOn: build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- deployment: DeployCanary
displayName: Deploy Canary
pool:
vmImage: 'ubuntu-latest'
environment: rhythm-ui-canary
strategy:
runOnce:
deploy:
steps:
# Connect to local npm artifact feed for publish
- script: |
printf "@rhythm-ui:registry=$(CANARY_FEED)\nalways-auth=true" > $(NPM_RC_PATH)
displayName: 'Connect to local npm feed'
- task: npmAuthenticate@0
inputs:
workingFile: $(NPM_RC_PATH)
- template: scripts/azure/deploy.yml
parameters:
name: 'deployCanary'
azBlobDestination: $(BLOB_CANARY)
npmDeployPattern: '*.tgz'
##################################################
# PUBLISH BETA STAGE #
##################################################
- stage: Beta
displayName: 'Publish Beta'
dependsOn: build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))
jobs:
- deployment: DeployBeta
displayName: Deploy Web App
pool:
vmImage: 'ubuntu-latest'
environment: rhythm-ui-beta
strategy:
runOnce:
deploy:
steps:
- template: scripts/azure/deploy.yml
parameters:
name: 'deployBeta'
azBlobDestination: $(BLOB_BETA)
npmDeployPattern: '*beta.tgz'
npmFlags: --beta
# - stage: deployProd
# displayName: "Deploy Prod"
# dependsOn: deployBeta
# condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')
# jobs:
# - job: Linux
# pool:
# vmImage: 'ubuntu-latest'
# steps:
# - template: scripts/azure/deploy.yml