Skip to content

Commit 7703aa2

Browse files
authored
chore: Use github actions for CI and release-please. (#289)
I will also make a release-please PR and hold merging this until both are ready.
1 parent 26eef1a commit 7703aa2

17 files changed

+183
-93
lines changed

.circleci/config.yml

-26
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Publish Documentation
2+
description: 'Publish documentation to github pages.'
3+
4+
inputs:
5+
github_token:
6+
description: 'The github token to use for committing'
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- uses: launchdarkly/gh-actions/actions/[email protected]
13+
name: 'Publish to Github pages'
14+
with:
15+
docs_path: docs
16+
github_token: ${{ inputs.github_token }}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish to NPM
2+
description: Publish an npm package.
3+
inputs:
4+
prerelease:
5+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
6+
required: false
7+
dry-run:
8+
description: 'Is this a dry run. If so no package will be published.'
9+
required: false
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Publish
15+
shell: bash
16+
run: |
17+
./scripts/publish-npm.sh
18+
env:
19+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
20+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry-run }}

.github/workflows/ci.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- '**.md' #Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [main]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build-test:
15+
strategy:
16+
matrix:
17+
variations: [
18+
# {os: ubuntu-latest, node: latest},
19+
{os: ubuntu-latest, node: 'lts/*'},
20+
]
21+
22+
runs-on: ${{ matrix.variations.os }}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.variations.node }}
29+
registry-url: 'https://registry.npmjs.org'
30+
- name: Install
31+
run: npm install
32+
- name: Build
33+
run: npm run build
34+
- name: Test
35+
run: npm test
36+
- name: Lint
37+
run: npm run lint

.github/workflows/release-please.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
release_created: ${{ steps.release.outputs.release_created }}
13+
steps:
14+
- uses: googleapis/release-please-action@v4
15+
id: release
16+
with:
17+
token: ${{secrets.GITHUB_TOKEN}}
18+
19+
publish-package:
20+
runs-on: ubuntu-latest
21+
needs: ['release-please']
22+
permissions:
23+
id-token: write
24+
contents: write
25+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20.x
32+
registry-url: 'https://registry.npmjs.org'
33+
34+
- uses: launchdarkly/gh-actions/actions/[email protected]
35+
name: 'Get NPM token'
36+
with:
37+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
38+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
39+
40+
- name: Install Dependencies
41+
run: npm install
42+
# Publishing will build because we have a prepublish script.
43+
44+
- id: publish-npm
45+
name: Publish NPM Package
46+
uses: ./.github/actions/publish-npm
47+
with:
48+
dry-run: 'false'
49+
prerelease: 'false'
50+
51+
- name: Build Documentation
52+
run: npm run doc
53+
54+
- id: publish-docs
55+
name: Publish Documentation
56+
uses: ./.github/actions/publish-docs
57+
with:
58+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ docs/build/
1313
yarn.lock
1414
package-lock.json
1515
.npmrc
16+
docs/

.ldrelease/config.yml

-29
This file was deleted.

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "3.3.2"
3+
}

docs/typedoc.js

