Skip to content

Build-Test-Publish #647

Build-Test-Publish

Build-Test-Publish #647

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 "[email protected]"
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