Skip to content

Commit 853c388

Browse files
chore(ci): add release process for js repository (#251)
* chore(ci): add release process for js repository * chore: rename * chore: update github action * chore: restore test version * chore: pin devDep * chore: clean up code * chore: convert to typescript * chore: remove version from umbrella package.json for js packages * Update clients/algoliasearch-client-javascript/scripts/publish.ts Co-authored-by: Clément Vannicatte <[email protected]> * chore: include .npmrc Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 0d80bc3 commit 853c388

File tree

7 files changed

+3389
-141
lines changed

7 files changed

+3389
-141
lines changed

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release packages
2+
3+
on:
4+
push:
5+
branches:
6+
- next
7+
8+
jobs:
9+
release:
10+
name: Publish
11+
runs-on: ubuntu-20.04
12+
if: "startsWith(github.event.issue.title, 'chore: release v')"
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Install Node
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version-file: .nvmrc
22+
cache: yarn
23+
24+
- name: Install JavaScript dependencies
25+
shell: bash
26+
run: yarn install
27+
28+
- name: Build clients
29+
shell: bash
30+
run: yarn build
31+
32+
- name: Publish to NPM
33+
shell: bash
34+
run: yarn release:publish
35+
env:
36+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

algoliasearch-client-javascript/.yarn/releases/yarn-3.1.1.cjs

+768
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import fsp from 'fs/promises';
2+
import path from 'path';
3+
4+
import { execaCommand } from 'execa';
5+
import semver from 'semver';
6+
7+
async function publish(): Promise<void> {
8+
// Read the local version of `algoliasearch/package.json`
9+
const { version } = JSON.parse(
10+
(
11+
await fsp.readFile(
12+
path.resolve(
13+
__dirname,
14+
'..',
15+
'packages',
16+
'algoliasearch',
17+
'package.json'
18+
)
19+
)
20+
).toString()
21+
);
22+
23+
// Get tag like `alpha`, `beta`, ...
24+
const tag = semver.prerelease(version)?.[0];
25+
26+
await execaCommand(
27+
`lerna exec --no-bail npm publish --access public ${
28+
tag ? `--tag ${tag}` : ''
29+
}`,
30+
{
31+
shell: 'bash',
32+
}
33+
);
34+
}
35+
36+
publish();

lerna.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"packages": ["packages/*"],
3+
"version": "independent"
4+
}

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "algoliasearch-client-javascript",
3-
"version": "5.0.0",
43
"workspaces": [
54
"packages/*"
65
],
@@ -13,7 +12,9 @@
1312
"release": "shipjs prepare",
1413
"test:size": "bundlesize",
1514
"test:lint": "eslint . --ext .js,.ts",
16-
"test:types": "yarn tsc --noEmit"
15+
"test:types": "yarn tsc --noEmit",
16+
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --yes",
17+
"release:publish": "ts-node scripts/publish.ts"
1718
},
1819
"devDependencies": {
1920
"@babel/core": "7.17.2",
@@ -25,11 +26,15 @@
2526
"@rollup/plugin-node-resolve": "13.1.3",
2627
"@types/rollup-plugin-node-globals": "1.4.1",
2728
"bundlesize2": "0.0.31",
29+
"execa": "6.1.0",
30+
"lerna": "4.0.0",
2831
"rollup": "2.67.1",
2932
"rollup-plugin-filesize": "9.1.2",
3033
"rollup-plugin-node-globals": "1.4.0",
3134
"rollup-plugin-terser": "7.0.2",
3235
"rollup-plugin-typescript2": "0.31.2",
36+
"semver": "7.3.5",
37+
"ts-node": "10.7.0",
3338
"typescript": "4.5.4"
3439
},
3540
"engines": {

0 commit comments

Comments
 (0)