-17
This file was deleted.

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
reporters: ['default', 'jest-junit'],
2+
reporters: ['default'],
33
moduleFileExtensions: ['ts', 'tsx', 'js'],
44
transform: {
55
'\\.(ts|tsx)$': 'ts-jest',

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@
2727
],
2828
"scripts": {
2929
"test": "jest",
30-
"test:junit": "jest --ci --reporters=default --reporters=jest-junit",
30+
"test:junit": "jest --ci --reporters=default",
3131
"clean": "rimraf lib/*",
3232
"rb": "rollup -c --configPlugin typescript",
33-
"rbw": "yarn rb --watch",
34-
"build": "yarn clean && yarn rb",
33+
"rbw": "npm run rb --watch",
34+
"build": "npm run clean && npm run rb",
3535
"lint": "tslint -p tsconfig.json 'src/**/*.ts*'",
3636
"lint:all": "npm run lint",
3737
"check-typescript": "tsc",
3838
"prepublishOnly": "npm run build",
3939
"prettier": "prettier --write 'src/*.@(js|ts|tsx|json|css)'",
4040
"link-dev": "./link-dev.sh",
41-
"check": "npm i && npm run prettier && npm run lint && tsc && npm run test"
41+
"check": "npm i && npm run prettier && npm run lint && tsc && npm run test",
42+
"doc": "typedoc"
4243
},
4344
"repository": {
4445
"type": "git",
@@ -60,26 +61,25 @@
6061
"@types/react": "^18.0.3",
6162
"@types/react-dom": "^18.0.0",
6263
"@types/react-test-renderer": "^18.0.0",
63-
"esbuild": "^0.21.3",
64-
"jest": "^27.5.1",
65-
"jest-environment-jsdom": "^27.4.4",
64+
"esbuild": "^0.21.3",
65+
"jest": "^29.7.0",
66+
"jest-environment-jsdom": "^29.7.0",
6667
"jest-environment-jsdom-global": "^4.0.0",
67-
"jest-junit": "^16.0.0",
6868
"prettier": "^1.18.2",
6969
"prop-types": "^15.7.2",
7070
"react": "^18.0.0",
7171
"react-dom": "^18.0.0",
7272
"react-test-renderer": "^18.0.0",
73-
"rimraf": "^5.0.7",
73+
"rimraf": "^5.0.9",
7474
"rollup": "^3.26.2",
7575
"rollup-plugin-dts": "^6.1.0",
7676
"rollup-plugin-esbuild": "^6.1.1",
77-
"rollup-plugin-filesize": "^10.0.0",
78-
"ts-jest": "^27.1.1",
77+
"ts-jest": "^29.2.2",
7978
"tslint": "^6.1.3",
8079
"tslint-config-prettier": "^1.18.0",
8180
"tslint-plugin-prettier": "^2.3.0",
82-
"typescript": "^4.5.3"
81+
"typescript": "^4.5.3",
82+
"typedoc": "^0.25.13"
8383
},
8484
"dependencies": {
8585
"hoist-non-react-statics": "^3.3.2",

release-please-config.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bootstrap-sha": "26eef1a9bb65f94489eff6ff7d2cd2abc969c952",
3+
"packages": {
4+
".": {
5+
"release-type": "node"
6+
}
7+
}
8+
}

rollup.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import dts from 'rollup-plugin-dts';
22
import esbuild from 'rollup-plugin-esbuild';
3-
import filesize from 'rollup-plugin-filesize';
43
import json from '@rollup/plugin-json';
54
import resolve from '@rollup/plugin-node-resolve';
65
import terser from '@rollup/plugin-terser';
76

8-
const plugins = [resolve(), esbuild({ target: 'es6' }), json(), terser(), filesize()];
7+
const plugins = [resolve(), esbuild({ target: 'es6' }), json(), terser()];
8+
99
const external = /node_modules/;
1010

1111
export default [

scripts/publish-npm.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
if $LD_RELEASE_IS_DRYRUN ; then
3+
echo "Doing a dry run of publishing."
4+
else
5+
if $LD_RELEASE_IS_PRERELEASE ; then
6+
echo "Publishing with prerelease tag."
7+
npm publish --tag prerelease --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
8+
else
9+
npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
10+
fi
11+
fi

src/__snapshots__/provider.test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
exports[`LDProvider render app 1`] = `
44
<Provider
55
value={
6-
Object {
6+
{
77
"error": undefined,
8-
"flagKeyMap": Object {},
9-
"flags": Object {},
8+
"flagKeyMap": {},
9+
"flags": {},
1010
"ldClient": undefined,
1111
}
1212
}

src/__snapshots__/withLDProvider.test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
exports[`withLDProvider render app 1`] = `
44
<Provider
55
value={
6-
Object {
6+
{
77
"error": undefined,
8-
"flagKeyMap": Object {},
9-
"flags": Object {},
8+
"flagKeyMap": {},
9+
"flags": {},
1010
"ldClient": undefined,
1111
}
1212
}

typedoc.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"name": "launchdarkly-react-client-sdk",
4+
"includeVersion": true,
5+
"entryPoints": [
6+
"src/index.ts",
7+
]
8+
}

0 commit comments

Comments
 (0)