-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (79 loc) · 2.71 KB
/
publish.yml
File metadata and controls
94 lines (79 loc) · 2.71 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Publish on NPM
on:
release:
types: [ published ]
jobs:
publish:
# Setup OS and Node Version
runs-on: ubuntu-latest
strategy:
matrix:
# Latest nodes only
node-version: [ 16.16 ]
steps:
# Checkout code
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.ACTION_AUTH_TOKEN }}
# Make sure we have all branches
- name: Fetch other branches
run: git fetch --no-tags --prune --depth=5 origin master
# Setup node
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
cache: 'npm'
- name: Set variables
run: |
LATEST_TAG=${{ github.event.release.tag_name }}
echo $LATEST_TAG
arrIN=(${LATEST_TAG//_/ })
echo "LIBRARY=${arrIN[0]}" >> $GITHUB_ENV
echo "VERSION=${arrIN[1]}" >> $GITHUB_ENV
echo $LIBS
echo $VERSION
# Run Install
- name: Install environment
run: npm ci
- name: Run lint
run: npm run affected:lint -- --base="origin/master"
- name: Tests coverage
run: npm run affected:test -- --base="origin/master" --codeCoverage
- name: Setup version of tagged libraries
run: |
if [ -d "$PWD/packages/$LIBRARY" ]; then
cd $PWD/packages/$LIBRARY
npm version ${VERSION} --allow-same-version
echo "Bumping $LIBRARY"
cd ..
cd ..
fi
- name: Builds components
run: npm run build --prod --with-deps --base="origin/master"
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Commit updated library package.json version
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: chore($LIBRARY)"':'" released $VERSION
commit_user_name: GitHub Action
commit_user_email: action@github.com
commit_author: Author <actions@github.com>
file_pattern: packages/${LIBRARY}/package.json
push_options: '--force -a || true'
- name: Deploy
run: |
echo "Publishing on npmjs ${LIBRARY} - version: ${VERSION}"
if [ -d "$PWD/dist/packages/$LIBRARY" ]; then
cd $PWD/dist/packages/$LIBRARY
npm publish --access=public --ignore-scripts
else
echo "No library: ${LIBRARY}"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}