forked from onramper/fast-geoip
-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (95 loc) · 2.92 KB
/
build-test-publish.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
name: Build-Test-Publish
on:
push:
branches: [ master ]
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
- run: npm ci
- run: npm run build
python-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Test with unittest
run: |
python tests/testCsvProcessing.py
js-test:
needs: [build, python-test]
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10', '12', '14' , '16' ] # Major releases as described in https://nodejs.org/en/download/releases/
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
publish:
needs: [build, python-test, js-test]
if: ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- run: npm ci
- name: Build typescript files
run: npm run build
- name: Download csv databases
run: python downloadDatabases.py
env:
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
- name: Build data structures
run: |
python processGeoIpCsv.py
- name: Get currently published data
run: |
mkdir old
cd old
npm init -y
npm install doc999tor-fast-geoip
- name: Compare new and old data
id: compare
run: |
if ! diff -qrN ./data ./old/node_modules/doc999tor-fast-geoip/data; then
echo "::set-output name=changed::true"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config user.name "$GITHUB_ACTOR"
npm version patch
else
echo "::set-output name=changed::false"
fi
- run: npm publish
if: github.event_name == 'push' || ( steps.compare.outputs.changed == 'true' && github.event_name == 'schedule' )
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push version changes to github repo
run: git push