-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (124 loc) · 5.03 KB
/
main.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
branches: [ master, github-action ]
pull_request:
branches: [ master ]
jobs:
build:
if: "!contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
node_version: [ 12.x, 13.x, 14.x, 15.x, 16.x, 18.x, 19.x, 20.x, 21.x, 22.x ] # [6.x, 8.x, 10.x, 12.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- name: Restore packages
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Copy appropriate package.json
run: |
if [[ ${{ matrix.node_version }} == 12* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 13* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 14* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 15* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 16* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 17* ]]; then
cp package-below-node-16.json package.json
elif [[ ${{ matrix.node_version }} == 19* ]]; then
cp package-below-node-16.json package.json
fi
- name: yarn install, yarn test:coverage
run: |
yarn install
yarn test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ runner.os }}
- name: Notification
if: always()
id: slack
uses: wingify/slack-github-action@v1.15.1-wingify
with:
channel-id: 'vwo-fs-fme-sdk-job-status' # 'fs-review-team'
slack-message: "<!here> Node.js/JavaScript FME SDK Test on *Node-${{ matrix.node_version }}* and *${{ matrix.os }}* got *${{job.status}}* ${{job.status == 'success' && ':heavy_check_mark:' || ':x:'}} \nCommit: `${{github.event.head_commit.message}}`. \nCheck the latest build: https://github.com/wingify/vwo-fme-node-sdk/actions"
color: "${{job.status == 'success' && '#00FF00' || '#FF0000'}}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
- name: Publish to npm
if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get version from tag
if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract Changelog Entry
if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag
id: changelog
run: |
VERSION=${{ env.VERSION }}
VERSION=${VERSION#refs/tags/}
VERSION=${VERSION#v}
# Use awk to extract all entries between version header and next version header
CHANGELOG_ENTRY=$(awk -v version="$VERSION" '
BEGIN { found=0; buffer="" }
$0 ~ "^## \\[" version "]" { found=1; next }
found && $0 ~ "^## \\[" { exit }
found && NF {
# Remove leading whitespace and common prefixes
gsub(/^[[:space:]]*[-*]?[[:space:]]*/, "")
gsub(/^### (Added|Changed|Fixed|Removed|Deprecated)[[:space:]]*/, "")
if (buffer == "") buffer = $0
else buffer = buffer " " $0
}
END { print buffer }
' CHANGELOG.md)
# If no entry is found, use fallback message
if [ -z "$CHANGELOG_ENTRY" ]; then
CHANGELOG="No changes in this release."
else
# Clean up the entry
CHANGELOG="$CHANGELOG_ENTRY"
fi
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV
- name: Create Release
if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag
id: create_release
uses: comnoco/create-release-action@v2.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }} # Tag name is used as the version
release_name: ${{ github.ref }} # Release name based on the tag
body: |
## What's Changed:
${{ env.CHANGELOG }}
draft: false
prerelease: false