Skip to content

Commit 98c38cb

Browse files
committed
add ci tests and release
1 parent b0212bb commit 98c38cb

File tree

2 files changed

+77
-4
lines changed

2 files changed

+77
-4
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: chunks CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- v*
10+
11+
jobs:
12+
main:
13+
env:
14+
BASE_REPO_OWNER: MegafonWebLab
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: '14.x'
25+
registry-url: 'https://registry.npmjs.org'
26+
27+
- name: Install dependencies
28+
run: yarn install --frozen-lockfile
29+
30+
- name: Typecheck
31+
run: yarn typecheck
32+
33+
- name: Tests
34+
run: yarn test
35+
36+
- name: Build
37+
run: yarn build
38+
39+
- name: Define branch purpose
40+
id: branch
41+
run: |
42+
if
43+
[ ${{ startsWith(github.ref, 'refs/tags/v') }} = true ] &&
44+
[ ${{ github.repository_owner }} = ${{ env.BASE_REPO_OWNER }} ];
45+
then
46+
echo ::set-output name=should_release::true
47+
else
48+
echo ::set-output name=should_release::false
49+
fi
50+
51+
- name: Publish to NPM
52+
if: steps.branch.outputs.should_release == 'true'
53+
run: npm publish
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
56+
57+
- name: Get current date
58+
if: steps.branch.outputs.should_release == 'true'
59+
id: date
60+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
61+
62+
- name: Create Github release
63+
if: steps.branch.outputs.should_release == 'true'
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: ${{ github.ref }}
69+
release_name: ${{ format('Release {0} ({1})', github.ref, steps.date.outputs.date) }}

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
{
2-
"name": "chunk-sizes-webpack-plugin",
2+
"name": "@megafon/chunk-sizes-webpack-plugin",
3+
"description": "Webpack plugin for collecting and reporting chunks sizes in OpenMetrics format.",
34
"version": "0.0.1",
45
"main": "lib/index.js",
56
"types": "lib/index.d.ts",
67
"files": [
78
"lib"
89
],
910
"license": "MIT",
10-
"private": true,
11+
"publishConfig": {
12+
"access": "public"
13+
},
1114
"scripts": {
1215
"prepare": "husky install",
1316
"build": "tsc --project tsconfig.build.json",
1417
"typecheck": "tsc",
1518
"test": "jest",
16-
"example:build": "yarn build && webpack --config example/webpack.config.js",
17-
"pre-commit": "yarn typecheck && yarn test"
19+
"example:build": "yarn build && rm -rf example/dist && webpack --config example/webpack.config.js",
20+
"pre-commit": "yarn typecheck && yarn test",
21+
"release": "yarn version --message='Release: v%s'"
1822
},
1923
"peerDependencies": {
2024
"webpack": "^4.0.0 || ^5.0.0"

0 commit comments

Comments
 (0)