Skip to content

Commit b8030f1

Browse files
committed
Split sb npm package build
1 parent 038342d commit b8030f1

File tree

2 files changed

+88
-16
lines changed

2 files changed

+88
-16
lines changed

azure-pipelines-sb.yml

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