Skip to content

Commit 8107bc4

Browse files
committed
adding github workflow for publishing packages
1 parent 57a1440 commit 8107bc4

File tree

5 files changed

+100
-51
lines changed

5 files changed

+100
-51
lines changed

.github/workflows/build.yml renamed to .github/workflows/pr.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
name: Build CI
55

66
on:
7-
push:
8-
branches: [main, release/**]
97
pull_request:
108
branches: [main, release/**]
119

@@ -15,16 +13,19 @@ jobs:
1513

1614
strategy:
1715
matrix:
18-
node-version: [10.x]
16+
node-version: [12.x]
1917

2018
steps:
2119
- uses: actions/checkout@v2
2220
- name: Use Node.js ${{ matrix.node-version }}
2321
uses: actions/setup-node@v1
2422
with:
2523
node-version: ${{ matrix.node-version }}
26-
- run: npm i
27-
- run: npm run pack
24+
- run: npm install -g yarn
25+
- run: yarn
26+
- run: yarn build
27+
- run: node .\scripts\setVersion.js --next
28+
- run: yarn run pack
2829
- name: Upload a Build Artifact - package
2930
uses: actions/upload-artifact@v2
3031
with:

.github/workflows/push.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Build CI
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'packages/**'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [12.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
registry-url: 'https://registry.npmjs.org'
27+
- run: npm install -g yarn lerna
28+
- run: yarn
29+
- run: yarn build
30+
- run: node .\scripts\setVersion.js --next
31+
- run: lerna exec --scope @microsoft/* -- "npm publish --tag next"
32+
env:
33+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

azure-pipelines.yml

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,39 @@ steps:
2929
command: custom
3030
verbose: false
3131
customCommand: 'run build'
32-
3332
#- task: Npm@1
3433
# displayName: 'npm test'
3534
# inputs:
3635
# command: custom
3736
# verbose: false
3837
# customCommand: test
39-
40-
- task: PublishTestResults@2
41-
displayName: 'Publish Test Results testResults/junit.xml'
42-
inputs:
43-
testResultsFiles: testResults/junit.xml
44-
condition: succeededOrFailed()
45-
46-
- task: PublishCodeCoverageResults@1
47-
displayName: 'Publish code coverage from $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
48-
inputs:
49-
codeCoverageTool: Cobertura
50-
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
51-
reportDirectory: '$(System.DefaultWorkingDirectory)/coverage'
52-
condition: succeededOrFailed()
53-
54-
- task: DeleteFiles@1
55-
displayName: 'Delete files from $(System.DefaultWorkingDirectory)'
56-
inputs:
57-
SourceFolder: '$(System.DefaultWorkingDirectory)'
58-
Contents: |
59-
.git
60-
node_modules
61-
coverage
62-
testResults
63-
.gitignore
64-
65-
- task: ArchiveFiles@2
66-
displayName: 'Archive $(Build.BinariesDirectory)'
67-
inputs:
68-
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
69-
includeRootFolder: false
70-
archiveFile: '$(Build.ArtifactStagingDirectory)/mgt-$(baseVersionNumber).$(Build.BuildId).zip'
71-
72-
- task: PublishBuildArtifacts@1
73-
displayName: 'Publish Artifact: drop'
38+
# - task: PublishTestResults@2
39+
# displayName: 'Publish Test Results testResults/junit.xml'
40+
# inputs:
41+
# testResultsFiles: testResults/junit.xml
42+
# condition: succeededOrFailed()
43+
# - task: PublishCodeCoverageResults@1
44+
# displayName: 'Publish code coverage from $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
45+
# inputs:
46+
# codeCoverageTool: Cobertura
47+
# summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
48+
# reportDirectory: '$(System.DefaultWorkingDirectory)/coverage'
49+
# condition: succeededOrFailed()
50+
# - task: DeleteFiles@1
51+
# displayName: 'Delete files from $(System.DefaultWorkingDirectory)'
52+
# inputs:
53+
# SourceFolder: '$(System.DefaultWorkingDirectory)'
54+
# Contents: |
55+
# .git
56+
# node_modules
57+
# coverage
58+
# testResults
59+
# .gitignore
60+
# - task: ArchiveFiles@2
61+
# displayName: 'Archive $(Build.BinariesDirectory)'
62+
# inputs:
63+
# rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
64+
# includeRootFolder: false
65+
# archiveFile: '$(Build.ArtifactStagingDirectory)/mgt-$(baseVersionNumber).$(Build.BuildId).zip'
66+
# - task: PublishBuildArtifacts@1
67+
# displayName: 'Publish Artifact: drop'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4+
"version": "2.0.0",
45
"workspaces": [
56
"packages/*",
67
"packages/providers/*",

scripts/setVersion.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var path = require('path'),
2-
fs = require('fs');
1+
var child_process = require('child_process')
2+
var path = require('path');
3+
var fs = require('fs');
4+
var project = require('../package.json');
35

4-
function getPackageJsons(startPath, results) {
6+
const getPackageJsons = (startPath, results) => {
57
startPath = startPath || 'packages';
68
results = results || [];
79
const filter = 'package.json';
@@ -24,7 +26,7 @@ function getPackageJsons(startPath, results) {
2426
return results;
2527
}
2628

27-
function updateMgtDependencyVersion(packages, version) {
29+
const updateMgtDependencyVersion = (packages, version) => {
2830
for (let package of packages) {
2931
const data = fs.readFileSync(package, 'utf8');
3032

@@ -35,12 +37,30 @@ function updateMgtDependencyVersion(packages, version) {
3537
}
3638
}
3739

38-
if (process.argv.length < 3) {
39-
console.log('usage: node setVersion.js VERSION');
40-
return;
41-
}
40+
let version = project.version;
4241

43-
const version = process.argv[2];
42+
if (process.argv.length > 2) {
43+
switch (process.argv[2]) {
44+
case '-n':
45+
case '--next':
46+
// set version from git hash
47+
const shortSha = child_process.execSync('git rev-parse --short HEAD').toString().trim();
48+
version = `${version}-preview.${shortSha}`;
49+
break;
50+
case '-v':
51+
case '--version':
52+
// set version from argument
53+
if (process.argv.length > 3) {
54+
version = process.argv[3];
55+
break;
56+
}
57+
default:
58+
console.log('usage: node setVersion.js');
59+
console.log('usage: node setVersion.js --next');
60+
console.log('usage: node setVersion.js --version [version]');
61+
return;
62+
}
63+
}
4464

45-
packages = getPackageJsons();
65+
const packages = getPackageJsons();
4666
updateMgtDependencyVersion(packages, version);

0 commit comments

Comments
 (0)