Skip to content

Commit

Permalink
Merge pull request #168 from aeagle/split-storybook-build
Browse files Browse the repository at this point in the history
Split storybook build
  • Loading branch information
aeagle authored Apr 21, 2024
2 parents 038342d + 0b8d1ae commit 8c2285d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 16 deletions.
87 changes: 87 additions & 0 deletions azure-pipelines-sb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

pool:
vmImage: "ubuntu-latest"

steps:
- task: Bash@3
displayName: Generate build number tag if required
inputs:
targetType: "inline"
script: |
if [ $(Build.SourceBranch) != "refs/heads/master" ]
then
# Lowercase
tag=$(sed 's/.*/\L&/' <<< $(Build.SourceBranchName))
# Replace non alpha-numeric to -
tag=$(sed 's/[^0-9a-z\-]/-/g' <<< $tag)
# Set the build number in DevOps
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0-$tag"
else
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0"
fi
failOnStderr: true
- task: Bash@3
displayName: Update version number in package.json
inputs:
targetType: "inline"
script: 'sed -i $"s/\"version\": \"[^\"]*\"/\"version\": \"$(Build.BuildNumber)\"/g" .storybook/package.json'
env:
GITVERSIONNUMBER: $(Build.BuildNumber)

- task: Bash@3
displayName: Update version number in react-spaces-storybook package.json
inputs:
targetType: "inline"
script: sed -i "s/0.2.2/$GITVERSIONNUMBER/g" .storybook/package.json
env:
GITVERSIONNUMBER: $(GitVersion.SemVer)

- task: NodeTool@0
inputs:
versionSpec: "20.x"
checkLatest: true
displayName: "Install Node.js"

- task: Cache@2
displayName: Cache node_modules
inputs:
key: 'npm | "$(Agent.OS)" | $(Build.SourcesDirectory)/package-lock.json'
path: $(Build.SourcesDirectory)/node_modules
cacheHitVar: CACHE_RESTORED

- task: Npm@1
displayName: "Install the dependencies"
inputs:
command: custom
verbose: false
customCommand: "ci"
condition: ne(variables.CACHE_RESTORED, 'true')

- script: |
npm test
displayName: "Run tests"
- script: |
npm run build-storybook
displayName: "Build storybook"
- task: CopyFiles@2
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Move storybook package json
inputs:
SourceFolder: ".storybook"
Contents: "package.json"
TargetFolder: "./storybook-static"
OverWrite: true

- task: Npm@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Publish react-spaces-storybook
inputs:
command: "publish"
workingDir: "storybook-static"
publishEndpoint: "NPM"
16 changes: 0 additions & 16 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ steps:
env:
GITVERSIONNUMBER: $(GitVersion.SemVer)

- task: Bash@3
displayName: Update version number in react-spaces-storybook package.json
inputs:
targetType: "inline"
script: sed -i "s/0.2.2/$GITVERSIONNUMBER/g" .storybook/package.json
env:
GITVERSIONNUMBER: $(GitVersion.SemVer)

- task: NodeTool@0
inputs:
versionSpec: "20.x"
Expand Down Expand Up @@ -73,14 +65,6 @@ steps:
TargetFolder: "./storybook-static"
OverWrite: true

- task: Npm@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Publish react-spaces-storybook
inputs:
command: "publish"
workingDir: "storybook-static"
publishEndpoint: "NPM"

- task: Npm@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Publish react-spaces
Expand Down

0 comments on commit 8c2285d

Please sign in to comment.