chore: migrate to changesets and github actions
This commit is contained in:
parent
bb4190d521
commit
258ae817cd
10 changed files with 720 additions and 3106 deletions
9
.changeset/config.json
Normal file
9
.changeset/config.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@1.1.0/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"linked": [],
|
||||
"access": "public",
|
||||
"baseBranch": "master",
|
||||
"updateInternalDependencies": "patch"
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
# Javascript Node CircleCI 2.0 configuration file
|
||||
#
|
||||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
||||
#
|
||||
version: 2
|
||||
|
||||
defaults: &defaults
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: circleci/node:10.18.1-browsers
|
||||
|
||||
jobs:
|
||||
test:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v3-dependencies-{{ checksum "package.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v3-dependencies-
|
||||
- run: yarn install --frozen-lockfile
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v2-dependencies-{{ checksum "package.json" }}
|
||||
|
||||
# run lint
|
||||
- run: npm run lint
|
||||
|
||||
# run test locally first
|
||||
- run: npm run test
|
||||
|
||||
# make sure size is ok
|
||||
- run: npm run bundlesize
|
||||
|
||||
# run compatibility tests for multiple browser via browserstack
|
||||
# disabled until we can safely test multiple browsers
|
||||
# - run: npm run test:bs
|
||||
|
||||
- persist_to_workspace:
|
||||
root: ~/repo
|
||||
paths: .
|
||||
deploy:
|
||||
<<: *defaults
|
||||
steps:
|
||||
# will add github as known host
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: ~/repo
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- 'df:41:a0:89:d0:a1:30:7d:08:38:d6:65:73:61:a4:ec'
|
||||
- run:
|
||||
name: Authenticate with registry
|
||||
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||
- run: git config --global user.email circleci@circleci
|
||||
- run: git config --global user.name CircleCI
|
||||
- run: npm run build:types
|
||||
- run:
|
||||
name: Publish package
|
||||
command: "./node_modules/.bin/lerna publish --message 'chore: release new versions' --exact --yes"
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
test-deploy:
|
||||
jobs:
|
||||
- test
|
||||
- deploy:
|
||||
requires:
|
||||
- test
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
52
.github/workflows/release.yml
vendored
Normal file
52
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.changeset/*.md'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@master
|
||||
with:
|
||||
node-version: 12.x
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build
|
||||
run: yarn build:types
|
||||
|
||||
- name: Changeset version
|
||||
run: yarn changeset version
|
||||
|
||||
- name: Format
|
||||
run: yarn format
|
||||
|
||||
- name: Commit version updates
|
||||
run: |
|
||||
git config --local user.email "lion@ing.com"
|
||||
git config --local user.name "Lion Bot"
|
||||
- run: git add .
|
||||
- run: "git commit -m 'chore: release new versions'"
|
||||
|
||||
- name: Release to NPM
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: yarn changeset publish
|
||||
|
||||
- name: Push commits and tags to GitHub
|
||||
run: git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} --follow-tags
|
||||
30
.github/workflows/verify.yml
vendored
Normal file
30
.github/workflows/verify.yml
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
name: Verify changes
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
name: Verify changes
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
|
||||
- name: Test
|
||||
run: yarn test
|
||||
|
||||
- name: Bundlesize
|
||||
run: yarn bundlesize
|
||||
18
lerna.json
18
lerna.json
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"ignoreChanges": [
|
||||
"packages/*/test/**",
|
||||
"**/*.md",
|
||||
"**/*.mdx"
|
||||
],
|
||||
"version": "independent",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
"publish": {
|
||||
"conventionalCommits": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,9 +28,10 @@
|
|||
"test:browser": "wtr \"packages/**/*/test/**/*.test.js\" --coverage",
|
||||
"test:browser:watch": "wtr \"packages/**/*/test/**/*.test.js\" --watch",
|
||||
"test:browserstack": "wtr --config ./web-test-runner-browserstack.config.js \"packages/form-core/test/**/*.test.js\"",
|
||||
"test:node": "lerna run test:node"
|
||||
"test:node": "node scripts/workspaces-scripts.mjs run test:node"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.9.2",
|
||||
"@commitlint/cli": "^7.0.0",
|
||||
"@commitlint/config-conventional": "^7.0.0",
|
||||
"@mdjs/core": "^0.3.1",
|
||||
|
|
@ -49,11 +50,12 @@
|
|||
"babel-polyfill": "^6.26.0",
|
||||
"bundlesize": "^0.17.1",
|
||||
"chai": "^4.2.0",
|
||||
"chalk": "^4.1.0",
|
||||
"concurrently": "^5.2.0",
|
||||
"eclint": "^2.8.1",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"husky": "^1.0.0",
|
||||
"lerna": "3.4.3",
|
||||
"lint-staged": "^10.0.0",
|
||||
"markdownlint-cli": "^0.17.0",
|
||||
"mocha": "^7.1.1",
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||
"@typescript-eslint/typescript-estree": "^2.0.0",
|
||||
"anymatch": "^3.1.1",
|
||||
"chalk": "^2.4.2",
|
||||
"chalk": "^4.1.0",
|
||||
"commander": "^2.20.0",
|
||||
"deepmerge": "^4.0.0",
|
||||
"es-dev-server": "^1.18.1",
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/* eslint-disable consistent-return, no-console */
|
||||
const fs = require('fs');
|
||||
|
||||
function escapeRegExp(text) {
|
||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
}
|
||||
|
||||
const filePath = `${process.cwd()}/README.md`;
|
||||
const findPattern = escapeRegExp("[//]: # 'AUTO INSERT HEADER PREPUBLISH'");
|
||||
const text = `
|
||||
> ## 🛠 Status: Pilot Phase
|
||||
> Lion Web Components are still in an early alpha stage; they should not be considered production ready yet.
|
||||
>
|
||||
> The goal of our pilot phase is to gather feedback from a private group of users.
|
||||
> Therefore, during this phase, we kindly ask you to:
|
||||
> - not publicly promote or link us yet: (no tweets, blog posts or other forms of communication about Lion Web Components)
|
||||
> - not publicly promote or link products derived from/based on Lion Web Components
|
||||
>
|
||||
> As soon as Pilot Phase ends we will let you know (feel free to subscribe to this issue https://github.com/ing-bank/lion/issues/1)
|
||||
`.trim();
|
||||
|
||||
fs.readFile(filePath, 'utf8', (readError, data) => {
|
||||
if (readError) {
|
||||
return console.log(readError);
|
||||
}
|
||||
|
||||
const result = data.replace(new RegExp(findPattern), text);
|
||||
fs.writeFile(filePath, result, 'utf8', writeError => {
|
||||
if (writeError) {
|
||||
return console.log(writeError);
|
||||
}
|
||||
});
|
||||
});
|
||||
70
scripts/workspaces-scripts.mjs
Normal file
70
scripts/workspaces-scripts.mjs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* eslint-disable */
|
||||
import fs from 'fs';
|
||||
import { join, dirname, basename } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import concurrently from 'concurrently';
|
||||
import chalk from 'chalk';
|
||||
|
||||
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
||||
const script = process.argv[process.argv.length - 1];
|
||||
|
||||
function findPackagesWithScript(directory) {
|
||||
const packages = [];
|
||||
|
||||
for (const name of fs.readdirSync(directory)) {
|
||||
const pkgPath = join(directory, name);
|
||||
const pkgJsonPath = join(pkgPath, 'package.json');
|
||||
|
||||
if (fs.existsSync(pkgJsonPath)) {
|
||||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
||||
|
||||
if (pkgJson && pkgJson.scripts && pkgJson.scripts[script]) {
|
||||
packages.push(pkgPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
const packagesDir = join(moduleDir, '..', 'packages');
|
||||
|
||||
const packagesWithScript = [...findPackagesWithScript(packagesDir)];
|
||||
|
||||
const commands = packagesWithScript.map(pkgPath => ({
|
||||
name: basename(pkgPath),
|
||||
command: `cd ${pkgPath} && yarn ${script}`,
|
||||
}));
|
||||
|
||||
concurrently(commands, { maxProcesses: 5 })
|
||||
.then(() => {
|
||||
console.log();
|
||||
console.log(
|
||||
chalk.green(
|
||||
`Successfully executed command ${chalk.yellow(script)} for packages: ${chalk.yellow(
|
||||
commands.map(c => c.name).join(', '),
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
console.log();
|
||||
})
|
||||
.catch(error => {
|
||||
if (error instanceof Error) {
|
||||
console.error(error);
|
||||
} else if (Array.isArray(error)) {
|
||||
const failedPackages = error
|
||||
.map((code, i) => (code === 1 ? commands[i].name : null))
|
||||
.filter(_ => _)
|
||||
.join(', ');
|
||||
console.log();
|
||||
console.log(
|
||||
chalk.red(
|
||||
`Failed to execute command ${chalk.yellow(script)} for packages: ${chalk.yellow(
|
||||
failedPackages,
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Reference in a new issue