Skip to content

Commit 8c2285d

Browse files
authored
Merge pull request #168 from aeagle/split-storybook-build
Split storybook build
2 parents 038342d + 0b8d1ae commit 8c2285d

File tree

2 files changed

+87
-16
lines changed

2 files changed

+87
-16
lines changed

azure-pipelines-sb.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Node.js with React
2+
# Build a Node.js project that uses React.
3+
# Add steps that analyze code, save build artifacts, deploy, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
5+
6+
pool:
7+
vmImage: "ubuntu-latest"
8+
9+
steps:
10+
- task: Bash@3
11+
displayName: Generate build number tag if required
12+
inputs:
13+
targetType: "inline"
14+
script: |
15+
if [ $(Build.SourceBranch) != "refs/heads/master" ]
16+
then
17+
# Lowercase
18+
tag=$(sed 's/.*/\L&/' <<< $(Build.SourceBranchName))
19+
# Replace non alpha-numeric to -
20+
tag=$(sed 's/[^0-9a-z\-]/-/g' <<< $tag)
21+
# Set the build number in DevOps
22+
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0-$tag"
23+
else
24+
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0"
25+
fi
26+
failOnStderr: true
27+
- task: Bash@3
28+
displayName: Update version number in package.json
29+
inputs:
30+
targetType: "inline"
31+
script: 'sed -i $"s/\"version\": \"[^\"]*\"/\"version\": \"$(Build.BuildNumber)\"/g" .storybook/package.json'
32+
env:
33+
GITVERSIONNUMBER: $(Build.BuildNumber)
34+
35+
- task: Bash@3
36+
displayName: Update version number in react-spaces-storybook package.json
37+
inputs:
38+
targetType: "inline"
39+
script: sed -i "s/0.2.2/$GITVERSIONNUMBER/g" .storybook/package.json
40+
env:
41+
GITVERSIONNUMBER: $(GitVersion.SemVer)
42+
43+
- task: NodeTool@0
44+
inputs:
45+
versionSpec: "20.x"
46+
checkLatest: true
47+
displayName: "Install Node.js"
48+
49+
- task: Cache@2
50+
displayName: Cache node_modules
51+
inputs:
52+
key: 'npm | "$(Agent.OS)" | $(Build.SourcesDirectory)/package-lock.json'
53+
path: $(Build.SourcesDirectory)/node_modules
54+
cacheHitVar: CACHE_RESTORED
55+
56+
- task: Npm@1
57+
displayName: "Install the dependencies"
58+
inputs:
59+
command: custom
60+
verbose: false
61+
customCommand: "ci"
62+
condition: ne(variables.CACHE_RESTORED, 'true')
63+
64+
- script: |
65+
npm test
66+
displayName: "Run tests"
67+
68+
- script: |
69+
npm run build-storybook
70+
displayName: "Build storybook"
71+
72+
- task: CopyFiles@2
73+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
74+
displayName: Move storybook package json
75+
inputs:
76+
SourceFolder: ".storybook"
77+
Contents: "package.json"
78+
TargetFolder: "./storybook-static"
79+
OverWrite: true
80+
81+
- task: Npm@1
82+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
83+
displayName: Publish react-spaces-storybook
84+
inputs:
85+
command: "publish"
86+
workingDir: "storybook-static"
87+
publishEndpoint: "NPM"

azure-pipelines.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ steps:
2323
env:
2424
GITVERSIONNUMBER: $(GitVersion.SemVer)
2525

26-
- task: Bash@3
27-
displayName: Update version number in react-spaces-storybook package.json
28-
inputs:
29-
targetType: "inline"
30-
script: sed -i "s/0.2.2/$GITVERSIONNUMBER/g" .storybook/package.json
31-
env:
32-
GITVERSIONNUMBER: $(GitVersion.SemVer)
33-
3426
- task: NodeTool@0
3527
inputs:
3628
versionSpec: "20.x"
@@ -73,14 +65,6 @@ steps:
7365
TargetFolder: "./storybook-static"
7466
OverWrite: true
7567

76-
- task: Npm@1
77-
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
78-
displayName: Publish react-spaces-storybook
79-
inputs:
80-
command: "publish"
81-
workingDir: "storybook-static"
82-
publishEndpoint: "NPM"
83-
8468
- task: Npm@1
8569
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
8670
displayName: Publish react-spaces

0 commit comments

Comments
 (0)