Skip to content

chore(ci): add release process for js repository #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}

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