Skip to content

Commit e990bcb

Browse files
Merge pull request #2 from ensuro/npm-action
Create NPM action and rename package
2 parents c12ec93 + f5bd2bf commit e990bcb

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

.github/workflows/npm.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: NPM Package
2+
on:
3+
push:
4+
branches-ignore:
5+
- "**"
6+
tags:
7+
- v*
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: "Package version"
12+
required: true
13+
tag:
14+
description: "Package tag"
15+
required: true
16+
default: "latest"
17+
type: choice
18+
options:
19+
- latest
20+
- beta
21+
22+
jobs:
23+
npm-upload:
24+
name: NPM Package Build and Upload
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 10
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
32+
- uses: actions/setup-node@v3
33+
with:
34+
node-version: "20"
35+
cache: "npm"
36+
37+
- run: npm ci
38+
- run: npm run build:lib # create the ./lib directory with the files to publish
39+
- run: sed "s/%%VERSION%%/$VERSION/" package.json > "./lib/package.json"
40+
41+
- id: semver
42+
run: |
43+
SEMVER="${{ github.event.inputs.version }}"
44+
if [ -z "$SEMVER" ]; then
45+
# No manual input, we must be running on a tag
46+
SEMVER="${GITHUB_REF/refs\/tags\/v/}"
47+
fi
48+
echo "::set-output name=semver::${SEMVER}"
49+
50+
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTOMATION_TOKEN }}" > ./lib/.npmrc
51+
52+
- run: |
53+
RELEASE_TAG="${{ github.event.inputs.tag }}"
54+
if [ -z "$RELEASE_TAG" ]; then
55+
if grep -q -- '-beta' <<< "${{ steps.semver.outputs.semver }}"; then
56+
RELEASE_TAG=beta
57+
else
58+
# No manual input, we must be running on a tag
59+
RELEASE_TAG=latest
60+
fi
61+
fi
62+
npm publish --tag "$RELEASE_TAG" --access public
63+
working-directory: ./lib

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ API Calls store for react redux
77
## Install
88

99
```bash
10-
npm install --save api-calls-store
10+
npm install --save @ensuro/api-calls-store
1111
```
1212

1313
## Configure
@@ -17,7 +17,7 @@ npm install --save api-calls-store
1717
In the `reducers.js` file:
1818

1919
```js
20-
import APIReducer from "api-calls-store/src/store/api/reducer";
20+
import APIReducer from "@ensuro/api-calls-store/src/store/api/reducer";
2121

2222
export default combineReducers({
2323
// ...
@@ -30,7 +30,7 @@ export default combineReducers({
3030
In the `sagas.js` file:
3131

3232
```js
33-
import { apiSaga, initializeAPIStore } from "api-calls-store/src/package-index";
33+
import { apiSaga, initializeAPIStore } from "@ensuro/api-calls-store/src/package-index";
3434

3535
const clockCount = 15;
3636
initializeAPIStore({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "api-calls-store",
3-
"version": "0.0.6",
2+
"name": "@ensuro/api-calls-store",
3+
"version": "%%VERSION%%",
44
"description": "API Calls Store for React Redux",
55
"scripts": {
66
"prettier": "prettier --write .",

0 commit comments

Comments
 (0)