Skip to content

Commit

Permalink
chore(ci): add release process for js repository (#251)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
eunjae-lee and shortcuts authored Mar 21, 2022
1 parent be08ed2 commit 0f9b48f
Show file tree
Hide file tree
Showing 8 changed files with 3,392 additions and 141 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release packages

on:
push:
branches:
- next

jobs:
release:
name: Publish
runs-on: ubuntu-20.04
if: "startsWith(github.event.issue.title, 'chore: release v')"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install Node
uses: actions/setup-node@v2
with:
node-version-file: .nvmrc
cache: yarn

- name: Install JavaScript dependencies
shell: bash
run: yarn install

- name: Build clients
shell: bash
run: yarn build

- name: Publish to NPM
shell: bash
run: yarn release:publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
1 change: 1 addition & 0 deletions clients/algoliasearch-client-javascript/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
768 changes: 768 additions & 0 deletions clients/algoliasearch-client-javascript/.yarn/releases/yarn-3.1.1.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions clients/algoliasearch-client-javascript/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.1.1.cjs
4 changes: 4 additions & 0 deletions clients/algoliasearch-client-javascript/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages": ["packages/*"],
"version": "independent"
}
9 changes: 7 additions & 2 deletions clients/algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "algoliasearch-client-javascript",
"version": "5.0.0",
"workspaces": [
"packages/*"
],
Expand All @@ -13,7 +12,9 @@
"release": "shipjs prepare",
"test:size": "bundlesize",
"test:lint": "eslint . --ext .js,.ts",
"test:types": "yarn tsc --noEmit"
"test:types": "yarn tsc --noEmit",
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --yes",
"release:publish": "ts-node scripts/publish.ts"
},
"devDependencies": {
"@babel/core": "7.17.2",
Expand All @@ -25,11 +26,15 @@
"@rollup/plugin-node-resolve": "13.1.3",
"@types/rollup-plugin-node-globals": "1.4.1",
"bundlesize2": "0.0.31",
"execa": "6.1.0",
"lerna": "4.0.0",
"rollup": "2.67.1",
"rollup-plugin-filesize": "9.1.2",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.31.2",
"semver": "7.3.5",
"ts-node": "10.7.0",
"typescript": "4.5.4"
},
"engines": {
Expand Down
36 changes: 36 additions & 0 deletions clients/algoliasearch-client-javascript/scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fsp from 'fs/promises';
import path from 'path';

import { execaCommand } from 'execa';
import semver from 'semver';

async function publish(): Promise<void> {
// Read the local version of `algoliasearch/package.json`
const { version } = JSON.parse(
(
await fsp.readFile(
path.resolve(
__dirname,
'..',
'packages',
'algoliasearch',
'package.json'
)
)
).toString()
);

// Get tag like `alpha`, `beta`, ...
const tag = semver.prerelease(version)?.[0];

await execaCommand(
`lerna exec --no-bail npm publish --access public ${
tag ? `--tag ${tag}` : ''
}`,
{
shell: 'bash',
}
);
}

publish();
Loading

0 comments on commit 0f9b48f

Please sign in to comment.