forked from tinify/tinify-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (75 loc) · 2.2 KB
/
ci-cd.yaml
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
name: Node CI/CD
on: [push, pull_request]
permissions: {}
jobs:
Unit_tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
node: [16, 18, 20, 22]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
Integration_tests:
if: github.event_name == 'push'
runs-on: ${{ matrix.os }}
timeout-minutes: 10
needs: Unit_tests
strategy:
fail-fast: false
matrix:
node: [16, 18, 20 ,22]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies
run: npm install
- name: Run test suite
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
run: npm run integration
Publish:
if: |
github.repository == 'tinify/tinify-nodejs' &&
startsWith(github.ref, 'refs/tags') &&
github.event_name == 'push'
timeout-minutes: 10
needs: [Unit_tests, Integration_tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Check if properly tagged
run: |
PACKAGE_VERSION="$(jq '.version' -r < package.json)";
CURRENT_TAG="${GITHUB_REF#refs/*/}";
if [[ "${PACKAGE_VERSION}" != "${CURRENT_TAG}" ]]; then
>&2 echo "Tag mismatch"
>&2 echo "Version in package.json (${PACKAGE_VERSION}) does not match the current tag=${CURRENT_TAG}"
>&2 echo "Skipping deploy"
exit 1;
fi
- name: TS compile
run: npx tsc
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}