# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Add native binaries to release

on:
  release:
    types: [created]
    

jobs:
  augment-release:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: |
        npm install --build-from-source
        ./node_modules/.bin/node-pre-gyp package
    - name: Upload native binaries for Node ${{ matrix.node-version }} for ${{ matrix.os }}
      uses: csexton/release-asset-action@v2
      with:
        pattern: "build/stage/*.tar.gz"
        github-token: ${{ secrets.GITHUB_TOKEN }}
        release-url: ${{ github.event.release.upload_url }}

# This workflow will prebuild native binaries for supported NodeJS versions, and add them to the Github release that triggered the workflow

name: Add native binaries to release

on:
  release:
    types: [created]

jobs:
  augment-release:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [7.x, 8.x, 9.x, 10.x, 11.x, 12.x]
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: patch node gyp on windows to support Visual Studio 2019
        if: matrix.os == 'windows-latest'
        shell: powershell
        run: |
          npm install --global node-gyp@5.1.1
          npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
      - name: build using node-pre-gyp
        run: |
          npm install --build-from-source
          ./node_modules/.bin/node-pre-gyp package
      - name: Upload native binaries for Node ${{ matrix.node-version }} for ${{ matrix.os }}
        uses: csexton/release-asset-action@v2
        with:
          pattern: "build/stage/*.tar.gz"
          github-token: ${{ secrets.GITHUB_TOKEN }}
          release-url: ${{ github.event.release.upload_url }}

Build binaries for all supported NodeJS versions
Build binaries for all supported NodeJS versions
