Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit e643a11

Browse files
author
Amir Blum
authored
ci: change publish workflow to lerna (#52)
1 parent 1640aa0 commit e643a11

File tree

12 files changed

+49
-45
lines changed

12 files changed

+49
-45
lines changed

.github/workflows/publish.yml

+14-20
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Publish
33
on:
44
workflow_dispatch:
55
inputs:
6-
packageName:
7-
description: Which package to publish
8-
required: true
96
semanticVersion:
107
description: 'Semantic Version [major | minor | patch ]'
118
required: true
@@ -22,6 +19,8 @@ jobs:
2219
with:
2320
token: ${{ secrets.ADMIN_TOKEN }}
2421
ref: 'master'
22+
# pulls all commits (needed for lerna / semantic release to correctly version)
23+
fetch-depth: '0'
2524

2625
- uses: actions/setup-node@v1
2726
with:
@@ -33,26 +32,21 @@ jobs:
3332
git config --global user.name '@aspecto-system'
3433
git config --global user.email '[email protected]'
3534
36-
- name: Install node modules
37-
run: yarn --cwd packages/${{ github.event.inputs.packageName }}
35+
- name: Install Packages
36+
run: yarn install
3837

39-
- name: Bump Version
38+
- name: Authenticate with Registry
4039
run: |
41-
yarn config set version-git-message "chore(release ${{ github.event.inputs.packageName }}) - publish v%s"
42-
yarn --cwd packages/${{ github.event.inputs.packageName }} version --${{ github.event.inputs.semanticVersion }} --no-commit-hooks
43-
node version-update.js ${{ github.event.inputs.packageName }}
44-
45-
- name: Build
46-
run: yarn --cwd packages/${{ github.event.inputs.packageName }} build
47-
48-
- name: Publish to NPM
49-
run: yarn --cwd packages/${{ github.event.inputs.packageName }} publish
40+
yarn logout
41+
echo "registry=http://registry.npmjs.org/" >> .npmrc
42+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
43+
npm whoami
5044
env:
51-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5246

53-
- name: Push Changes
47+
- name: Publish package
5448
run: |
55-
git add .
56-
git commit --amend --no-edit
57-
git push
49+
yarn publish:ci ${{ github.event.inputs.semanticVersion }}
50+
env:
51+
GH_TOKEN: ${{ secrets.ADMIN_TOKEN }}
5852

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"test": "lerna run test",
66
"build": "lerna run build",
77
"postinstall": "lerna bootstrap",
8-
"prettier": "prettier --config .prettierrc.yml --write \"**/*.{ts,tsx,js,jsx,json}\""
8+
"prettier": "prettier --config .prettierrc.yml --write \"**/*.{ts,tsx,js,jsx,json}\"",
9+
"version:update": "lerna run version:update",
10+
"version": "git add packages/**/version.ts",
11+
"publish:ci": "lerna publish --yes --allow-branch master --create-release github --conventionalCommits"
912
},
1013
"devDependencies": {
1114
"husky": "^4.3.6",
@@ -27,4 +30,4 @@
2730
"prettier --write"
2831
]
2932
}
30-
}
33+
}

packages/plugin-aws-sdk/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"build": "tsc",
2525
"prepare": "yarn run build",
2626
"test": "jest",
27-
"watch": "tsc -w"
27+
"watch": "tsc -w",
28+
"version:update": "node ../../scripts/version-update.js",
29+
"version": "yarn run version:update"
2830
},
2931
"bugs": {
3032
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// this is autogenerated file, see version-update.js
1+
// this is autogenerated file, see scripts/version-update.js
22
export const VERSION = '0.1.1';

packages/plugin-kafkajs/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"build": "tsc",
2525
"prepare": "yarn run build",
2626
"test": "jest",
27-
"watch": "tsc -w"
27+
"watch": "tsc -w",
28+
"version:update": "node ../../scripts/version-update.js",
29+
"version": "yarn run version:update"
2830
},
2931
"bugs": {
3032
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// this is autogenerated file, see version-update.js
1+
// this is autogenerated file, see scripts/version-update.js
22
export const VERSION = '0.1.1';

packages/plugin-sequelize/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"build": "tsc",
3030
"prepare": "yarn run build",
3131
"test": "jest",
32-
"watch": "tsc -w"
32+
"watch": "tsc -w",
33+
"version:update": "node ../../scripts/version-update.js",
34+
"version": "yarn run version:update"
3335
},
3436
"bugs": {
3537
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// this is autogenerated file, see version-update.js
1+
// this is autogenerated file, see scripts/version-update.js
22
export const VERSION = '0.1.1';

packages/plugin-typeorm/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"build": "tsc",
2525
"prepare": "yarn run build",
2626
"test": "jest",
27-
"watch": "tsc -w"
27+
"watch": "tsc -w",
28+
"version:update": "node ../../scripts/version-update.js",
29+
"version": "yarn run version:update"
2830
},
2931
"bugs": {
3032
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// this is autogenerated file, see version-update.js
1+
// this is autogenerated file, see scripts/version-update.js
22
export const VERSION = '0.1.0';

scripts/version-update.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs');
2+
const os = require('os');
3+
const path = require('path');
4+
5+
const appRoot = process.cwd();
6+
const packageJsonUrl = path.resolve(`${appRoot}/package.json`);
7+
const pjson = require(packageJsonUrl);
8+
9+
const content = `// this is autogenerated file, see scripts/version-update.js
10+
export const VERSION = '${pjson.version}';
11+
`;
12+
13+
const fileUrl = path.join(appRoot, 'src', 'version.ts');
14+
fs.writeFileSync(fileUrl, content.replace(/\n/g, os.EOL));

version-update.js

-15
This file was deleted.

0 commit comments

Comments
 (0)