Build-Test-Publish #1640
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '12.x' | |
- run: npm ci | |
- run: npm run build | |
python-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [2.7, 3.5, 3.6, 3.7, 3.8] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
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: [ '0.12', '4', '6', '8', '10', '12', '14' ] # Major releases as described in https://nodejs.org/en/download/releases/ | |
name: Node ${{ matrix.node }} sample | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
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@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '12.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
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 fast-geoip | |
- name: Compare new and old data | |
id: compare | |
run: | | |
if ! diff -qrN ./data ./old/node_modules/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 |