Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

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 }}

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"
}
7 changes: 6 additions & 1 deletion clients/algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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": "./scripts/publish.js"
},
"devDependencies": {
"@babel/core": "7.17.2",
Expand All @@ -25,11 +27,14 @@
"@rollup/plugin-node-resolve": "13.1.3",
"@types/rollup-plugin-node-globals": "1.4.1",
"bundlesize2": "0.0.31",
"execa": "5.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",
"typescript": "4.5.4"
},
"engines": {
Expand Down
37 changes: 37 additions & 0 deletions clients/algoliasearch-client-javascript/scripts/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-commonjs */

const fs = require('fs');
const path = require('path');

const execa = require('execa');
const semver = require('semver');

async function publish() {
await execa.command(
`npm config set "registry.npmjs.org/:_authToken=${process.env.NPM_AUTH_TOKEN}"`,
{
shell: 'bash',
}
);
// Read the local version of `algoliasearch/package.json`
const { version } = JSON.parse(
fs.readFileSync(
path.resolve(__dirname, '..', 'packages', 'algoliasearch', 'package.json')
)
);
// Get tag like `alpha`, `beta`, ...
const tag = semver.prerelease(version)?.[0];

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

publish();
Loading