-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (53 loc) · 1.95 KB
/
public-package-build-test-release-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build publish and test a public NPM package
on:
workflow_call:
inputs:
publish:
required: false
type: boolean
default: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone the repo
uses: actions/checkout@v3
- name: Autodetect and set-up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Documentate tools version
run: |
echo -n 'Node version ' && node -v
echo -n 'NPM version ' && npm -v
- name: Clone workflows repo to get npmrc
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: bluealba/workflows-public
path: pipeline/
- name: Render npmrc file
uses: nowactions/envsubst@v1
with:
input: /home/runner/work/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}/pipeline/files/bluealba/publish_npmrc
output: ./.npmrc
env:
BA_NPMJS_AUTH_TOKEN : ${{ secrets.BA_NPMJS_AUTH_TOKEN }}
- name: Install dependencies
run: |
cat .npmrc
npm install
- name: Test service
run: npm run test --if-present
- name: Build service
run: npm run build --if-present
- name: Create release package
if: contains(github.ref ,'refs/heads/release') || contains(github.ref ,'refs/heads/hotfix') || contains(github.ref ,'refs/heads/master') || contains(github.ref ,'refs/heads/main')
run: npm pack
- name: Publish package
if: inputs.publish && (contains(github.ref ,'refs/heads/release') || contains(github.ref ,'refs/heads/hotfix') || contains(github.ref ,'refs/heads/master') || contains(github.ref ,'refs/heads/main'))
run: |
npm config set access public
npm publish