-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
118 lines (100 loc) · 3.21 KB
/
azure-pipelines.yml
File metadata and controls
118 lines (100 loc) · 3.21 KB
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
# Trigger CI automatically whenever main branch is changed
name: Angular Pubsub Azure CI Pipeline
pool:
vmImage: "ubuntu-latest"
strategy:
matrix:
node_14_x:
node_version: 14.x
# node_14_x:
# node_version: 14.x
variables:
AUTH_NPMTOKEN: $(NPM_TOKEN) # Mapping secret var
AUTH_GHTOKEN: $(GH_TOKEN) # Mapping secret var
IS_PULLREQUEST: $[eq(variables['Build.Reason'], 'PullRequest')]
NPM_CACHE_DIR: $(PIPELINE_CACHE_DIR)
trigger:
- main
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
- task: Cache@2 # Cache Node packages on build agent
displayName: "Cache npm Dependencies"
inputs:
key: "**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json"
path: $(NPM_CACHE_DIR)
cacheHitVar: CacheRestored
- task: Npm@1 # Install npm packages on your build agent
displayName: "Npm CI"
inputs:
command: ci
verbose: false
condition: eq(variables['CacheRestored'],False)
- script: npm run test:ci # Run unit tests
enabled: true
displayName: Test
- task: PublishTestResults@2 # Publish test results
displayName: Test Report
enabled: true
inputs:
testResultsFormat: "JUnit"
testResultsFiles: "./coverage/fsms-angular-pubsub/test-report.xml"
mergeTestResults: true
condition: succeededOrFailed()
- task: PublishCodeCoverageResults@1 # Publish code coverage results
enabled: true
displayName: Code Coverage
inputs:
codeCoverageTool: "Cobertura"
summaryFileLocation: "./coverage/fsms-angular-pubsub/cobertura-coverage.xml"
condition: succeededOrFailed()
# Build Angular Lib -->
- script: npm run build:ci # Build Angular Project
displayName: Build
enabled: true
# Update Package JSON Version & Build Number -->
- script: |
export num=$(node ./tools/version.js $(Build.BuildId))
echo "##vso[build.updatebuildnumber]$num"
displayName: Update Version
- script: echo $(Build.BuildNumber)
- script: npm run changelog # Change Log
displayName: Changelog
- script: npm run copyfiles # Copy Changelogs
displayName: Copy Files
# Publishing NPM module to Registry -->
- script: | # Publish a module to a npm registry
npm config set //registry.npmjs.org/:_authToken=$(AUTH_NPMTOKEN)
npm config set scope "@fsms"
# npm config list
# npm --version
npm publish --access public
displayName: Publish NPM
workingDirectory: "./dist/fsms-angular-pubsub"
condition: |
and(
succeeded(),
ne(variables['IS_PULLREQUEST'], 'true')
)
- task: CopyFiles@2
displayName: 'Copy NPMRC'
enabled: true
inputs:
SourceFolder: '$(Build.SourcesDirectory)/.github'
TargetFolder: "./dist/fsms-angular-pubsub"
contents: ".npmrc"
- task: npmAuthenticate@0
enabled: false
inputs:
workingFile: "./dist/fsms-angular-pubsub/.npmrc"
- script: | # Publish a module to a github npm registry
npm publish --access public
enabled: false
displayName: Publish GitHub
workingDirectory: "./dist/fsms-angular-pubsub"
condition: |
and(
succeeded(),
ne(variables['IS_PULLREQUEST'], 'true')
)