name: Build and publish Node.js package on: create: tags: - 'v*' repository_dispatch: types: [wf-nodejs] jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest] node: [8, 9, 10, 11, 12, 13, 14] include: - os: ubuntu-latest ARCH: linux-x86_64 - os: macos-latest ARCH: macos-x86_64 steps: - uses: actions/checkout@v1 - name: Get version id: version shell: bash run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')" - name: Set up Node.js uses: actions/setup-node@master with: node-version: ${{ matrix.node }}.x - name: Set up Rust (macOS, Linux) if: runner.os != 'Windows' uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal default: true - name: Set up Rust (Windows) if: runner.os == 'Windows' uses: actions-rs/toolchain@v1 with: toolchain: stable-gnu profile: minimal default: true - name: Set up Go uses: actions/setup-go@v2 with: go-version: '^1.14.0' - name: Set up GCC (Windows) if: runner.os == 'Windows' run: .\.github\workflows\gcc.ps1 - name: Run prebuild steps shell: bash run: bash ./prebuild.sh - name: Build native module working-directory: ./nodejs shell: bash run: | npm install npm run build-binary - name: Install B2 CLI (macOS, Linux) if: runner.os != 'Windows' run: | sudo pip install setuptools sudo pip install --upgrade b2 - name: Install B2 CLI (Windows) if: runner.os == 'Windows' run: | pip install --upgrade b2 - name: Upload to B2 shell: bash run: | binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')" b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }} b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/dist/native.node "hyperbuild/bin/nodejs/${{ steps.version.outputs.VERSION }}/$binary_name.node" package: runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v1 - name: Get version id: version shell: bash run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')" - name: Set up Node.js uses: actions/setup-node@master with: node-version: 14.x - name: Pack and publish package working-directory: ./nodejs run: | cat << 'EOF' > .npmrc package-lock=false //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }} EOF npm install npm run build cp ../README.md . if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then npm publish fi